221k views
3 votes
Assuming that the probability of flipping heads is p, n coins are tossed each time, k times (k=10^6):

(1) Please use the random. binomial and plt. bar functions to draw the following 3 situations

-A, p = 0.5, n = 20

-B, p = 0.7, n = 20

-C, p = 0.5, n = 40

Please post the pictures of the three results for the output results

(2) Discuss the influence of p, n, and k on the graph changes when they rise and fall.

(3) Use .std() to find the standard deviation, and calculate the ratio of the mean plus or minus one standard deviation.

1 Answer

3 votes

Final answer:

To draw the graphs, use random.binomial and plt.bar functions with different values of p and n. The influence of p, n, and k on the graphs can be observed by comparing the situations. Calculate the standard deviation and find the ratio of mean plus or minus one standard deviation.

Step-by-step explanation:

To draw the graphs for three situations, we will use the random.binomial and plt.bar functions in Python. For situation A, where p = 0.5 and n = 20, we will generate random numbers using the binomial distribution and plot them using a bar graph. We will do the same for situations B (p = 0.7, n = 20) and C (p = 0.5, n = 40).

The influence of p, n, and k on the graph changes can be observed by comparing the three situations. When p increases from 0.5 to 0.7, the probability of getting heads increases, resulting in a shift towards more heads in the graph. When n increases from 20 to 40, the spread of the graph becomes wider, indicating a higher range of possible outcomes. As for k, a larger value will give a smoother and more accurate representation of the probability distribution.

To calculate the standard deviation, we can use the .std() function. After calculating the standard deviation, we can find the ratio of the mean plus or minus one standard deviation by adding or subtracting the standard deviation from the mean and dividing it by the mean.

User Vinicius Cainelli
by
7.9k points