MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Using The Random Function to predict Things

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63003] Re: Using The Random Function to predict Things
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Sat, 10 Dec 2005 06:03:27 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 12/9/05 at 5:10 AM, fieryashish at gmail.com (mathuser) wrote:

>I used this line of code "typicalList =
>Table[Random[Integer], {50}]" and got this result...

<snip>

>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?

This looks like it might be homework. Also, there is some ambiguity as to precisely what you want to simulate.

Perhaps you are looking for the number of coin tosses needed to get exactly 3 heads in a row. Or perhaps it is at least 3 heads in a row. Or maybe you simply toss the coin until heads appear three times in a row and stop and it is the total number of coin tosses you want.

I am going to assume the last scenario and outline an approach. It is clear from what you posted you already understand how to generate a list to simulate n coin tosses. The next thing to do would be to group that list into runs.

This can be done with Split. And

runLst={First@#,Length@#}&/@Split[Table[Random[Integer],{n}]]

will give me list of {state, run length} pairs.

So,

n=Position[runLst, {1,3}][[1,1]]

will be the number of pairs up to the first occurance of a run of three heads (I am representing a head with 1).

Total[Last/@Take[runLst,{n}]]

will be the total number of coin tosses that occured including the run of three heads.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: UML-like diagrams for Mathematica
  • Next by Date: Re: Solve Limitations
  • Previous by thread: Re: Using The Random Function to predict Things
  • Next by thread: Re: Using The Random Function to predict Things