Normal Distribution
The probability density of normal distribution is:
Here,
is the mean (or expectation) of the distribution. It is also equal to median and mode of the distribution.
is the variance.
is the standard deviation.
If and , then the normal distribution is known as standard normal distribution:
Every normal distribution can be represented as standard normal distribution:
Consider a real-valued random variable, . The cumulative distribution function of (or just the distribution function of ) evaluated at is the probability that will take a value less than or equal to :
Also,
The cumulative distribution function for a function with normal distribution is:
phi = lambda x: 0.5 * (1 + math.erf((x - mean)/(std * (2 ** 0.5))))
Where is the function:
Task In a certain plant, the time taken to assemble a car is a random variable, , having a normal distribution with a mean of hours and a standard deviation of hours. What is the probability that a car can be assembled at this plant in:
Less than hours?
Between and hours?
import math
mean, std = 20, 2
cdf = lambda x: 0.5 * (1 + math.erf((x - mean) / (std * (2 ** 0.5))))
# Less than 19.5
print('{:.3f}'.format(cdf(19.5)))
# Between 20 and 22
print('{:.3f}'.format(cdf(22) - cdf(20)))
Task The final grades for a Physics exam taken by a large group of students have a mean of and a standard deviation of . If we can approximate the distribution of these grades by a normal distribution, what percentage of the students:
Scored higher than (i.e., have a )?
Passed the test (i.e., have a )?
Failed the test (i.e., have a )?
import math
def arg_erf(x, u, o):
return (x-u)/(o * math.sqrt(2))
def F(x, arg_x):
return 0.5 * ( 1 + math.erf(arg_x) )
u, o = input().split() # u = 70, o = 10
u, o = float(u), float(o)
a = float(input()) # a = 80
b = float(input()) # b = 60
arg_a = arg_erf(a, u, o)
arg_b = arg_erf(b, u, o)
first_ans = (1 - F(a, arg_a))
second_ans = (1 - F(b, arg_b))
third_ans = F(b, arg_b)
print(round(first_ans*100.0, 2))
print(round(second_ans*100.0, 2))
print(round(third_ans*100.0, 2))
Last updated