Untitled
unknown
plain_text
3 months ago
837 B
4
Indexable
import numpy as np import matplotlib.pyplot as plt import scipy.stats as stats # Parameters for the normal distribution mu = 65 sigma = 3.06 # Define the range for x values (covering a few standard deviations around the mean) x = np.linspace(mu - 4*sigma, mu + 4*sigma, 400) y = stats.norm.pdf(x, mu, sigma) # Define the bounds for the shaded region x_shade = np.linspace(58.88, 74.18, 200) y_shade = stats.norm.pdf(x_shade, mu, sigma) # Plot the normal distribution plt.figure(figsize=(8, 5)) plt.plot(x, y, label='Normal Distribution\n$\mu=65$, $\sigma=3.06$') plt.fill_between(x_shade, y_shade, color='skyblue', alpha=0.5, label='Area between 58.88 and 74.18') plt.xlabel('Life Span (years)') plt.ylabel('Probability Density') plt.title('Normal Distribution of Life Span') plt.legend() plt.grid(True) plt.show()
Editor is loading...
Leave a Comment