MathGroup Archive 2011

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

Search the Archive

Re: average of the consecutive coin tosses


Hi,

a = Table[2*Random[Integer, {0, 1}] - 1, {10^3}];
b = FoldList[Plus, a[[1]], Drop[a, 1]];
N[Mean[b]]

... and say hello to "this guy" ;-)

Wolfgang

"michael partensky" <partensky at gmail.com> schrieb im Newsbeitrag 
news:j6jobf$lv7$1 at smc.vnet.net...
> Hi.
>
> What are the better ways of doing what this guy does very 
> inefficiently for
> the average of the consecutive coin tosses:
>
> tr = (flips = 1; (#/flips++) & /@ Accumulate[Table[toss, {1000}]]) // 
> N);
>
> where
>
> toss= RandomInteger[];
>
> Thanks
> Michael




  • Prev by Date: Compilation of c mathlink
  • Next by Date: mathematica antialiasing quality has no influence
  • Previous by thread: Re: average of the consecutive coin tosses
  • Next by thread: importing data into a CDF