4 typo
source | link

Observe:

TableForm@
 Map[{First[Timing[RandomVariate[BinomialDistribution[10 #, 1/#]]]],
      First[Timing[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]]]]} &,
  {1500, 3000, 5000, 10000}]

0.          0.733205
0.          1.809612
0.          3.447622
0.          0.

Note how the timing goes through the roof simply lowering the probability a tiny amount.

If appears for lowish n in Binomial[n,p], when n*p<10, things get strange.

9.01 Windows, would appreciate if others could confirm behavior.

N.b - the times above are on my loungebook, so you might need to use this on a real machine to compare - do you see the same drop?:

TableForm@
 Map[{First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/#]], {100}]]],
    First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]], {100}]]]} &,
  {1500, 3000, 5000, 10000}]

Update: This appears to be caused by heuristics in method switching (hazily outlined in the documentation), probably between a lookup/alias and other methods. This can be seen from:

Table[{MaxMemoryUsed[RandomVariate[BinomialDistribution[10 x, 1./(x)]]], 
       MaxMemoryUsed[RandomVariate[BinomialDistribution[10 x, 1/(x + 1)]]]}, 
    {x, {9999, 10000}}]

(* {{3320, 12630024}, {3200, 2440}} *)

Where in this case, x>=10K uses an alternate method.

Observe:

TableForm@
 Map[{First[Timing[RandomVariate[BinomialDistribution[10 #, 1/#]]]],
      First[Timing[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]]]]} &,
  {1500, 3000, 5000, 10000}]

0.          0.733205
0.          1.809612
0.          3.447622
0.          0.

Note how the timing goes through the roof simply lowering the probability a tiny amount.

If appears for lowish n in Binomial[n,p], when n*p<10, things get strange.

9.01 Windows, would appreciate if others could confirm behavior.

N.b - the times above are on my loungebook, so you might need to use this on a real machine to compare - do you see the same drop?:

TableForm@
 Map[{First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/#]], {100}]]],
    First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]], {100}]]]} &,
  {1500, 3000, 5000, 10000}]

Update: This appears to be caused by heuristics in method switching (hazily outlined in the documentation), probably between a lookup/alias and other methods. This can be seen from:

Table[{MaxMemoryUsed[RandomVariate[BinomialDistribution[10 x, 1./(x)]]], 
       MaxMemoryUsed[RandomVariate[BinomialDistribution[10 x, 1/(x + 1)]]]}, 
    {x, {9999, 10000}}]

(* {{3320, 12630024}, {3200, 2440}} *)

Where in this case, x>=10K uses an alternate method.

Observe:

TableForm@
 Map[{First[Timing[RandomVariate[BinomialDistribution[10 #, 1/#]]]],
      First[Timing[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]]]]} &,
  {1500, 3000, 5000, 10000}]

0.          0.733205
0.          1.809612
0.          3.447622
0.          0.

Note how the timing goes through the roof simply lowering the probability a tiny amount.

If appears for lowish n in Binomial[n,p], when n*p<10, things get strange.

9.01 Windows, would appreciate if others could confirm behavior.

N.b - the times above are on my loungebook, so you might need to use this on a real machine to compare - do you see the same drop?:

TableForm@
 Map[{First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/#]], {100}]]],
    First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]], {100}]]]} &,
  {1500, 3000, 5000, 10000}]

Update: This appears to be caused by heuristics in method switching (hazily outlined in the documentation), probably between a lookup/alias and other methods. This can be seen from:

Table[{MaxMemoryUsed[RandomVariate[BinomialDistribution[10 x, 1/(x)]]], 
       MaxMemoryUsed[RandomVariate[BinomialDistribution[10 x, 1/(x + 1)]]]}, 
    {x, {9999, 10000}}]

(* {{3320, 12630024}, {3200, 2440}} *)

Where in this case, x>=10K uses an alternate method.

3 added 426 characters in body
source | link

Observe:

TableForm@
 Map[{First[Timing[RandomVariate[BinomialDistribution[10 #, 1/#]]]],
      First[Timing[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]]]]} &,
  {1500, 3000, 5000, 10000}]

0.          0.733205
0.          1.809612
0.          3.447622
0.          0.

Note how the timing goes through the roof simply lowering the probability a tiny amount.

If appears for lowish n in Binomial[n,p], when n*p<10, things get strange.

9.01 Windows, would appreciate if others could confirm behavior.

N.b - the times above are on my loungebook, so you might need to use this on a real machine to compare - do you see the same drop?:

TableForm@
 Map[{First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/#]], {100}]]],
    First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]], {100}]]]} &,
  {1500, 3000, 5000, 10000}]

Update: This appears to be caused by heuristics in method switching (hazily outlined in the documentation), probably between a lookup/alias and other methods. This can be seen from:

Table[{MaxMemoryUsed[RandomVariate[BinomialDistribution[10 x, 1./(x)]]], 
       MaxMemoryUsed[RandomVariate[BinomialDistribution[10 x, 1/(x + 1)]]]}, 
    {x, {9999, 10000}}]

(* {{3320, 12630024}, {3200, 2440}} *)

Where in this case, x>=10K uses an alternate method.

Observe:

TableForm@
 Map[{First[Timing[RandomVariate[BinomialDistribution[10 #, 1/#]]]],
      First[Timing[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]]]]} &,
  {1500, 3000, 5000, 10000}]

0.          0.733205
0.          1.809612
0.          3.447622
0.          0.

Note how the timing goes through the roof simply lowering the probability a tiny amount.

If appears for lowish n in Binomial[n,p], when n*p<10, things get strange.

9.01 Windows, would appreciate if others could confirm behavior.

N.b - the times above are on my loungebook, so you might need to use this on a real machine to compare - do you see the same drop?:

TableForm@
 Map[{First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/#]], {100}]]],
    First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]], {100}]]]} &,
  {1500, 3000, 5000, 10000}]

Observe:

TableForm@
 Map[{First[Timing[RandomVariate[BinomialDistribution[10 #, 1/#]]]],
      First[Timing[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]]]]} &,
  {1500, 3000, 5000, 10000}]

0.          0.733205
0.          1.809612
0.          3.447622
0.          0.

Note how the timing goes through the roof simply lowering the probability a tiny amount.

If appears for lowish n in Binomial[n,p], when n*p<10, things get strange.

9.01 Windows, would appreciate if others could confirm behavior.

N.b - the times above are on my loungebook, so you might need to use this on a real machine to compare - do you see the same drop?:

TableForm@
 Map[{First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/#]], {100}]]],
    First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]], {100}]]]} &,
  {1500, 3000, 5000, 10000}]

Update: This appears to be caused by heuristics in method switching (hazily outlined in the documentation), probably between a lookup/alias and other methods. This can be seen from:

Table[{MaxMemoryUsed[RandomVariate[BinomialDistribution[10 x, 1./(x)]]], 
       MaxMemoryUsed[RandomVariate[BinomialDistribution[10 x, 1/(x + 1)]]]}, 
    {x, {9999, 10000}}]

(* {{3320, 12630024}, {3200, 2440}} *)

Where in this case, x>=10K uses an alternate method.

    Tweeted twitter.com/#!/StackMma/status/636767012518260736
2 added 368 characters in body
source | link

Observe:

TableForm@
 Map[{First[Timing[RandomVariate[BinomialDistribution[10 #, 1/#]]]],
      First[Timing[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]]]]} &,
  {1500, 3000, 5000, 10000}]

0.          0.733205
0.          1.809612
0.          3.447622
0.          0.

Note how the timing goes through the roof simply lowering the probability a tiny amount.

If appears for lowish n in Binomial[n,p], when n*p<10, things get strange.

9.01 Windows, would appreciate if others could confirm behavior.

N.b - the times above are on my loungebook, so you might need to use this on a real machine to compare - do you see the same drop?:

TableForm@
 Map[{First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/#]], {100}]]],
    First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]], {100}]]]} &,
  {1500, 3000, 5000, 10000}]

Observe:

TableForm@
 Map[{First[Timing[RandomVariate[BinomialDistribution[10 #, 1/#]]]],
      First[Timing[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]]]]} &,
  {1500, 3000, 5000, 10000}]

0.          0.733205
0.          1.809612
0.          3.447622
0.          0.

Note how the timing goes through the roof simply lowering the probability a tiny amount.

If appears for lowish n in Binomial[n,p], when n*p<10, things get strange.

9.01 Windows, would appreciate if others could confirm behavior.

Observe:

TableForm@
 Map[{First[Timing[RandomVariate[BinomialDistribution[10 #, 1/#]]]],
      First[Timing[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]]]]} &,
  {1500, 3000, 5000, 10000}]

0.          0.733205
0.          1.809612
0.          3.447622
0.          0.

Note how the timing goes through the roof simply lowering the probability a tiny amount.

If appears for lowish n in Binomial[n,p], when n*p<10, things get strange.

9.01 Windows, would appreciate if others could confirm behavior.

N.b - the times above are on my loungebook, so you might need to use this on a real machine to compare - do you see the same drop?:

TableForm@
 Map[{First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/#]], {100}]]],
    First[Timing[Do[RandomVariate[BinomialDistribution[10 #, 1/(# + 1)]], {100}]]]} &,
  {1500, 3000, 5000, 10000}]
1
source | link