4

I am currently using Excel to calculate the cumulative normal distribution using the following

x = 0
mean = 0.03
standard deviation = 0.055

I then use the formula

=1-NORMDIST(0,0.03,0.055,TRUE)

This yields an output of 0.7, which is what I'm looking for.

How can I achieve the same result on python?

Thanks

1

2 Answers 2

3

If you are able to use scipy you can do this:

from scipy import stats
stats.norm.cdf(0)
0.5  

but it looks like what you want is actually the upper tail probability which in scipy.stats is referred to as a survival function of sf for short.

stats.norm.sf(0, 0.03, 0.055)
0.7072795327155363

should give you what you want. There are many continuous and discrete distributions within the scipy package. The docs are also available online to read:

https://docs.scipy.org/doc/scipy-0.16.1/reference/stats.html

other distribution functions are supported as are other common calculations on distributions, e.g. random sampling, mean, mass/density function, etc.

If you wanted you could directly calculate via:

>>> 1-stats.norm.cdf(0, 0.03, 0.055)
0.7072795327155363

For arguments near the bulk of the probability mass the two values will usually be the same but for very low probability events it is often the case that different numerical algorithms are used in the "tails" of the probability distributions so it can sometimes be beneficial to use the .sf() version.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use scipy.stats.norm:

from scipy.stats import norm
print(norm.sf(x=0, loc=0.03, scale=0.055))
Out[10]: 0.7072795327155363

1 Comment

norm.sf, small error :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.