Distributions

Please check Intro to Statistical Dist for Engineers with Python for technical information and many examples.

 

Beta Dist

x: Quantile
p: Cumulative probability
shape1, shape2: similar to alpha and beta

 


def dbeta(
	x:Iterable|Real, 
	shape1:float, 
	shape2:float) -> list|Real:


def pbeta(
	q:Iterable|Real, 
	shape1:float, 
	shape2:float)->list|Real:


def qbeta(
	p:Iterable|Real, 
	shape1:float, 
	shape2:float) -> list|Real:


def rbeta(
	n:int, 
	shape1:float, 
	shape2:float) -> list:

 

 



Binomial Dist

Arguments

x: Number of successes
p: Cumulative probability
q: quantile
size: Number of independent trials
prob: Probability of success on each trial

 


def dbinom(
	x:Iterable|Real, 
	size:int, 
	prob:float)->list|Real:
	

def pbinom(
	q:Iterable|Real, 
	size:int, 
	prob:float)->list|Real:


def qbinom(
	p:Iterable|Real, 
	size:int, 
	prob:float)->list|Real:
	

def rbinom(
	n:int, 
	size:int, 
	prob:float)->list:

 

Examples


qbinom(p=0.83692, size=5, prob=0.3) 
#2.0

Although, in the above example the quantile was perfectly overlapping with the cumulative probability, it very rarely is the case. Consider the following:


v = np.array([0.53, 0.80])
qbinom(p=v, size=5, prob=0.3) 
#[2, 2]

Although the cumulative probability in all 3 cases are different (0.53, 0.80, 0.83692) the quantile is always reported as 2. Here, the function applies a policy, where it always rounds up the result (for more info).

 

 

Negative Binomial Dist

Arguments

x: Number of failures before success occurs
p: Cumulative probability
q: Number of failures before success occurs
size: Target for number of successful trials
prob: Probability of success on each trial

 


def dnbinom(
	x:Iterable|Real, 
	size:int, 
	prob:float)->list|Real:


def pnbinom(
	q:Iterable|Real, 
	size:int, 
	prob:float)->list|Real:
	

def qnbinom(
	p:Iterable|Real, 
	size:int, 
	prob:float)->list|Real:
	

def rnbinom(
	n:int, 
	size, 
	prob)->list:

 

 

Chi-Square Dist

x: Quantile
p: Cumulative probability
q: quantile
df Degrees of freedom

 


def dchisq(
	x:Iterable|Real, 
	df:int)->list|Real:


def pchisq(
	q:Iterable|Real, 
	df:int)->list|Real:


def qchisq(
	p:Iterable|Real, 
	df:int)->list|Real:


def rchisq(
	n:int, 
	df)->list:

 

 

Exponential Dist

Arguments

x: Quantile
p: Cumulative probability
q: Quantile
rate: 1/mean, where mean is the waiting time for the next event recurrence

 


def dexp(
	x:Iterable|Real, 
	rate = 1.0)->list|Real:


def pexp(
	q:Iterable|Real, 
	rate = 1.0)->list|Real:


def qexp(
	p:Iterable|Real, 
	rate = 1.0)->list|Real:


def rexp(
	n:int, 
	rate=1.0)->list:

 

 



F Dist

x: quantile, number / ndarray
p: Cumulative probability
q: quantile, number / ndarray
df1, df2: Degrees of freedoms

 


def df(
	x:Iterable|Real, 
	df1:int, 
	df2:int)->list|Real:


def pf(
	q:Iterable|Real, 
	df1:int, 
	df2:int)->list|Real:
	

def qf(
	p:Iterable|Real, 
	df1:int, 
	df2:int)->list|Real:


def rf(
	n:int, 
	df1, 
	df2)->list:

 

 

Gamma Dist

Arguments

x: Quantile
p: Cumulative probability
q: Quantile
shape: waiting time for the rth event to occur
scale: average waiting time for the next event recurrence

 


def dgamma(
	x:Iterable|Real, 
	shape:float, 
	scale = 1.0)->list|Real:


def pgamma(
	q:Iterable|Real, 
	shape:float, 
	scale = 1.0)->list|Real:


def qgamma(
	p:Iterable|Real, 
	shape:float, 
	scale = 1.0)->list|Real:


def rgamma(
	n:int, 
	shape:float, 
	scale=1.0)->list:

 

 

Geometric Dist

Arguments

x: Number of failures before success occurs
p: Cumulative probability
q: Number of failures before success occurs,
prob: probability of success in each trial

 


def dgeom(
	x:Iterable|Real, 
	prob:Real)->list|Real:


def pgeom(
	q:Iterable|Real, 
	prob:Real)->list|Real:


def qgeom(
	p:Iterable|Real, 
	prob:Real)->list|Real:


def rgeom(
	n:int, 
	prob:Real)->list:

 

 

Hypergeometric Dist

Arguments

m: number of good samples in the urn
n: number of bad samples in the urn
k: samples drawn from the urn,
prob: probability of success in each trial

 


def dhyper(
	x:Iterable|Real, 
	m:int, 
	n:int, 
	k:int)->list|Real:


def phyper(
	q:Iterable|Real, 
	m:int, 
	n:int, 
	k:int)->list|Real:


def qhyper(
	p:Iterable|Real, 
	m:int, 
	n:int, 
	k:int)->list|Real:


def rhyper(
	nn:int,
	m:int, 
	n:int, 
	k:int)->list:

 

 

Log-normal Dist

Computes properties of log-normal distribution.

Arguments

x: Quantile
p: Cumulative probability
q: quantile
meanlog: Mean of the distribution
sdlog: standard deviation

 


def dlnorm(
	x:Iterable|Real, 
	meanlog=0.0, 
	sdlog=1.0)->list|Real:


def plnorm(
	q:Iterable|Real, 
	meanlog=0.0, 
	sdlog=1.0)->list|Real:


def qlnorm(
	p:Iterable|Real, 
	meanlog=0.0, 
	sdlog=1.0)->list|Real:


def rlnorm(
	n:int, 
	meanlog=0.0, 
	sdlog=1.0)->list:

 

 

Multinomial Dist

Arguments

x: Number of successes
size: Number of trials
prob: Probability of success on each trial

 


def dmultinom(
	x:Iterable, 
	size:int, 
	prob:Iterable)->float:


def rmultinom(
	n:int, 
	size:int, 
	prob:Iterable)->list:

 

 

Normal Dist

Computes properties of normal distribution.

Arguments

x: Quantile
p: Cumulative probability
q: quantile
mean: Mean of the distribution
sd: standard deviation

 


def dnorm(
	x:Iterable|Real, 
	mean=0.0, 
	sd=1.0)->list|Real:


def pnorm(
	q:Iterable|Real, 
	mean=0.0, 
	sd=1.0)->list|Real:


def qnorm(
	p:Iterable|Real, 
	mean=0.0, 
	sd=1.0)->list|Real:


def rnorm(
	n:int, 
	mean=0.0, 
	sd=1.0)->list:

 

 

Pareto Dist

Computes properties of pareto distribution.

Arguments

x: Quantile
p: Cumulative probability
q: quantile
location: location parameter
shape: shape parameter

 


def dpareto(
	x:Iterable|Real, 
	location:Real,
	shape=1.0)->list|Real:


def ppareto(
	q:Iterable|Real, 
	location:Real, 
	shape=1.0)->list|Real:


def qpareto(
	p:Iterable|Real, 
	location:Real, 
	shape=1.0)->list|Real:


def rpareto(
	n:int, 
	location:Real, 
	shape=1.0)->list:

 

 



Poisson Dist

x: quantile, Iterable
p: Cumulative probability
q: quantile, Iterable
mu: the average number of events per interval (event rate)

 


def dpois(
	x:Iterable|Real, 
	mu:float)->list|Real:


def ppois(
	q:Iterable|Real, 
	mu:float)->list|Real:


def qpois(
	p:Iterable|Real, 
	mu:float)->list|Real:
"""
The function always rounds up the result 
https://www.boost.org/doc/libs/1_40_0/libs/math/doc/sf_and_dist/html/math_toolkit/policy/pol_tutorial/understand_dis_quant.html
"""


def rpois(
	n:int, 
	mu = 1)->list:

 

 



Student t Distribution

Arguments

x: quantile, Iterable
p: Cumulative probability
q: quantile, Iterable
df Degrees of freedom

 


def dt(
	x:Iterable|Real, 
	df:int)->list|Real:


def pt(
	q:Iterable|Real, 
	df:int)->list|Real:


def qt(
	p:Iterable|Real, 
	df:int)->list|Real:


def rt(
	n:int, 
	df)->list:

 

 

Uniform Dist

Arguments

x: Quantile
p: Cumulative probability
q: Quantile
min, max: Lower and upper limits of the distribution

 


def dunif(
	x:Iterable|Real, 
	min=0.0, 
	max=1.0)->list|Real:


def punif(
	q:Iterable|Real, 
	min=0.0, 
	max=1.0)->list|Real:


def qunif(
	p:Iterable|Real, 
	min=0.0, 
	max=1.0)->list|Real:


def runif(
	n:int, 
	min=0.0, 
	max=1.0)->list:

 

 

Weibull Dist

Arguments

x: Quantile
p: Cumulative probability
q: Quantile
shape: known as Weibull-slope
scale: characteristic life

 


def dweibull(
	x:Iterable|Real, 
	shape:float, 
	scale = 1.0)->list|Real:


def pweibull(
	q:Iterable|Real, 
	shape:float, 
	scale = 1.0)->list|Real:


def qweibull(
	p:Iterable|Real, 
	shape:float, 
	scale = 1.0)->list|Real:


def rweibull(
	n:int, 
	shape:float, 
	scale=1.0)->list:

 

 



Wilcoxon Signed Rank Statistic

Arguments

x: quantile, Iterable
p: Cumulative probability
q: quantile, Iterable
n: Sample size

 


def dsignrank(
	x:Iterable|Real, 
	n:int)->list|Real:
"""
If the argument x is greater than the number of coefficients generated by argument n, 
or if x < 0, the function returns 0.0.
"""


def psignrank(
	q:Iterable|Real, 
	n:int)->list|Real:
"""
If argument q is not an integer number, 
then it is rounded to the nearest integer number.
"""
	

def qsignrank(
	p:Iterable|Real, 
	n:int)->list|Real:
"""
The function rounds up the result.
"""