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

This looks  nice,
much better than my later version,
coinFlipNest[n_]:=Module[{flipCount=0.},NestList[((flipCount # +
RandomInteger[])/(++flipCount))&,0,n]]
(this also adopts Sseziwa's advice).
Multiply  the previous outcome by flipCount did not seem natural.
 Any ideas involving better use of NestList?

Thanks
MP

On Thu, Oct 6, 2011 at 9:48 AM, Harvey P. Dale <hpd1 at nyu.edu> wrote:

>        Perhaps something like this:
>
> With[{numberoftosses=500},Accumulate[RandomInteger[{0,1},numberoftosses]
> ]/Range[numberoftosses]]//N
>
>        Best,
>
>        Harvey
>
>
> -----Original Message-----
> From: michael partensky [mailto:partensky at gmail.com]
> Sent: Thursday, October 06, 2011 4:18 AM
> To: mathgroup at smc.vnet.net
> Subject: average of the consecutive coin tosses
>
> 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: How to use PDF for function definition?
  • Next by Date: Mathematica
  • Previous by thread: Re: average of the consecutive coin tosses
  • Next by thread: Re: average of the consecutive coin tosses