Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5511

Re: average of the consecutive coin tosses

From Peter Pein <petsie@dordos.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: average of the consecutive coin tosses
Date 2011-10-07 09:11 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j6mfnm$7nr$1@smc.vnet.net> (permalink)
References <j6jobf$lv7$1@smc.vnet.net>

Show all headers | View raw


Am 06.10.2011 10:19, schrieb michael partensky:
> 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
sorry, I forgot to mention that using machine-precision floats is a lot
faster:

Accumulate[RandomInteger[1, 1000]//N]N[Range[1000]]^-1

is ~65 times faster than the element-wise code

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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