MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

problem with RandomInteger

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112175] problem with RandomInteger
  • From: Yuri Izrailsky <izrailsk at iacp.dvo.ru>
  • Date: Fri, 3 Sep 2010 06:10:01 -0400 (EDT)
  • Reply-to: Yuri Izrailsky <izrailsk at iacp.dvo.ru>

Hello Mathgroup,

  I have recently encountered a strange behavior of RandomInteger
function when used inside Module construct. Here is an example:

str1[] := Module[{l, i, j},
  l = {0, 0, 0};
  i = RandomInteger[{1, 3}];
  l[[i]] = 1;
  j = RandomInteger[{1, 3}];
  l[[j]]
  ]
  
In[3]:= N[Total[Table[str1[],{200}]]]/200
Out[3]= 0.345

which is reasonably close to 1/3, but

In[5]:= N[Total[Table[str1[],{1000}]]]/1000
Out[5]= 0.997

looks very strange. What's happening here?

TIA, Yuri.




  • Prev by Date: Re: Another question on ParallelDo
  • Next by Date: Strange colour highlighting in functions
  • Previous by thread: Re: List of all "Built-in Mathematica Symbols".
  • Next by thread: Re: problem with RandomInteger