[Date Index]
[Thread Index]
[Author Index]
Re: Re: Using The Random Function to predict Things
*To*: mathgroup at smc.vnet.net
*Subject*: [mg63032] Re: [mg63004] Re: Using The Random Function to predict Things
*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>
*Date*: Sun, 11 Dec 2005 04:57:12 -0500 (EST)
*References*: <dnbn04$5qv$1@smc.vnet.net> <200512101103.GAA29413@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
On 10 Dec 2005, at 20:03, Peter Pein wrote:
> mathuser schrieb:
>> Hi there friends...
>> I used this line of code "typicalList = Table[Random[Integer],
>> {50}]" and got this result...
>>
>> {1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0,
>> 0, 0, 0, \
>> 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1,
>> 1, 0, 1}
>>
>> By generating a few more of these random lists, I'm to predict a
>> similiar situation: such as how long i would expect to wait for 3
>> heads in a coin tossing competition...
>>
>> any suggestion or help as to what code i could use to do this?
>>
>> thanks a lot guys
>>
> Hi,
>
> in this kind of sequence you've got 2^k possibilities of k subsequent
> numbers. One of them consits of k times the one. As 1 and 0 occur with
> the same probability, one would expect to wait on average 2(2^k-1)
> "tosses" of digits.
>
This answer is, of course, correct. In fact the answer to the
question "how many flips of a coin are needed on the average to get
any specified pattern" is well known and due to A. D. Solvev. The
whole problem is solved in detail in Knuth's book "Concrete
Mathematics" ( see particularly page 394 in the chapter "Discrete
Probability").
A simple way to simulate tossing a coin until three heads come up is:
simulate[k_]:=NestWhileList[Random[Integer]&,0,Plus[##]=!=k&,k]
For example:
simulate[5]
{0,1,0,1,1,0,1,0,1,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,0,1,0,0,1,0,1,0,0,0,0
,0,1,\
1,1,0,0,0,1,1,1,0,1,1,0,0,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,1,0,1,0,
0,1,0,\
0,1,1,0,1,1,0,0,1,0,0,0,0,1,1,0,1,0,1,0,1,0,1,1,1,0,0,1,1,1,1,0,0,1,0,1,
0,0,0,\
1,1,1,0,0,1,1,1,1,0,1,1,0,0,1,1,1,1,1}
Andrzej Kozlowski
Prev by Date:
**Re: A list of numbers without "73"**
Next by Date:
**Re: functional programming**
Previous by thread:
** Re: Using The Random Function to predict Things**
Next by thread:
**Re: Re: Using The Random Function to predict Things**
| |