Election Binomial Project (https://www.codecademy.com/paths/data-science/tracks/intro-statistics-numpy/modules/dspath-intro-statistics/projects/election-binomial)

This feels like it’s probably a dumb question and that I’m missing something obvious, but I’m going to ask anyway. When generating the binomial distributions in this project, the solution says to divide the results by N like so:

possible_surveys = np.random.binomial(70, 0.54, 10000) / 70.0

Similarly, when generating the larger distribution (7,000 survey responses), the solution says to divide it by 7,000. I’m wondering why that’s needed? Is it just to display the histogram as percentages rather than number of votes?

Hi @mayormcnaked welcome to the forums!

It’s not a dumb question; there are no dumb questions here. :slight_smile:

You’re using a floating point number b/c you don’t want to divide by an integer. You don’t want integer division you want a float, or a decimal here in this project b/c you’re dealing w/percentages of votes & predicting based on survey responses.

Gotcha. And the reason you divide by the number of votes is so that the histogram displays the percentage rather than the whole numbers, right?


Yes, that is correct.