Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

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

O sorry!
I looked in a wrong place!
This is extremely elegant!

Please ignore my previous response, except for the congrats :)
Thanks
Michael
On Thu, Oct 6, 2011 at 11:01 AM, Daniel Lichtblau <danl at wolfram.com> wrote:

> On 10/06/2011 03: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
>>
>
> n = 1000;
> avgs = Accumulate[RandomInteger[1, n]]/N[Range[n]];
>
> Daniel
>


  • Prev by Date: Re: How to use PDF for function definition?
  • 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