Search code examples
pythonscipystatisticsprobabilitynormal-distribution

extracting probabilities from SciPy's norm object


I am using SciPy's norm object here and I have a normal distribution here with a mean value of 100. and a standard deviation of 20.:

from scipy.stats import norm    
dist = norm(loc=100., scale=20.)

I want to get the probability of a new instance being in locations... let's say... 70, or 120, how can I retrieve this probability using the norm object?

The norm object has a few methods such as norm.pdf, norm.cdf, norm.ppf, etc.. I am not sure which one I can use for this task.

Thank you


Solution

  • First of all you are talking of normal distribution which is a continuous distribution so you cannot get the probability that a new instance is at an exact location (that would be 0 by definition).

    In your example you can get the probability that the observation is for example > 70 or < 70 (the strict inequality makes no difference for continuous distributions hence >= or > are same).

    You need to use dist.cdf(70) for this to get P(X<=70) and 1 - dist.cdf(70) to get P(X>70)