04-25-2013 10:52 AM
@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.
04-25-2013 01:50 PM
@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!
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