MathGroup Archive 2011

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

Search the Archive

Re: average of the consecutive coin tosses

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122001] Re: average of the consecutive coin tosses
  • From: "Dr. Wolfgang Hintze" <weh at snafu.de>
  • Date: Sat, 8 Oct 2011 05:35:23 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j6jobf$lv7$1@smc.vnet.net>

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