Fergal
Fergal

Reputation: 494

Compute natural log of survival function of a Gaussian in Python/numpy/scipy

I can compute the natural log of the survival function of a Gaussian distribution using

np.log( scipy.stats.norm.sf(s) )

I need to compute the survival function for some ludicrously large values of s (maybe up to 1000), but the above function hits double point machine precision around s = 37. Is there some function I could use to compute the log of the survival function directly?

Note: I don't believe my underlying distribution is Gaussian out to that many sigma, but I need the survival function to compute some properties of weak signals (3-4 sigma), and I want the algorithm to do something reasonable in the presence of very strong signals.

Upvotes: 0

Views: 236

Answers (1)

Warren Weckesser
Warren Weckesser

Reputation: 114911

Use the logsf method of scipy.stats.norm.

For example:

In [67]: from scipy.stats import norm

In [68]: norm.logsf(1000)
Out[68]: -500007.82669481222

Upvotes: 3

Related Questions