MathGroup Archive 2005

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

Search the Archive

Re: The two dices

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54508] Re: The two dices
  • From: Peter Pein <petsie at arcor.de>
  • Date: Tue, 22 Feb 2005 04:23:05 -0500 (EST)
  • References: <cvc8dt$qte$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Antoine wrote:
> Hello,
> 
> I wanted to simulate the throws of two dices and something happened I can't
> explain:
> (Mathematica 5.0 , the same occurs on Mathematica 5.1 )
> 
> 
> The following code is OK:
> 
> 
> n=300;
> theThrows = Table[Random[Integer, {1, 6}] + Random[Integer, {1, 6}], {n}];
> theStats = Table[Count[theThrows, i], {i, 2, 12}]
> 
> 
> the occurences, as n becomes greater and greater, looks like the Gaussian
> curve
> (sorry for my English)
> 
> 
> Suppose you want your dice function, and that it is defined by
> 
> 
> dice[]:=Random[Integer, {1, 6}]  ( nothing wrong about it, I suppose )
> 
> 
> Now the behavior of the following code changes depending on the value of n.
> If n < 250 everything is fine ...
> hen n >= 250, then there is no occurence of odd values.
> ( the two dices never give 3, 5, ....)
> 
> 
> n=250;
> theThrows = Table[dice[] + dice[], {n}];
> theStats = Table[Count[theThrows, i], {i, 2, 12}]
> 
> 
> Does a rationnal explanation exists ?  Is it a bug ?
> 
> 
> The two definitions ( see below ) of the dice function "makes" the code
> running properly.
> But, of course, I prefer the former definition.
> 
> 
> dice:=Random[Integer, {1, 6}]  ( not so nice, specially if you want to have
> several dice functions)
> dice[_]:=Random[Integer, {1, 6}]   ( you must give a parameter to the
> function, quite horrible )
> 
> 
> Thank you for your help.
> Antoine
> 
> 
Salut Antoine,

have a look at
Table[d[]+d[],{3}]
==>
{2 d[],2 d[],2 d[]}

If you define twoDices[]:=dice[]+dice[] or - for an arbitrary number of 
dices - dices[k_]:=Plus@@Table[dice[],{k}], everything works as 
expected. But don't ask me, why this phenomenon occurs for n>=250 but 
not for smaller values of n.

-- 
Peter Pein
Berlin


  • Prev by Date: Re: Show command trims bitmap edges? (newbie)
  • Next by Date: Re: The two dices
  • Previous by thread: Re: The two dices
  • Next by thread: Re: The two dices