Complete the code to import the normal distribution function from scipy.stats.
from scipy.stats import [1] # Now you can use norm to work with normal distribution
The normal distribution function in scipy.stats is called norm. Importing it allows you to use its methods.
Complete the code to calculate the probability density function (PDF) of a normal distribution at x=0.
from scipy.stats import norm pdf_value = norm.pdf([1]) print(pdf_value)
The PDF of the standard normal distribution is highest at x=0, so we calculate it at 0.
Fix the error in the code to generate 5 random samples from a normal distribution with mean 10 and standard deviation 2.
from scipy.stats import norm samples = norm.rvs(loc=[1], scale=2, size=5) print(samples)
The loc parameter sets the mean of the normal distribution. Here, it should be 10.
Fill both blanks to create a dictionary comprehension that maps numbers 1 to 5 to their normal PDF values with mean 0 and std 1, but only include values where PDF is greater than 0.2.
pdf_dict = {x: norm.pdf(x, loc=[1], scale=[2]) for x in range(1, 6) if norm.pdf(x, loc=0, scale=1) > 0.2}The mean (loc) is 0 and standard deviation (scale) is 1 for the standard normal distribution.
Fill all three blanks to create a dictionary comprehension that maps numbers 1 to 5 to their cumulative distribution function (CDF) values for a normal distribution with mean 5 and std 2, but only include values where CDF is less than 0.8.
cdf_dict = {x: norm.[1](x, loc=[2], scale=[3]) for x in range(1, 6) if norm.cdf(x, loc=5, scale=2) < 0.8}The method to get cumulative probabilities is cdf. The mean is 5 and standard deviation is 2.