Wolfram Language

Extended Probability & Statistics

Improved Sampling of Truncated Distributions

Version 11 enhances the sampling of commonly used truncated distributions. The following charts show the speed comparisons for different distributions with various sample size. Experiments were performed on a Windows 10 system with an Intel Xeon Processor E3-1245 v2 3.40 GHz. The number at the bottom shows how much faster Version 11 is than Version 10.

Sampling of a truncated normal distribution.

show complete Wolfram Language input
In[1]:=
Click for copyable input
dist = TruncatedDistribution[{10, Infinity}, NormalDistribution[]]; Table[ BlockRandom[SeedRandom["MarketingExample"]; Mean[Table[First[AbsoluteTiming[RandomVariate[dist, n];]], {5}]]] , {n, {10000, 100000, 1000000}}]
Out[171]=

Sampling of a truncated Cauchy distribution.

show complete Wolfram Language input
In[2]:=
Click for copyable input
dist = TruncatedDistribution[{4, 10}, CauchyDistribution[1, 2]]; Table[ BlockRandom[SeedRandom["MarketingExample"]; Mean[Table[First[AbsoluteTiming[RandomVariate[dist, n];]], {5}]]] , {n, {10000, 100000, 1000000}}]
Out[39]=

Related Examples

de es fr ja ko pt-br ru zh