Created
February 4, 2018 22:27
-
-
Save rawls238/fad44585cffad069e83c6325d030aac2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import multiprocessing | |
from joblib import Parallel, delayed | |
from scipy.stats import bernoulli | |
def test(i, dist): | |
#dist = bernoulli(0.7) | |
return dist.rvs() | |
numCores = multiprocessing.cpu_count() | |
dist = bernoulli(0.7) | |
results = Parallel(n_jobs=numCores)(delayed(test)(i, dist) for i in xrange(1000)) | |
print(np.mean(results)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment