Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compute CDF probability of normal distribution in C++?

Is there any function that allow me to compute the CDF probability of a normal distribution, given a mean and sigma ? i.e. for example P( X < x ) given the normal distribution with $\bar{x}$ and $\sigma$.

I think boost have this, but I think that it is just for the standard normal distribution.

like image 662
shn Avatar asked Jun 06 '12 13:06

shn


People also ask

How do you calculate normal distribution from CDF?

The CDF of the standard normal distribution is denoted by the Φ function: Φ(x)=P(Z≤x)=1√2π∫x−∞exp{−u22}du. As we will see in a moment, the CDF of any normal random variable can be written in terms of the Φ function, so the Φ function is widely used in probability.

What is CDF in normal distribution?

The cumulative distribution function (CDF) of the standard normal distribution, usually denoted with the capital Greek letter (phi), is the integral. The related error function gives the probability of a random variable, with normal distribution of mean 0 and variance 1/2 falling in the range .

What is CDF in probability?

The Cumulative Distribution Function (CDF) of a real-valued random variable X, evaluated at x, is the probability function that X will take a value less than or equal to x. It is used to describe the probability distribution of random variables in a table.


1 Answers

You scale -- any N(m, s) can be turned into N(0,1) by dividing by s and subtracting m. So all you need is a cdf for N(0,1) which is provided by a number of libraries.

Here is a simple R example:

R> pnorm(1.96, 0, 1)          # compute cdf of 1.96 for N(0,1)
[1] 0.975002
R> pnorm(1.96*3 + 2, 2, 3)    # mu + sd*1.96 is really the same for N(mu, sd)
[1] 0.975002
R> 
like image 128
Dirk Eddelbuettel Avatar answered Sep 21 '22 17:09

Dirk Eddelbuettel