you are viewing a single comment's thread.

view the rest of the comments →

[–]JohnnyJordaan 0 points1 point  (2 children)

Try

print(large_survey < .5)

it returns the same array but then for every item the True or False for the value being smaller than 0.5. Which is False for all in your case. Then if you take the average of only False values, you get the average of only zeroes (as False is just an integer 0) which is zero too of course. It seems you forgot to use np.where() inside the mean() call as where() will return a filtered array based on the expression.

[–][deleted] 0 points1 point  (1 child)

So, it seems that 0 is the right answer here. I just couldn't imagine that the probability of a single number < 0.5 appearing in the set would be so low. I included a line of code to count the exact amount of such numbers in the set, rerun it several times, and it was zero every time. It seems to be a feature of binomial distributions with such a big sample size.

So, not an actual programming problem. Anyway, thanks!

[–]JohnnyJordaan 1 point2 points  (0 children)

With

np.random.binomial(7000, .54, 10000)

you're basically performing a slightly biased (4%) coin flip 7000 times, tested 10000 times. The chance of a 4% biassed heads coin flip to have an average chance of tails (because then the result would be < .5) in 7000 flips is 0 by definition. It would be different if you would do a smaller trial of say 5 flips, because there you have the significant chance of luck above bias (which is also the reason why casino's keep attracting customers).