Timeline for Determine the chance a streak of 6 HEADs or 6 TAILS appear in 100 flips, repeated 10000 times [closed]
Current License: CC BY-SA 4.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 6, 2023 at 8:15 | comment | added | Nova | Thank you, I'm definitely checking that out right now | |
May 6, 2023 at 6:29 | history | closed |
FMc pacmaninbw♦ slepic |
Not suitable for this site | |
May 6, 2023 at 1:00 | comment | added | FMc | That ambiguity is one small reason why I dislike the book (the primary reason is that it places too little emphasis on building programs with functions). I had forgotten about a review of this very question I wrote a while back. My interpretation of the question appears to be shared by others. If you're interested, here's the review. | |
May 6, 2023 at 0:45 | comment | added | Nova | Hmm.. That's an interesting interpretation. I suppose the only way to know exactly what he meant is to ask the author himself | |
May 6, 2023 at 0:16 | comment | added | FMc | As I interpret the question, it asks the following: what percentage of "experiments" result in "success"? An experiment is flipping a coin 100 times. And success is a streak of 6+ heads or tails. To answer this question, you want to count successful experiments, not the total number of streaks across all experiments. Your code does the latter, but that overcounts things because a single experiment can contain multiple long steaks. | |
May 5, 2023 at 22:14 | vote | accept | Nova | ||
May 5, 2023 at 20:41 | comment | added | Nova | @FMc Yes. The numbers look off to me. I never suspected anything wrong with the suggestion but I don't full understand the last line of code. What do you mean by "counting streaks within an experiment rather than simply checking whether the experiment contains a sufficiently large streak or not"? I don't understand this part. Thank u for your insight The book is written by Al Sweigart. I'm new to Python but it seems to me like a reputable book, recommended by lots of sites for newbies so I'm surprised that the code would be faulty | |
May 5, 2023 at 20:35 | review | Close votes | |||
May 6, 2023 at 6:32 | |||||
May 5, 2023 at 20:18 | comment | added | FMc | If you flip a coin 100 times, the probability that the flips contain a streak of 6 or more cannot be greater than 100%. That means the program logic is incorrect (and technically that your question is off-topic for CodeReview). Your primary error comes from the low quality book you are reading: it has you compute the probability by dividing by 100 rather than by the number of experiments. Your second error is in counting streaks within an experiment rather than simply checking whether the experiment contains a sufficiently large streak or not. | |
May 5, 2023 at 18:08 | answer | added | Kache | timeline score: 2 | |
May 5, 2023 at 16:32 | history | edited | Sᴀᴍ Onᴇᴌᴀ♦ | CC BY-SA 4.0 |
add link to online version of book - like this similar question: https://codereview.stackexchange.com/q/275130/120114
|
May 5, 2023 at 16:25 | history | edited | Sᴀᴍ Onᴇᴌᴀ♦ | CC BY-SA 4.0 |
remove Thanks - say thanks by voting - see https://codereview.stackexchange.com/help/behavior and https://codereview.stackexchange.com/help/why-vote ; update formatting
|
S May 5, 2023 at 16:19 | review | First questions | |||
May 5, 2023 at 16:25 | |||||
S May 5, 2023 at 16:19 | history | asked | Nova | CC BY-SA 4.0 |