Say we have normal distribution n(x): mean=0 and \int_{-a}^{a} n(x) = P.
What is the easiest way to compute standard deviation of such distribution? May be there are standard libraries for python or C, that are suitable for that task?
Say we have normal distribution n(x): mean=0 and \int_{-a}^{a} n(x) = P.
What is the easiest way to compute standard deviation of such distribution? May be there are standard libraries for python or C, that are suitable for that task?
Take a look at the sciPy Project, it should have what you need.
If X is normal with mean 0 and standard deviation sigma, it must hold
P = Prob[ -a <= X <= a ] = Prob[ -a/sigma <= N <= a/sigma ]
= 2 Prob[ 0 <= N <= a/sigma ]
= 2 ( Prob[ N <= a/sigma ] - 1/2 )
where N is normal with mean 0 and standard deviation 1. Hence
P/2 + 1/2 = Prob[ N <= a/sigma ] = Phi(a/sigma)
Where Phi is the cumulative distribution function (cdf) of a normal variable with mean 0 and stddev 1. Now we need the inverse normal cdf (or the "percent point function"), which in Python is scipy.stats.norm.ppf(). Sample code:
from scipy.stats import norm
P = 0.3456
a = 3.0
a_sigma = float(norm.ppf(P/2 + 0.5)) # a/sigma
sigma = a/a_sigma # Here is the standard deviation
For example, we know that the probability of a N(0,1) variable falling int the interval [-1.1] is ~ 0.682 (the dark blue area in this figure). If you set P = 0.682 and a = 1.0 you obtain sigma ~ 1.0, which is indeed the standard deviation.