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: [mg121956] Re: average of the consecutive coin tosses
  • From: michael partensky <partensky at gmail.com>
  • Date: Fri, 7 Oct 2011 04:47:46 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201110060818.EAA22381@smc.vnet.net>

Thanks, Michael.
Best
MP

On Thu, Oct 6, 2011 at 11:34 AM, Michael Stern <nycstern at gmail.com> wrote:

> 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
>>
>


  • Prev by Date: Re: list equation
  • Next by Date: Re: list equation
  • Previous by thread: Re: average of the consecutive coin tosses
  • Next by thread: Re: average of the consecutive coin tosses