Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5481 > unrolled thread

Re: average of the consecutive coin tosses

Started byMichael Stern <nycstern@gmail.com>
First post2011-10-07 08:55 +0000
Last post2011-10-07 08:55 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: average of the consecutive coin tosses Michael Stern <nycstern@gmail.com> - 2011-10-07 08:55 +0000

#5481 — Re: average of the consecutive coin tosses

FromMichael Stern <nycstern@gmail.com>
Date2011-10-07 08:55 +0000
SubjectRe: average of the consecutive coin tosses
Message-ID<j6mepg$7eo$1@smc.vnet.net>
Your way:

Timing[(flips = 1; (#/flips++) & /@
      Accumulate[Table[RandomInteger[], {10000}]]) // N;]

{0.078, Null}



My way:

Timing[Accumulate[RandomInteger[{0, 1}, 10000]]/Range[10000] // N;]

{0.032, Null}




On 10/6/2011 4:18 AM, michael partensky wrote:
> 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

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web