import randomĬoinFlip = # (1) create a new, empty list for this list of 100 I have marked modifications with comments prefixed by # and numbered them with reference to the explanations that follow. The following is a set of minor modifications to the initially provided code that will compute the estimate correctly. Output: Chance of streak: 0.7834% rather than. Print('Chance of streak: %s%%' % chance_percent) #function that converts decimal to percent and rounds # Code that creates a list of 100 'heads' or 'tails' values.'Ĭhance = (numberOfStreaks / total_instances) Lastly, changed the hard coding to variables, obviously doesn't matter but just to explain the things I changed. Therefore, I added a function that converts a decimal to percentage and rounds it to 4 decimal places. I was just working on the same problem in my own learning process.įirst, I was unsure why you used multiple for loops when the range was the same length, so I combined those and continued to get the same results.Īlso, I noticed that the final calculation is presented as a percentage but not converted to a percentage from the original calculation.įor example, 5/100 =. I am new to programming so anyone please correct me if I'm wrong. I wasn't able to comment on Stuart's answer because I recently joined and don't have the reputation, so that's why this an answer on it's own. I'm not sure why their "hint" suggest dividing by only 100. I also think you need to divide by 100*10000 to get the real probability. for experimentNumber in range(10000):Įlif CoinFlip = CoinFlip: #checks if current list item is the same as before I also added a check for i=0 so that you're not comparing to the end of the list, because that's not technically part of the streak. Your current program just keeps appending to CoinFlip, which makes for a very long list. Where did I make the mess? I can't really see it! Print('Chance of streak: %s%%' % (numberOfStreaks / 100)) If CoinFlip = CoinFlip: #checks if current list item is the same as before # Code that checks if there is a streak of 6 heads or tails in a row. I am going to check if there is multiple 0 or 1 in a row #does not matter if it is 0 or 1, H or T, peas or lentils. # Code that creates a list of 100 'heads' or 'tails' values. Do I have a problem with the first iteration of the comparison of current value to value before (as far as I understand it, I would compare index -1 (which then is index 100?) to the current one?) import random I tried to be as lazy as possible which results in my macbook working really hard. Therefore, if you guys could just point out the errors in the code, that would be nice :) But in previous questions the coding problem was described as a bit fuzzy. The task is to to 10.000 samples of 100 flips each and then compute the probability of a 6x heads or tails streak over all the samples - as far as I understand it. It’s a simple calculation but we’ve made it a little bit easier with this calculator.I know there's tons of questions about it by now, even for the same problem, but I think I tried a bit of a different approach. Say goodbye to an average of 25 cents every time you place this bet. Let’s see how that fits into our equation assuming the same bet size of $10: (9.50 *. Now, let’s assume the odds don’t reflect the 50/50 probability and the bookmaker has provided bookmakeresque odds of $1.95. Here is the formula in its raw form (Amount won per bet * probability of winning) – (Amount lost per bet * probability of losing) =Īs is obligatory in any mathematics explanation, let’s explain with a coin toss.Ī coin toss is 50/50 right? In a fair world, the odds would be set at $2.0 and the expected value for any flip would be 0, here is the equation assuming a $10 bet size (the 50% is always represented as a decimal, here as. Simply, Expected Value is the average result you should expect to receive from the given bet or equation Expected Value Calculator For Betting: Expected Value (EV) is the most simple of all betting equations:Įxpected Value is the predicted value of a variable, calculated as the sum of all possible values each multiplied by the probability of its occurrence
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |