Question: PYTHON CODE PLEASE!!! This year is an election year, and it looks like it might be a close one, so here are some election statistics
PYTHON CODE PLEASE!!!
This year is an election year, and it looks like it might be a close one, so here are some
election statistics to ponder.
Suppose a million votes are cast for two opposing candidates. Suppose that voters are
slightly less likely to vote for one candidate than for the other. Specifically, assume
that on average of voters will choose the less favored candidate. What are the
chances that there is a tie each candidate gets exactly votes What are the
chances that the lessfavored candidate will actually win?
To answer these questions, assume that the votes for the lessfavored candidate follow
a binomial distribution such that the chance of the candidate getting exactly
votes out of a total of votes is
;
where is the probability that any individual voter will vote for this candi
date. This equation may be difficult to solve numerically, owing to the large numbers
involved. To mitigate this difficulty, you may want to make use of the approximation
to the binomial distribution given in Exercise of Lab which should be very good
for near and
Write a Python script
elect.py which takes commandline input from the user to
specify Have your code print out the following:
probability p that voter chooses candidate: XXX
probability of tie: YYY
probability of win: ZZZ
Note: this probabilistic interpretation of voters does not mean that voters themselves
necessarily act in a random fashion. Instead, probabilities are assigned because the
many influences on individual choices prevent us from knowing much more than how
voters behave on average, as gleaned from surveys and polls. In this sense the situation
is similar to a coinflipping experiment, wherein unpredictable processes influence the
outcome and we only know if the coin is a fairhonest one that on average, we'll
get heads. in the above equation Play around with different input values
for I think it is amazing how finely tuned must be for there to be a close election!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
