LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Coin Toss Simulator


@Edjsch wrote:

@crossrulz wrote:

I think I found a bug in your code.  For your Head>=10 variable, it increments whenever the current streak is >=10.  This means it increments when the streak is at 10, 11, 12, 13, etc.  So for a single streak of 19, it increments 10 times.


Yes, that's how I intended it to work. That looks like the difference with your code, and why mine works like Don's.


Ok, more semantics here.

 

Your code is finding the probability of a streak of 10 heads, regardless if the single toss was already included  in a streak.  Mine finds the number of single streaks of length >= 10.  Again, it is all in what you are looking for.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 91 of 92
(518 Views)
@crossrulz wrote:

Ok, more semantics here.

 

Your code is finding the probability of a streak of 10 heads, regardless if the single toss was already included  in a streak.  Mine finds the number of single streaks of length >= 10.  Again, it is all in what you are looking for.


Yes. That's why your probability (1/2048) is one-half the probability of mine and Don's (1/1024). I keep incrementing the counter even after 10 heads in a row are found. You don't. So I am counting a streak of 11 as 2 streaks >= 10. Glad that's cleared up! Smiley LOL

 

Anyway, I knew the probability had to be a power of 2!

 

Thanks to all for your help. I did learn to use shift registers more, where possible. Also, if my (main) loop is big, I use the equivalent Feedback Node instead. It can make for a cleaner block diagram. Cheers!

 

Ed

0 Kudos
Message 92 of 92
(502 Views)