Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. (* I create a random pdf just as an example *)
  2. pdf = Table[{x, RandomReal[]}, {x, 1, 10, 0.5}];
  3. intpdf = Interpolation@pdf;
  4. norm = Integrate[intpdf[x], {x, 1, 10}];
  5. dist = ProbabilityDistribution[intpdf[x]/norm, {x, 1, 10}];
  6.  
  7. (* no parallelization *)
  8. AbsoluteTiming[RandomVariate[dist, 1000000]][[1]]
  9. (* Out = 7.28052 *)
  10.  
  11. (* parallelization on 8 subkernels *)
  12. ParallelTable[
  13. AbsoluteTiming[RandomVariate[dist, 1000000]][[1]], {i, 1, 8}]
  14. (* Out = {13.021, 12.7993, 13.8139, 13.417, 12.8863, 13.0874, 13.3788, 13.7836} *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement