In: Computer Science
Use the scipy.stats.norm.cdf function to compute the probability that a draw from N(−3, 4) is between 5 and 7. submit your jupyter notebook for this problem.
Using python.
We have normal distribution(also gaussian distribution) N(,2) where is mean and is standard deviation and 2 is variance , which is a continuous probability distribution for arandom variable X(which is real valued).
For calculating probability of a normal distribution we have norm.cdf in scipy.stats.
So we have to calculate P(5<X<7), so to calculate this probability of an interval we will subtract one cdf from another.
Here we have N(,2) as N(-3, 22) so =-3 and =2.
This norm.cdf(x,loc,scale) has location which is mean, scale which is our standard deviation and x is the limit to our random variable i.e,x is in P(X<x).
So for 5<X<7, we have p= ( norm.cdf(x=7, loc=-3, scale=2) - norm.cdf(x=5, loc=-3, scale=2) )
#import module
from scipy.stats import norm
#calculate the probability of normal distrubution for
x<7
cdf1=norm.cdf(x=7, loc=-3, scale=2)
#calculate the probability of normal distrubution for x<5
cdf2=norm.cdf(x=5, loc=-3, scale=2)
#for P(5<x<7)
p=cdf1-cdf2
#print p
print(p)
3.138459026119644e-05
CODE and OUTPUT
So if you still have any doubt regarding this solution please feel free to ask it in the comment section below and if it is helpful then please upvote this solution, THANK YOU.