Contents

Calculate Probability From Normal Distribution in R

You can use the pnorm function, which is a cumulative distribution function (CDF), from stats package in R to calculate the probability (p value) from the normal distribution given the mean and standard deviation of the distribution.

The CDF represents the probability that a random variable from the given distribution will be less than or equal to a specific value.

The following examples explain how to calculate the probability given mean and standard deviation using the pnorm function in R.

Example 1 (probability less than or equal to)

Suppose you have normally distributed data with a mean of 20 and a standard deviation of 5.

You want to calculate the probability that a random value is less than or equal to 30.

Here, you can use the pnorm function to calculate this probability.

pnorm(30, mean = 20, sd = 5)

# output
0.9772499

The probability that the random value from a normal distribution is less than or equal to 30 is 0.9772.

Example 2 (probability greater than or equal to)

Suppose you have normally distributed data with a mean of 50 and a standard deviation of 5.

You want to calculate the probability that a random value is greater than or equal to 70.

Here, you can use the pnorm function to calculate this probability.

1 - pnorm(70, mean = 50, sd = 5)

# output
3.167124e-05

The probability that the random value from a normal distribution is greater than or equal to 70 is 3.167124e-05.

Example 3 (probability within range)

Suppose you have normally distributed data with a mean of 100 and a standard deviation of 50.

You want to calculate the probability that a random value that is between 100 and 200.

Here, you can use the pnorm function to calculate this probability.

pnorm(200, mean = 100, sd = 50) - pnorm(100, mean = 100, sd = 50)

# output
0.4772499

The probability that the random value from a normal distribution will fall between 100 and 200 is 0.4772. There is 47.72% chance that the the random value from a normal distribution will fall between 100 and 200.

Please visit this article, if you want to learn how to calculate the probability from the normal distribution in Python.