Skip to content

Instantly share code, notes, and snippets.

@rawls238
Created February 4, 2018 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rawls238/fad44585cffad069e83c6325d030aac2 to your computer and use it in GitHub Desktop.
Save rawls238/fad44585cffad069e83c6325d030aac2 to your computer and use it in GitHub Desktop.
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