Area under the normal curve


In [13]:
# stats.py

from math import erf, sqrt

# define constants

mu = 979.8    # mean = 978.8 kΩ
sigma = 73.1  # standard deviation = 73.1 kΩ
x1 = 900      # lower bound = 900 kΩ
x2 = 1100     # upper bound = 1100 kΩ

# calculate probability

# Probability from 0 to lower bound
double_prob = erf( (x1-mu) / (sigma*sqrt(2)) )
p_lower = double_prob/2
print(f'\n Lower Bound: {round(p_lower,4)}')

# Probability from 0 to upper bound
double_prob = erf( (x2-mu) / (sigma*sqrt(2)) )
p_upper = double_prob/2
print(f'\n Upper Bound: {round(p_upper,4)}')


Pin= (p_upper) - (p_lower)
print('\n')
print(f'mean = {mu}    std dev = {sigma} \n')
print(f'Calculating probability of occuring between {x1} <--> {x2} \n')
print(f'inside interval Pin = {round(Pin*100,1)}%')
print(f'outside interval Pout = {round((1-Pin)*100,1)}% \n')
print('\n')


 Lower Bound: -0.3625

 Upper Bound: 0.4499


mean = 979.8    std dev = 73.1 

Calculating probability of occuring between 900 <--> 1100 

inside interval Pin = 81.2%
outside interval Pout = 18.8% 




In [1]:
from math import erf, sqrt

mu = 979.8    # mean = 978.8 kΩ
sigma = 73.1  # standard deviation = 73.1 kΩ
x1 = 900      # lower bound = 900 kΩ
x2 = 1100     # upper bound = 1100 kΩ

# calculate probability

# Probability from 0 to lower bound
double_prob = erf( (x1-mu) / (sigma*sqrt(2)) )
p_lower = double_prob/2
print(f'\n Lower Bound: {round(p_lower,4)}')

# Probability from 0 to upper bound
double_prob = erf( (x2-mu) / (sigma*sqrt(2)) )
p_upper = double_prob/2
print(f'\n Upper Bound: {round(p_upper,4)}')

# print the results

Pin= (p_upper) - (p_lower)
print('\n')
print(f'mean = {mu}    std dev = {sigma} \n')
print(f'Calculating the probability of occurring between {x1} <--> {x2} \n')
print(f'inside interval Pin = {round(Pin*100,1)}%')
print(f'outside interval Pout = {round((1-Pin)*100,1)}% \n')
print('\n')


 Lower Bound: -0.3625

 Upper Bound: 0.4499


mean = 979.8    std dev = 73.1 

Calculating the probability of occurring between 900 <--> 1100 

inside interval Pin = 81.2%
outside interval Pout = 18.8% 




In [ ]: