LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Coin Toss Simulator


@Edjsch wrote:

But isn't the control or indicator itself the FIRST memory storage location, and the shift register or one local variable the second? This may be a matter of semantics.


A shift register doesn't require any associated control or indicator, so only one copy. Your code had a couple of hidden indicators that you were using only as local storage. Those should be replaced with shift registers, since there's no reason to have an extra unused copy of them on the front panel.

0 Kudos
Message 41 of 92
(1,259 Views)

That's true. Good point.

0 Kudos
Message 42 of 92
(1,257 Views)

Altenbach,

 

Your code is "proving" or showing what I was getting in my original code, that 40% of the time I'd get a streak of 10 or more in 1024 tosses. I expected it to be slightly over 50% (because there are diminishingly small chances of getting 11 or 12 or 13, etc., in a row). We still must have the math wrong, or there is some other explanation. I can't open that Bernoulli vi, so I can't see. Can you make your vi without it?

 

(BTW, this seems to prove that my use of local variables is not the problem).

 

0 Kudos
Message 43 of 92
(1,252 Views)

Don_Phillips,

 

The forum posts are coming in fast and furiously, crossing and getting a little mixed up / out of sequence!

 

I'd like to hear you reply to my 04-18-2013 02:01 PM post, which was a reply to your 04-18-2013 01:40 PM post.

 

Thanks,

Ed

0 Kudos
Message 44 of 92
(1,250 Views)

I changed my comparison from >= 10 to = 10 and get 1/2 of the number of heads in a row than previously. In other words, instead of my average of 1067, I got 537 on my first run. Subsequent runs were about the same.

 

This makes sense because the sum of all probabilities > 10 equals the probability of being exactly 10! (Math wizards, look at the infinite series Sum[1/(2^N)] from 0 to infinity.)

 

So the answer to a previous question is that 1/1024 is the probability of 10 or more heads in a row. Expressed in another way, the probability of getting 10 or more heads in a row in 1024 tosses is 50%, just as the probability of getting 1 head in one toss is 50%. (It's still troubling me as to why we are getting about 40%.)

 

 

0 Kudos
Message 45 of 92
(1,237 Views)

@Edjsch wrote:

 

 

So the answer to a previous question is that 1/1024 is the probability of 10 or more heads in a row. Expressed in another way, the probability of getting 10 or more heads in a row in 1024 tosses is 50%, just as the probability of getting 1 head in one toss is 50%. (It's still troubling me as to why we are getting about 40%.)

 

 


 

NO NO NO.  You are still confusing the conditions of what you are looking at.  You are saying one thing, then are thinking about something else.

 

The 40% is coming from the likelihood of having at least one stretch of at least 10 heads within a run of a 1000 tosses.

 

Your chances of 10 consecutive heads in a row are 1 in 1024.  But what are your chances of 10 consectutive heads if you had only 11 tosses?  It is about twice as much.  You could have the 1st 10 of the 11 be heads, or the last 10 of the 11 be heads.  What are you chances of 10 heads within 20 tosses.  Still higher.  Your run of 10 could start anywhere from toss 1 to toss 11.  It is much better than twice as much because your chances of 10 in a row for the first 10 are 1 in 1024.  10 in a row for the 2nd 10 is 1 in 1024.  But what about if you had the last 6 of the first 10, and the first 4 of the second 10.  Neither meets the requirements if you are only looking at 10, but once you sequence the two 10's together, now you have that possibility.

 

As the number of consecutive throws approaches infinity, then the probability of at least 10 heads in a row happening at least once is going to approach 100%.

The chance of having a 10th head in a row after having already thrown 9 in a row, is still precisely 50%.  The probability of a 10 head run within a 1000 is just a measure of how long it might take to get to the precondition that you need to throw 9 in a row before you can determine what happens on the 10th.

 

What are your chances of 10 in a row with exactly 10 tosses.  Very low.  What are your chances of NOT getting 10 in a row with only 10 tosses.  Very high.

As you continue to make longer and longer stretches of tosses, don't you believe that the probably of getting 10 in a row sometime during a long run is going to increase?

 

0 Kudos
Message 46 of 92
(1,231 Views)

RavensFan,

 

>> As you continue to make longer and longer stretches of tosses, don't you believe that the probably of getting 10 in a row sometime during a long run is going to increase?

 

Yes, of course. As the number of tosses approaches infinity the probability approaches 100%, as you said.

 

But what I am saying (trying to say) is that in an infinite number of tosses, on average in every 1024 tosses there will be a streak of 10 or more heads half the time (50% probability). Does this make sense?

 

This is what I had intended my program to prove, but instead it's showing 40%. Others have also gotten 40%, but I don't understand why or exactly what they did. So my first thought was I made a coding error, but I don't see how we get 40%. It should be either 50%, 25%, etc. when using a binary (2 possible outcomes) coin flip.

 

Ed

0 Kudos
Message 47 of 92
(1,208 Views)

If the theory does not fit the experimental data, I typically blame the theory. 😄

0 Kudos
Message 48 of 92
(1,206 Views)

@Edjsch wrote:

[...]

But what I am saying (trying to say) is that in an infinite number of tosses, on average in every 1024 tosses there will be a streak of 10 or more heads half the time (50% probability). Does this make sense?

 

This is what I had intended my program to prove, but instead it's showing 40%.[...]

Ed


Ed,

 

common sense shares your view of 50%. Somehow. But statistics is not common sense 😉

Well, the point is:

You say that each toss is an independant event. 50% heads, 50% tail. That's true.

BUT:

If you state that you want to have 10 heads (or tail, doesn't matter) in a row within a specific amount of tosses, the tosses are not independent anymore!

 

Let's dig into that:

We say, heads (H) is what we are looking for. So the first toss, the chance of getting H or T (tail) is 50:50. In case we get H, we begin a streak. In case of T, the streak has not started yet.

Either way, we spent one toss, so we have only n-1 tosses left to achieve the streak!

So with any toss not completing the streak, chances are growing against us. Even if the indiviual toss still has a 50:50 chance for H:T.....

 

just my 5 cents (one coin!),

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 49 of 92
(1,202 Views)

Right you are, Altenbach. But since we have not done a million actual coin tosses I need to rely on coding what I believe the theory to be. That gives 2 sources of error! Even that link to Mark Nelson's "interesting" web page did not totally clear up things.

 

So here's the question: Say you are flipping a fair coin and there is currently a streak of 10 heads in a row, would you bet the next toss will be heads or tails?

 

Ed

0 Kudos
Message 50 of 92
(1,199 Views)