Project 22: Biden Re-elected

Suppose we take a random sample of voters and ask who they will vote for in 2024.  We want to determine if our results give us evidence (and at what level) that Biden will get re-elected.


A few examples:

1) We ask 100 random voters and 98 say they will vote for Biden in 2024.  

Possibility 1: We received such a high number because truly more than 50% of voters will vote for Biden in 2024.

Possibility 2: We received such a high number by chance (based on the randomness of the sample).

To analyze the plausibility of possibility 2, we can calculate the probability that we would get 98 or more voters from a sample of 100 if the true proportion of all voters was actually 50%.  The probability of this happening is virtually 0, so we would have evidence for possibility 1 (that Biden will get re-elected)


2) We ask 50 random voters and 28 say they will vote for Biden in 2024.

Possibility 1: We received such a high number because truly more than 50% of voters will vote for Biden in 2024.

Possibility 2: We received such a high number by chance (based on the randomness of the sample).

To analyze the plausibility of possibility 2, we can calculate the probability that we would get 28 or more voters from a sample of 50 if the true proportion of all voters was actually 50%.  The probability of this happening is about .24 (24%).  Because this is a fairly typical result (would happen about 1 out of every 4 times) we would not have strong evidence for possibility 1 (that Biden will get re-elected)


Explanation: The two probabilities (virtually 0 and .24) are called p-values.  The lower the p-value, the more evidence we would have that Biden will get re-elected.


Project 22: Variables 'n' and 'x' have been initialized.  There is a working method called binomialcdf.

n is the sample size (the number of voters we asked)

x is the number of successes (the number of voters in the sample that say they will vote for Biden in 2024)

binomialcdf(n, p, low, high) returns the probability of getting between 'low' and 'high' number of successes with 'n' trials and a constant probability of success (p)

Task: Appropriately initialize the value of 'pValue' that represents the p-value for the problem as explained above.

**If your code works for 5 test cases in a row, you can enter your e-mail address.