Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5534
| From | "Dr. Wolfgang Hintze" <weh@snafu.de> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: average of the consecutive coin tosses |
| Date | 2011-10-08 18:49 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j6q5ve$p11$1@smc.vnet.net> (permalink) |
| References | <j6jobf$lv7$1@smc.vnet.net> |
Hi,
a = Table[2*Random[Integer, {0, 1}] - 1, {10^3}];
b = FoldList[Plus, a[[1]], Drop[a, 1]];
N[Mean[b]]
... and say hello to "this guy" ;-)
Wolfgang
"michael partensky" <partensky@gmail.com> schrieb im Newsbeitrag
news:j6jobf$lv7$1@smc.vnet.net...
> 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 comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
average of the consecutive coin tosses michael partensky <partensky@gmail.com> - 2011-10-06 08:19 +0000 Re: average of the consecutive coin tosses Jonas <coroa@online.de> - 2011-10-07 09:01 +0000 Re: average of the consecutive coin tosses Peter Pein <petsie@dordos.net> - 2011-10-07 09:10 +0000 Re: average of the consecutive coin tosses Peter Pein <petsie@dordos.net> - 2011-10-07 09:11 +0000 Re: average of the consecutive coin tosses "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-10-08 18:49 +0000
csiph-web