Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5473 > unrolled thread
| Started by | michael partensky <partensky@gmail.com> |
|---|---|
| First post | 2011-10-07 08:50 +0000 |
| Last post | 2011-10-07 08:50 +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.
Re: average of the consecutive coin tosses michael partensky <partensky@gmail.com> - 2011-10-07 08:50 +0000
| From | michael partensky <partensky@gmail.com> |
|---|---|
| Date | 2011-10-07 08:50 +0000 |
| Subject | Re: average of the consecutive coin tosses |
| Message-ID | <j6mehd$7bp$1@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@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@gmail.com]
> Sent: Thursday, October 06, 2011 4:18 AM
> To: mathgroup@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
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web