Introduction¶
PyStats is a Python 3 library of statistical analysis and distribution functions with simple R-like syntax, scalar/list input/output with OpenMP parallelization.
Author: Marc Izquierdo
License: MIT License
Installation¶
You can use pip to install this library:
pip install pystats
Alternatively, you can also clone this repository and install the plugin manually using pip:
$ git clone git@github.com:marcizhu/PyStats.git
$ pip3 install ./PyStats
After that, you can just import pystats
(or do from pystats import *
if you don’t want to type pystats.
before all
functions) and you’re ready to go.
Contents¶
Syntax¶
Functions are called using an R-like syntax. Some general rules:
Density functions:
pystats.d*
. For example, the Normal (Gaussian) density is called using
pystats.dnorm(<value>, <mean parameter>, <standard deviation>)
Cumulative distribution functions:
pystats.p*
. For example, the Gamma CDF is called using
pystats.pgamma(<value>, <shape parameter>, <scale parameter>)
Quantile functions:
pystats.q*
. For example, the Beta quantile is called using
pystats.qbeta(<value>, <a parameter>, <b parameter>)
random sampling:
pystats.r*
. For example, to generate a single draw from the Logistic distribution:
pystats.rlogis(<location parameter>, <scale parameter>)
The library also supports lists as input/output:
The pdf, cdf, and quantile functions can take list arguments. For example,
norm_pdf_vals = pystats.dnorm([x / 10 for x in range(-10, 10, 1)], 1.0, 2.0)
The randomization functions (
r*
) can output random lists of arbitrary size. For example, the following code will generate a 100-item list of iid draws from a Gamma(3,2) distribution:
gamma_rvs = pystats.rgamma(100, 3.0, 2.0)
Additionally, most parameters have defaults to most common values and named parameters are also supported. For example, to generate a single draw from a Normal(0, 2) the following can be used:
norm_draw = pystats.rnorm(sd=2.0)
Examples¶
# Evaluate the normal PDF at x = 1, mu = 0, sigma = 1
dval_1 = pystats.dnorm(1.0, 0.0, 1.0)
# Evaluate the normal PDF at x = 1, mu = 0, sigma = 1, and return the log value
dval_2 = pystats.dnorm(1.0, 0.0, 1.0, True)
# Same as above, but using default values and named parameters
dval_3 = pystats.dnorm(1.0, log=True)
# Evaluate the normal CDF at x = 1, mu = 0, sigma = 1
pval = pystats.pnorm(1.0, 0.0, 1.0)
# Evaluate the Laplacian quantile at q = 0.1, mu = 0, sigma = 1
qval = pystats.qlaplace(0.1, 0.0, 1.0)
# Draw from a t-distribution with dof = 30
rval = pystats.rt(dof=30)
# List output
beta_rvs = pystats.rbeta(100, 3.0, 2.0)
# List input
beta_cdf_vals = pystats.pbeta(beta_rvs, 3.0, 2.0)
Distributions¶
Bernoulli Distribution¶
Table of contents
Density Function¶
The density function of the Bernoulli distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dbern(x: int, prob: float, log: bool = False) float
Density function of the Bernoulli distribution.
Example
>>> pystats.dbern(1, 0.6) 0.6
- Parameters
x (int) – An integral-valued input, equal to 0 or 1.
prob (float) – The probability parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dbern(x: List[int], prob: float, log: bool = False) float
Density function of the Bernoulli distribution.
Example
>>> pystats.dbern([0, 1], 0.6) [0.4, 0.6]
- Parameters
x (List[int]) – A standard list input.
prob (float) – The probability parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Bernoulli distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pbern(p: int, prob: float, log: bool = False) float
Distribution function of the Bernoulli distribution.
Example
>>> pystats.pbern(1, 0.6) 1.0
- Parameters
p (int) – A value equal to 0 or 1.
prob (float) – The probability parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pbern(p: List[int], prob: float, log: bool = False) float
Distribution function of the Bernoulli distribution.
Example
>>> pystats.pbern([0, 1], 0.6) [0.4, 1.0]
- Parameters
p (List[int]) – A standard list input.
prob (float) – The probability parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Bernoulli distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qbern(q: float, prob: float) float
Quantile function of the Bernoulli distribution.
Example
>>> pystats.qbern(0.5, 0.4) 0.0
- Parameters
q (float) – A real-valued input.
prob (float) – The probability parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qbern(q: List[float], prob: float) float
Quantile function of the Bernoulli distribution.
Example
>>> pystats.pbern([0.3, 0.7], 0.6) [0.0, 1.0]
- Parameters
q (List[float]) – A standard list input.
prob (float) – The probability parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Bernoulli distribution is achieved via the inverse probability integral transform.
Scalar Output¶
- pystats.rbern(prob: float) float
Random sampling function for the Bernoulli distribution.
Example
>>> pystats.rbern(0.4) 0.0
- Parameters
prob (float) – The probability parameter, a real-valued input.
- Returns
A pseudo-random draw from the Bernoulli distribution.
List Output¶
- pystats.rbern(n: int, prob: float) float
Random sampling function for the Bernoulli distribution.
Example
>>> pystats.rbern(10, 0.4) [1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0]
- Parameters
n (int) – The number of output values.
prob (float) – The probability parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Bernoulli distribution.
Density function of the Bernoulli distribution |
|
Distribution function of the Bernoulli distribution |
|
Quantile function of the Bernoulli distribution |
|
Sampling function of the Bernoulli distribution |
Beta Distribution¶
Table of contents
Density Function¶
The density function of the Beta distribution:
where \(\mathcal{B}(a,b)\) denotes the Beta function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dbeta(x: float, shape1: float, shape2: float, log: bool = False) float
Density function of the Beta distribution.
Example
>>> pystats.dbeta(0.5, 3.0, 2.0) 1.5
- Parameters
x (float) – A real-valued input.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dbeta(x: List[float], shape1: float, shape2: float, log: bool = False) List[float]
Density function of the Beta distribution.
Example
>>> pystats.dbeta([0.3, 0.5, 0.9], 3.0, 2.0) [0.756, 1.5, 0.972]
- Parameters
x (List[float]) – A standard list input.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Beta distribution:
where \(I_x (a,b)\) denotes the regularized incomplete Beta function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pbeta(p: float, shape1: float, shape2: float, log: bool = False) float
Distribution function of the Beta distribution.
Example
>>> pystats.pbeta(0.5, 3.0, 2.0) 0.3125
- Parameters
p (float) – A real-valued input.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pbeta(p: List[float], shape1: float, shape2: float, log: bool = False) List[float]
Distribution function of the Beta distribution.
Example
>>> pystats.pbeta([0.3, 0.5, 0.9], 3.0, 2.0) [0.0837, 0.3125, 0.9477]
- Parameters
p (List[float]) – A standard list input.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Beta distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qbeta(q: float, shape1: float, shape2: float) float
Quantile function of the Beta distribution.
Example
>>> pystats.qbeta(0.5, 3.0, 2.0) 0.61427243186
- Parameters
q (float) – A real-valued input.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qbeta(q: List[float], shape1: float, shape2: float) List[float]
Quantile function of the Beta distribution.
Example
>>> pystats.qbeta([0.3, 0.5, 0.9], 3.0, 2.0) [0.4915952451274149, 0.6142724318676113, 0.8574406832899696]
- Parameters
q (List[float]) – A standard list input.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Beta distribution is achieved by simulating two independent gamma-distributed random variables, \(X \sim G(a,1), Y \sim G(a,1)\), then returning:
Scalar Output¶
- pystats.rbeta(shape1: float, shape2: float) float
Random sampling function for the Beta distribution.
Example
>>> pystats.rbeta(3.0, 2.0) 0.3102933967927699
- Parameters
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
- Returns
A pseudo-random draw from the Beta distribution.
List Output¶
- pystats.rbeta(n: int, shape1: float, shape2: float) List[float]
Random sampling function for the Beta distribution.
Example
>>> pystats.rbeta(5, 3.0, 2.0) [0.2098009340766354, 0.483502928842804, 0.5101449459492882, 0.46683636135288137, 0.791214142230094]
- Parameters
n (int) – The number of output values.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
- Returns
A list of pseudo-random draws from the Beta distribution.
Density function of the Beta distribution |
|
Distribution function of the Beta distribution |
|
Quantile function of the Beta distribution |
|
Sampling function of the Beta distribution |
Binomial Distribution¶
Table of contents
Density Function¶
The density function of the Binomial distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dbinom(x: float, n_trials: int, prob: float, log: bool = False) float
Density function of the Binomial distribution.
Example
>>> pystats.dbinom(2, 4, 0.4) 0.3456
- Parameters
x (int) – An integral-valued input, equal to 0 or 1.
n_trials (int) – The number of trials, a non-negative integral-valued input.
prob (float) – The probability parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dbinom(x: List[float], n_trials: int, prob: float, log: bool = False) List[float]
Density function of the Binomial distribution.
Example
>>> pystats.dbinom([2, 3, 4], 5, 0.4) [0.3456, 0.2304, 0.0768]
- Parameters
x (List[int]) – A standard list input.
n_trials (int) – The number of trials, a non-negative integral-valued input.
prob (float) – The probability parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Binomial distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pbinom(p: float, n_trials: int, prob: float, log: bool = False) float
Distribution function of the Binomial distribution.
Example
>>> pystats.pbinom(2, 4, 0.4) 0.8208
- Parameters
p (float) – A value equal to 0 or 1.
n_trials (int) – The number of trials, a non-negative integral-valued input.
prob (float) – The probability parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pbinom(p: List[float], n_trials: int, prob: float, log: bool = False) List[float]
Distribution function of the Binomial distribution.
Example
>>> pystats.pbinom([2, 3, 4], 5, 0.4) [0.68256, 0.91296, 0.98976]
- Parameters
p (List[float]) – A standard list input.
n_trials (int) – The number of trials, a non-negative integral-valued input.
prob (float) – The probability parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Binomial distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qbinom(q: float, n_trials: int, prob: float) float
Quantile function of the Binomial distribution.
Example
>>> pystats.qbinom(0.5, 4, 0.4) 2
- Parameters
q (float) – A real-valued input.
n_trials (int) – The number of trials, a non-negative integral-valued input.
prob (float) – The probability parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qbinom(q: List[float], n_trials: int, prob: float) List[float]
Quantile function of the Binomial distribution.
Example
>>> pystats.qbinom([0.2, 0.4, 0.8], 5, 0.4) [1, 2, 3]
- Parameters
q (List[float]) – A standard list input.
n_trials (int) – The number of trials, a non-negative integral-valued input.
prob (float) – The probability parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Binomial distribution is achieved by summing the results of simulating n Bernoulli-distributed random variables.
Scalar Output¶
- pystats.rbinom(n_trials: int, prob: float) float
Random sampling function for the Binomial distribution.
Example
>>> pystats.rbinom(4, 0.4) 2
- Parameters
n_trials (int) – The number of trials, a non-negative integral-valued input.
prob (float) – The probability parameter, a real-valued input.
- Returns
A pseudo-random draw from the Binomial distribution.
List Output¶
- pystats.rbinom(n: int, n_trials: int, prob: float) List[float]
Random sampling function for the Binomial distribution.
Example
>>> pystats.rbinom(10, 4, 0.4) [1, 4, 0, 2, 3, 2, 2, 2, 2, 1]
- Parameters
n (int) – The number of output values.
n_trials (int) – The number of trials, a non-negative integral-valued input.
prob (float) – The probability parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Binomial distribution.
Density function of the Binomial distribution |
|
Distribution function of the Binomial distribution |
|
Quantile function of the Binomial distribution |
|
Sampling function of the Binomial distribution |
Cauchy Distribution¶
Table of contents
Density Function¶
The density function of the Cauchy distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dcauchy(x: float, mu: float = 0.0, sigma: float = 1.0, log: bool = False) float
Density function of the Cauchy distribution.
Example
>>> pystats.dcauchy(2.5, 1.0, 3.0) 0.084883
- Parameters
x (float) – A real-valued input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dcauchy(x: List[float], mu: float = 0.0, sigma: float = 1.0, log: bool = False) List[float]
Density function of the Cauchy distribution.
Example
>>> pystats.dcauchy([0.0, 1.0, 2.0], 1.0, 2.0) [0.12732395447351627, 0.15915494309189535, 0.12732395447351627]
- Parameters
x (List[float]) – A standard list input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Cauchy distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pcauchy(p: float, mu: float = 0.0, sigma: float = 1.0, log: bool = False) float
Distribution function of the Cauchy distribution.
Example
>>> pystats.pcauchy(2.5, 1.0, 3.0) 0.647584
- Parameters
p (float) – A real-valued input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pcauchy(p: List[float], mu: float = 0.0, sigma: float = 1.0, log: bool = False) List[float]
Distribution function of the Cauchy distribution.
Example
>>> pystats.pcauchy([0.0, 1.0, 2.0], 1.0, 2.0) [0.35241638234956674, 0.5, 0.6475836176504333]
- Parameters
p (List[float]) – A standard list input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Cauchy distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qcauchy(q: float, mu: float = 0.0, sigma: float = 1.0) float
Quantile function of the Cauchy distribution.
Example
>>> pystats.qcauchy(0.5, 1, 3.0) 0.647584
- Parameters
q (float) – A real-valued input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qcauchy(q: List[float], mu: float = 0.0, sigma: float = 1.0) List[float]
Quantile function of the Cauchy distribution.
Example
>>> pystats.qcauchy([0.1, 0.3, 0.7], 1.0, 2.0) [-5.155367074350508, -0.45308505601072185, 2.453085056010721]
- Parameters
q (List[float]) – A standard list input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Cauchy distribution is achieved via the inverse probability integral transform.
Scalar Output¶
- pystats.rcauchy(mu: float = 0.0, sigma: float = 1.0) float
Random sampling function for the Cauchy distribution.
Example
>>> pystats.rcauchy(1.0, 2.0) 9.93054237677352
- Parameters
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
A pseudo-random draw from the Cauchy distribution.
List Output¶
- pystats.rcauchy(n: int, mu: float = 0.0, sigma: float = 1.0) List[float]
Random sampling function for the Cauchy distribution.
Example
>>> pystats.rcauchy(1.0, 2.0) [-2.383182638662492, 1.0766564460128407, -20.367599105297693, -0.9512379893292959, -0.17185207327053853]
- Parameters
n (int) – The number of output values.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Cauchy distribution.
Density function of the Cauchy distribution |
|
Distribution function of the Cauchy distribution |
|
Quantile function of the Cauchy distribution |
|
Sampling function of the Cauchy distribution |
Chi-squared Distribution¶
Table of contents
Density Function¶
The density function of the Chi-squared distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dchisq(x: float, dof: float = 1.0, log: bool = False) float
Density function of the Chi-squared distribution.
Example
>>> pystats.dchisq(4.0, 5) 0.1439759107018347
- Parameters
x (float) – A real-valued input.
dof (float) – The degrees of freedom parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dchisq(x: List[float], dof: float = 1.0, log: bool = False) List[float]
Density function of the Chi-squared distribution.
Example
>>> pystats.dchisq([1.8, 0.7, 4.2], 4) [0.18295634688326964, 0.12332041570077489, 0.12857924966563097]
- Parameters
x (List[float]) – A standard list input.
dof (float) – The degrees of freedom parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Chi-squared distribution:
where \(\Gamma(\cdot)\) denotes the gamma function and \(\gamma(\cdot, \cdot)\) denotes the incomplete gamma function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pchisq(p: float, dof: float = 1.0, log: bool = False) float
Distribution function of the Chi-squared distribution.
Example
>>> pystats.pchisq(4.0, 5) 0.45058404864721946
- Parameters
p (float) – A real-valued input.
dof (float) – The degrees of freedom parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pchisq(p: List[float], dof: float = 1.0, log: bool = False) List[float]
Distribution function of the Chi-squared distribution.
Example
>>> pystats.pchisq([1.8, 0.7, 4.2], 4) [0.22751764649286174, 0.048671078879736845, 0.620385072415756]
- Parameters
p (List[float]) – A standard list input.
dof (float) – The degrees of freedom parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Chi-squared distribution:
where \(\Gamma(\cdot)\) denotes the gamma function and \(\gamma(\cdot, \cdot)\) denotes the incomplete gamma function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qchisq(q: float, dof: float = 1.0) float
Quantile function of the Chi-squared distribution.
Example
>>> pystats.qchisq(0.5, 5) 4.351460191095529
- Parameters
q (float) – A real-valued input.
dof (float) – The degrees of freedom parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qchisq(q: List[float], dof: float = 1.0) List[float]
Quantile function of the Chi-squared distribution.
Example
>>> pystats.qchisq([1.8, 0.7, 4.2], 4) [2.194698421406983, 3.356693980033322, 5.988616694004245]
- Parameters
q (List[float]) – A standard list input.
dof (float) – The degrees of freedom parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Scalar Output¶
- pystats.rchisq(dof: float = 1.0) float
Random sampling function for the Chi-squared distribution.
Example
>>> pystats.rchisq(dof=5) 7.088454619471778
- Parameters
dof (float) – The degrees of freedom parameter, a real-valued input.
- Returns
A pseudo-random draw from the Chi-squared distribution.
List Output¶
- pystats.rchisq(n: int, dof: float = 1.0) List[float]
Random sampling function for the Chi-squared distribution.
Example
>>> pystats.rchisq(5, 5) [2.3284093401299866, 9.215161276152928, 6.904990781549569, 8.257146493760509, 4.299710184814277]
- Parameters
n (int) – The number of output values.
dof (float) – The degrees of freedom parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Chi-squared distribution.
Density function of the Chi-squared distribution |
|
Distribution function of the Chi-squared distribution |
|
Quantile function of the Chi-squared distribution |
|
Sampling function of the Chi-squared distribution |
Exponential Distribution¶
Table of contents
Density Function¶
The density function of the Exponential distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dexp(x: float, rate: float = 1.0, log: bool = False) float
Density function of the Exponential distribution.
Example
>>> pystats.dexp(1.0, 2.0) 0.2706705664732254
- Parameters
x (float) – A real-valued input.
rate (float) – The rate parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dexp(x: List[float], rate: float = 1.0, log: bool = False) List[float]
Density function of the Exponential distribution.
Example
>>> pystats.dexp([1.8, 0.7, 4.2], 4.0) [0.0029863432335067172, 0.24324025050087195, 2.022612539334209e-07]
- Parameters
x (List[float]) – A standard list input.
rate (float) – The rate parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Exponential distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pexp(p: float, rate: float = 1.0, log: bool = False) float
Distribution function of the Exponential distribution.
Example
>>> pystats.pexp(1.0, 2.0) 0.8646647167633873
- Parameters
p (float) – A real-valued input.
rate (float) – The rate parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pexp(p: List[float], rate: float = 1.0, log: bool = False) List[float]
Distribution function of the Exponential distribution.
Example
>>> pystats.pexp([1.8, 0.7, 4.2], 4.0) [0.9992534141916233, 0.9391899373747821, 0.9999999494346865]
- Parameters
p (List[float]) – A standard list input.
rate (float) – The rate parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Exponential distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qexp(q: float, rate: float = 1.0) float
Quantile function of the Exponential distribution.
Example
>>> pystats.qexp(0.5, 2.0) 0.3465735902799726
- Parameters
q (float) – A real-valued input.
rate (float) – The rate parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qexp(q: List[float], rate: float = 1.0) List[float]
Quantile function of the Exponential distribution.
Example
>>> pystats.qexp([0.3, 0.5, 0.8], 4.0) [0.08916873598468311, 0.1732867951399863, 0.40235947810852524]
- Parameters
q (List[float]) – A standard list input.
rate (float) – The rate parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Cauchy distribution is achieved via the inverse probability integral transform.
Scalar Output¶
- pystats.rexp(rate: float = 1.0) float
Random sampling function for the Exponential distribution.
Example
>>> pystats.rexp(2.0) 0.8337215251612762
- Parameters
rate (float) – The rate parameter, a real-valued input.
- Returns
A pseudo-random draw from the Exponential distribution.
List Output¶
- pystats.rexp(n: int, rate: float = 1.0) List[float]
Random sampling function for the Exponential distribution.
Example
>>> pystats.rexp(3, 2.0) [0.006095192297017023, 0.552560396122137, 0.8185248559121117]
- Parameters
n (int) – The number of output values.
rate (float) – The rate parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Exponential distribution.
Density function of the Exponential distribution |
|
Distribution function of the Exponential distribution |
|
Quantile function of the Exponential distribution |
|
Sampling function of the Exponential distribution |
F-Distribution¶
Table of contents
Density Function¶
The density function of the F distribution:
where \(\mathcal{B}(a,b)\) denotes the Beta function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.df(x: float, df1: float = 1.0, df2: float = 1.0, log: bool = False) float
Density function of the F-distribution distribution.
Example
>>> pystats.df(1.5, 10.0, 12.0) 0.3426270538333347
- Parameters
x (float) – A real-valued input.
df1 (float) – A degrees of freedom parameter, a real-valued input.
df2 (float) – A degrees of freedom parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.df(x: List[float], df1: float = 1.0, df2: float = 1.0, log: bool = False) List[float]
Density function of the F-distribution distribution.
Example
>>> pystats.df([0.3, 0.5, 0.9], 10.0, 12.0) [0.3523215359999982, 0.6861197229627093, 0.7047187344898975]
- Parameters
x (List[float]) – A standard list input.
df1 (float) – A degrees of freedom parameter, a real-valued input.
df2 (float) – A degrees of freedom parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the F distribution:
where \(I_x (a,b)\) denotes the regularized incomplete Beta function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pf(p: float, df1: float = 1.0, df2: float = 1.0, log: bool = False) float
Distribution function of the F-distribution distribution.
Example
>>> pystats.pf(1.5, 10.0, 12.0) 0.7501297253279772
- Parameters
p (float) – A real-valued input.
df1 (float) – A degrees of freedom parameter, a real-valued input.
df2 (float) – A degrees of freedom parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pf(p: List[float], df1: float = 1.0, df2: float = 1.0, log: bool = False) List[float]
Distribution function of the F-distribution distribution.
Example
>>> pystats.pf([0.3, 0.5, 0.9], 10.0, 12.0) [0.03279349759999985, 0.14036282082102308, 0.43990811032084115]
- Parameters
p (List[float]) – A standard list input.
df1 (float) – A degrees of freedom parameter, a real-valued input.
df2 (float) – A degrees of freedom parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the F distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qf(q: float, df1: float = 1.0, df2: float = 1.0) float
Quantile function of the F-distribution distribution.
Example
>>> pystats.qf(0.5, 10.0, 12.0) 0.9885595669294069
- Parameters
q (float) – A real-valued input.
df1 (float) – A degrees of freedom parameter, a real-valued input.
df2 (float) – A degrees of freedom parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qf(q: List[float], df1: float = 1.0, df2: float = 1.0) List[float]
Quantile function of the F-distribution distribution.
Example
>>> pystats.qf([0.3, 0.5, 0.9], 10.0, 12.0) [0.7125992144145168, 0.9885595669294069, 2.1877640788750874]
- Parameters
q (List[float]) – A standard list input.
df1 (float) – A degrees of freedom parameter, a real-valued input.
df2 (float) – A degrees of freedom parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Beta distribution is achieved by simulating two independent \(\chi^2\)-distributed random variables, \(X \sim \chi^2(d_1), Y \sim \chi^2(d_2)\), then returning:
Scalar Output¶
- pystats.rf(df1: float = 1.0, df2: float = 1.0) float
Random sampling function for the F-distribution distribution.
Example
>>> pystats.rf(10.0, 12.0) 2.646874442851056
- Parameters
df1 (float) – A degrees of freedom parameter, a real-valued input.
df2 (float) – A degrees of freedom parameter, a real-valued input.
- Returns
A pseudo-random draw from the F-distribution distribution.
List Output¶
- pystats.rf(n: int, df1: float = 1.0, df2: float = 1.0) List[float]
Random sampling function for the F-distribution distribution.
Example
>>> pystats.rf(3, 10.0, 12.0) [0.4932413364221738, 0.2827026830899671, 2.750316525821291]
- Parameters
n (int) – The number of output values.
df1 (float) – A degrees of freedom parameter, a real-valued input.
df2 (float) – A degrees of freedom parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the F-distribution distribution.
Density function of the F-distribution |
|
Distribution function of the F-distribution |
|
Quantile function of the F-distribution |
|
Sampling function of the F-distribution |
Gamma Distribution¶
Table of contents
Density Function¶
The density function of the Gamma distribution:
where \(\Gamma(\cdot)\) denotes the Gamma function, \(k\) is the shape parameter, and \(\theta\) is the scale parameter.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dgamma(x: float, shape: float = 1.0, scale: float = 1.0, log: bool = False) float
Density function of the Gamma distribution.
Example
>>> pystats.dgamma(2, 2, 3) 0.1140926931183538
- Parameters
x (float) – A real-valued input.
shape (float) – The shape parameter, a real-valued input.
scale (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dgamma(x: List[float], shape: float = 1.0, scale: float = 1.0, log: bool = False) List[float]
Density function of the Gamma distribution.
Example
>>> pystats.dgamma([1.8, 0.7, 4.2], 2, 3) [0.1097623272188053, 0.061591410715083, 0.11507858317274963]
- Parameters
x (List[float]) – A standard list input.
shape (float) – The shape parameter, a real-valued input.
scale (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Gamma distribution:
where \(\Gamma(\cdot)\) denotes the gamma function and \(\gamma(\cdot, \cdot)\) denotes the incomplete gamma function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pgamma(p: float, shape: float = 1.0, scale: float = 1.0, log: bool = False) float
Distribution function of the Gamma distribution.
Example
>>> pystats.pgamma(2, 2, 3) 0.14430480161234657
- Parameters
p (float) – A real-valued input.
shape (float) – The shape parameter, a real-valued input.
scale (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pgamma(p: List[float], shape: float = 1.0, scale: float = 1.0, log: bool = False) List[float]
Distribution function of the Gamma distribution.
Example
>>> pystats.pgamma([1.8, 0.7, 4.2], 2, 3) [0.12190138224955768, 0.023336201517969262, 0.4081672865401445]
- Parameters
p (List[float]) – A standard list input.
shape (float) – The shape parameter, a real-valued input.
scale (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Gamma distribution:
where \(\Gamma(\cdot)\) denotes the gamma function and \(\gamma(\cdot, \cdot)\) denotes the incomplete gamma function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qgamma(q: float, shape: float = 1.0, scale: float = 1.0) float
Quantile function of the Gamma distribution.
Example
>>> pystats.qgamma(0.15, 2, 3) 2.0497158392128205
- Parameters
q (float) – A real-valued input.
shape (float) – The shape parameter, a real-valued input.
scale (float) – The scale parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qgamma(q: List[float], shape: float = 1.0, scale: float = 1.0) List[float]
Quantile function of the Gamma distribution.
Example
>>> pystats.qgamma([0.1, 0.2, 0.7], 2, 3) [1.5954348251688362, 2.473164927098954, 7.317649449840613]
- Parameters
q (List[float]) – A standard list input.
shape (float) – The shape parameter, a real-valued input.
scale (float) – The scale parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Gamma distribution is achieved via the Ziggurat method of Marsaglia and Tsang (2000).
Scalar Output¶
- pystats.rgamma(shape: float = 1.0, scale: float = 1.0) float
Random sampling function for the Gamma distribution.
Example
>>> pystats.rgamma(2, 3) 2.5950379008163194
- Parameters
shape (float) – The shape parameter, a real-valued input.
scale (float) – The scale parameter, a real-valued input.
- Returns
A pseudo-random draw from the Gamma distribution.
List Output¶
- pystats.rgamma(n: int, shape: float = 1.0, scale: float = 1.0) List[float]
Random sampling function for the Gamma distribution.
Example
>>> pystats.rgamma(3, 2, 3) [8.584541442906463, 4.491138145011711, 4.904685252957054]
- Parameters
n (int) – The number of output values.
shape (float) – The shape parameter, a real-valued input.
scale (float) – The scale parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Gamma distribution.
Density function of the Gamma distribution |
|
Distribution function of the Gamma distribution |
|
Quantile function of the Gamma distribution |
|
Sampling function of the Gamma distribution |
Inverse-Gamma Distribution¶
Table of contents
Density Function¶
The density function of the inverse-Gamma distribution:
where \(\Gamma(\cdot)\) denotes the Gamma function, \(\alpha\) is the shape parameter, and \(\beta\) is the rate parameter.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dinvgamma(x: float, shape: float = 1.0, rate: float = 1.0, log: bool = False) float
Density function of the inverse-Gamma distribution.
Example
>>> pystats.dinvgamma(1.5, 2, 1) 0.15212359082447174
- Parameters
x (float) – A real-valued input.
shape (float) – The shape parameter, a real-valued input.
rate (float) – The rate parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dinvgamma(x: List[float], shape: float = 1.0, rate: float = 1.0, log: bool = False) List[float]
Density function of the inverse-Gamma distribution.
Example
>>> pystats.dinvgamma([1.8, 0.7, 4.2], 3, 2) [0.12543552347504414, 0.9568116496062874, 0.007984650912112904]
- Parameters
x (List[float]) – A standard list input.
shape (float) – The shape parameter, a real-valued input.
rate (float) – The rate parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the inverse-Gamma distribution:
where \(\Gamma(\cdot)\) denotes the gamma function and \(\gamma(\cdot, \cdot)\) denotes the incomplete gamma function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pinvgamma(p: float, shape: float = 1.0, rate: float = 1.0, log: bool = False) float
Distribution function of the inverse-Gamma distribution.
Example
>>> pystats.pinvgamma(1.5, 2, 1) 0.8556951983876534
- Parameters
p (float) – A real-valued input.
shape (float) – The shape parameter, a real-valued input.
rate (float) – The rate parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pinvgamma(p: List[float], shape: float = 1.0, rate: float = 1.0, log: bool = False) List[float]
Distribution function of the inverse-Gamma distribution.
Example
>>> pystats.pinvgamma([1.8, 0.7, 4.2], 3, 2) [0.8981685222907052, 0.4559446713286356, 0.9873531870485975]
- Parameters
p (List[float]) – A standard list input.
shape (float) – The shape parameter, a real-valued input.
rate (float) – The rate parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the inverse-Gamma distribution:
where \(\Gamma(\cdot)\) denotes the gamma function and \(\gamma(\cdot, \cdot)\) denotes the incomplete gamma function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qinvgamma(q: float, shape: float = 1.0, rate: float = 1.0) float
Quantile function of the inverse-Gamma distribution.
Example
>>> pystats.qinvgamma(0.95, 2, 1) 2.8140357632821265
- Parameters
q (float) – A real-valued input.
shape (float) – The shape parameter, a real-valued input.
rate (float) – The rate parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qinvgamma(q: List[float], shape: float = 1.0, rate: float = 1.0) List[float]
Quantile function of the inverse-Gamma distribution.
Example
>>> pystats.qinvgamma([0.3, 0.5, 0.6], 3, 2) [0.5531634821501723, 0.7479262863802247, 0.8752440657450371]
- Parameters
q (List[float]) – A standard list input.
shape (float) – The shape parameter, a real-valued input.
rate (float) – The rate parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the inverse-Gamma distribution is achieved by simulating \(X \sim G(\alpha, 1/\beta)\), then returning
Scalar Output¶
- pystats.rinvgamma(shape: float = 1.0, rate: float = 1.0) float
Random sampling function for the inverse-Gamma distribution.
Example
>>> pystats.rinvgamma(2, 1) 0.29563080448131196
- Parameters
shape (float) – The shape parameter, a real-valued input.
rate (float) – The rate parameter, a real-valued input.
- Returns
A pseudo-random draw from the inverse-Gamma distribution.
List Output¶
- pystats.rinvgamma(n: int, shape: float = 1.0, rate: float = 1.0) List[float]
Random sampling function for the inverse-Gamma distribution.
Example
>>> pystats.rinvgamma(3, 2, 1) [0.31841204990923705, 0.47383794440642224, 0.4720582119984054]
- Parameters
n (int) – The number of output values.
shape (float) – The shape parameter, a real-valued input.
rate (float) – The rate parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the inverse-Gamma distribution.
Density function of the inverse Gamma distribution |
|
Distribution function of the inverse Gamma distribution |
|
Quantile function of the inverse Gamma distribution |
|
Sampling function of the inverse Gamma distribution |
Laplace Distribution¶
Table of contents
Density Function¶
The density function of the Laplace distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dlaplace(x: float, mu: float = 0.0, sigma: float = 1.0, log: bool = False) float
Density function of the Laplace distribution.
Example
>>> pystats.dlaplace(0.7, 1.0, 2.0) 0.21517699410626442
- Parameters
x (float) – A real-valued input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dlaplace(x: List[float], mu: float = 0.0, sigma: float = 1.0, log: bool = False) List[float]
Density function of the Laplace distribution.
Example
>>> pystats.dlaplace([0.0, 1.0, 2.0], 1.0, 2.0) [0.15163266492815836, 0.25, 0.15163266492815836]
- Parameters
x (List[float]) – A standard list input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Laplace distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.plaplace(p: float, mu: float = 0.0, sigma: float = 1.0, log: bool = False) float
Distribution function of the Laplace distribution.
Example
>>> pystats.plaplace(0.7, 1.0, 2.0) 0.4303539882125289
- Parameters
p (float) – A real-valued input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.plaplace(p: List[float], mu: float = 0.0, sigma: float = 1.0, log: bool = False) List[float]
Distribution function of the Laplace distribution.
Example
>>> pystats.plaplace([0.0, 1.0, 2.0], 1.0, 2.0) [0.3032653298563167, 0.5, 0.6967346701436833]
- Parameters
p (List[float]) – A standard list input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Laplace distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qlaplace(q: float, mu: float = 0.0, sigma: float = 1.0) float
Quantile function of the Laplace distribution.
Example
>>> pystats.qlaplace(0.5, 1.0, 2.0) 1.0
- Parameters
q (float) – A real-valued input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qlaplace(q: List[float], mu: float = 0.0, sigma: float = 1.0) List[float]
Quantile function of the Laplace distribution.
Example
>>> pystats.qlaplace([0.1, 0.6, 0.9], 1.0, 2.0) [-2.218875824868202, 1.4462871026284194, 4.218875824868202]
- Parameters
q (List[float]) – A standard list input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Laplace distribution is achieved via the inverse probability integral transform.
Scalar Output¶
- pystats.rlaplace(mu: float = 0.0, sigma: float = 1.0) float
Random sampling function for the Laplace distribution.
Example
>>> pystats.rlaplace(1.0, 2.0) -0.06931476521956581
- Parameters
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
A pseudo-random draw from the Laplace distribution.
List Output¶
- pystats.rlaplace(n: int, mu: float = 0.0, sigma: float = 1.0) List[float]
Random sampling function for the Laplace distribution.
Example
>>> pystats.rlaplace(3, 1.0, 2.0) [0.7785860236771809, 0.14724988410675632, 3.0446760367044163]
- Parameters
n (int) – The number of output values.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Laplace distribution.
Density function of the Laplace distribution |
|
Distribution function of the Laplace distribution |
|
Quantile function of the Laplace distribution |
|
Sampling function of the Laplace distribution |
Log-Normal Distribution¶
Table of contents
Density Function¶
The density function of the log-Normal distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dlnorm(x: float, mean: float = 0.0, sd: float = 1.0, log: bool = False) float
Density function of the Log-Normal distribution.
Example
>>> pystats.dlnorm(2.0, 1.0, 2.0) 0.0985685803440131
- Parameters
x (float) – A real-valued input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dlnorm(x: List[float], mean: float = 0.0, sd: float = 1.0, log: bool = False) List[float]
Density function of the Log-Normal distribution.
Example
>>> pystats.dlnorm([0.0, 1.0, 2.0], 1.0, 2.0) [0.0, 0.17603266338214968, 0.0985685803440131]
- Parameters
x (List[float]) – A standard list input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the log-Normal distribution:
where \(\text{erf}(\cdot)\) denotes the Gaussian error function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.plnorm(p: float, mean: float = 0.0, sd: float = 1.0, log: bool = False) float
Distribution function of the Log-Normal distribution.
Example
>>> pystats.plnorm(2.0, 1.0, 2.0) 0.43903100974768944
- Parameters
p (float) – A real-valued input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.plnorm(p: List[float], mean: float = 0.0, sd: float = 1.0, log: bool = False) List[float]
Distribution function of the Log-Normal distribution.
Example
>>> pystats.plnorm([0.0, 1.0, 2.0], 1.0, 2.0) [0.0, 0.3085375387259869, 0.43903100974768944]
- Parameters
p (List[float]) – A standard list input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the log-Normal distribution:
where \(\text{erf}^{-1}(\cdot)\) denotes the inverse Gaussian error function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qlnorm(q: float, mean: float = 0.0, sd: float = 1.0) float
Quantile function of the Log-Normal distribution.
Example
>>> pystats.qlnorm(0.95, 1.0, 2.0) 72.94511097708158
- Parameters
q (float) – A real-valued input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qlnorm(q: List[float], mean: float = 0.0, sd: float = 1.0) List[float]
Quantile function of the Log-Normal distribution.
Example
>>> pystats.qlnorm([0.1, 0.5, 0.9], 1.0, 2.0) [0.20948500212405705, 2.718281828459045, 35.27248263126183]
- Parameters
q (List[float]) – A standard list input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the log-Normal distribution is achieved by simulating \(X \sim N(\mu, \sigma^2)\), then returning
Scalar Output¶
- pystats.rlnorm(mean: float = 0.0, sd: float = 1.0) float
Random sampling function for the Log-Normal distribution.
Example
>>> pystats.rlnorm(1.0, 2.0) 0.7961734447160091
- Parameters
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
- Returns
A pseudo-random draw from the Log-Normal distribution.
List Output¶
- pystats.rlnorm(n: int, mean: float = 0.0, sd: float = 1.0) List[float]
Random sampling function for the Log-Normal distribution.
Example
>>> pystats.rlnorm(3, 1.0, 2.0) [0.7889982649469498, 0.060477695435514324, 0.09150040197067903]
- Parameters
n (int) – The number of output values.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Log-Normal distribution.
Density function of the log Normal distribution |
|
Distribution function of the log Normal distribution |
|
Quantile function of the log Normal distribution |
|
Sampling function of the log Normal distribution |
Logistic Distribution¶
Table of contents
Density Function¶
The density function of the Logistic distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dlogis(x: float, mu: float = 0.0, sigma: float = 1.0, log: bool = False) float
Density function of the Logistic distribution.
Example
>>> pystats.dlogis(2.0, 1.0, 2.0) 0.11750185610079714
- Parameters
x (float) – A real-valued input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dlogis(x: List[float], mu: float = 0.0, sigma: float = 1.0, log: bool = False) List[float]
Density function of the Logistic distribution.
Example
>>> pystats.dlogis([0.0, 1.0, 2.0], 1.0, 2.0) [0.11750185610079714, 0.125, 0.11750185610079714]
- Parameters
x (List[float]) – A standard list input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Logistic distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.plogis(p: float, mu: float = 0.0, sigma: float = 1.0, log: bool = False) float
Distribution function of the Logistic distribution.
Example
>>> pystats.plogis(2.0, 1.0, 2.0) 0.6224593312018546
- Parameters
p (float) – A real-valued input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.plogis(p: List[float], mu: float = 0.0, sigma: float = 1.0, log: bool = False) List[float]
Distribution function of the Logistic distribution.
Example
>>> pystats.plogis([0.0, 1.0, 2.0], 1.0, 2.0) [0.37754066879814546, 0.5, 0.6224593312018546]
- Parameters
p (List[float]) – A standard list input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Logistic distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qlogis(q: float, mu: float = 0.0, sigma: float = 1.0) float
Quantile function of the Logistic distribution.
Example
>>> pystats.qlogis(0.75, 1.0, 2.0) 3.1972245773362196
- Parameters
q (float) – A real-valued input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qlogis(q: List[float], mu: float = 0.0, sigma: float = 1.0) List[float]
Quantile function of the Logistic distribution.
Example
>>> pystats.qlogis([0.1, 0.3, 0.7], 1.0, 2.0) [-3.394449154672439, -0.6945957207744073, 2.694595720774407]
- Parameters
q (List[float]) – A standard list input.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Logistic distribution is achieved via the inverse probability integral transform.
Scalar Output¶
- pystats.rlogis(mu: float = 0.0, sigma: float = 1.0) float
Random sampling function for the Logistic distribution.
Example
>>> pystats.rlogis(1.0, 2.0) -2.0430312686217516
- Parameters
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
A pseudo-random draw from the Logistic distribution.
List Output¶
- pystats.rlogis(n: int, mu: float = 0.0, sigma: float = 1.0) List[float]
Random sampling function for the Logistic distribution.
Example
>>> pystats.rlogis(3, 1.0, 2.0) [7.012051380112511, 1.4135266403017916, -1.3985463825344762]
- Parameters
n (int) – The number of output values.
mu (float) – The location parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Logistic distribution.
Density function of the Logistic distribution |
|
Distribution function of the Logistic distribution |
|
Quantile function of the Logistic distribution |
|
Sampling function of the Logistic distribution |
Normal Distribution¶
Table of contents
Density Function¶
The density function of the Normal (Gaussian) distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dnorm(x: float, mean: float = 0.0, sd: float = 1.0, log: bool = False) float
Density function of the Normal distribution.
Example
>>> pystats.dnorm(1.645, 0.0, 1.0) 0.10311081109198143
- Parameters
x (float) – A real-valued input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dnorm(x: List[float], mean: float = 0.0, sd: float = 1.0, log: bool = False) List[float]
Density function of the Normal distribution.
Example
>>> pystats.dnorm([-1.0, 0.0, 2.0], 0.0, 1.0) [0.24197072451914342, 0.39894228040143265, 0.05399096651318805]
- Parameters
x (List[float]) – A standard list input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Normal (Gaussian) distribution:
where \(\text{erf}(\cdot)\) denotes the Gaussian error function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pnorm(p: float, mean: float = 0.0, sd: float = 1.0, log: bool = False) float
Distribution function of the Normal distribution.
Example
>>> pystats.pnorm(1.645, 0.0, 1.0) 0.9500150944608786
- Parameters
p (float) – A real-valued input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pnorm(p: List[float], mean: float = 0.0, sd: float = 1.0, log: bool = False) List[float]
Distribution function of the Normal distribution.
Example
>>> pystats.pnorm([-1.0, 0.0, 2.0], 0.0, 1.0) [0.15865525393145705, 0.5, 0.9772498680518208]
- Parameters
p (List[float]) – A standard list input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the log-Normal distribution:
where \(\text{erf}^{-1}(\cdot)\) denotes the inverse Gaussian error function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qnorm(q: float, mean: float = 0.0, sd: float = 1.0) float
Quantile function of the Normal distribution.
Example
>>> pystats.qnorm(0.95, 0.0, 1.0) 1.6448536269514706
- Parameters
q (float) – A real-valued input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qnorm(q: List[float], mean: float = 0.0, sd: float = 1.0) List[float]
Quantile function of the Normal distribution.
Example
>>> pystats.qnorm([0.3, 0.5, 0.95], 0.0, 1.0) [-0.5244005127080409, 0.0, 1.6448536269514706]
- Parameters
q (List[float]) – A standard list input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Normal distribution is achieved via the normal_distribution
class from the C++ standard library, imported from <random>
.
Scalar Output¶
- pystats.rnorm(mean: float = 0.0, sd: float = 1.0) float
Random sampling function for the Normal distribution.
Example
>>> pystats.rnorm(0.0, 1.0) 0.2772437359624193
- Parameters
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
- Returns
A pseudo-random draw from the Normal distribution.
List Output¶
- pystats.rnorm(n: int, mean: float = 0.0, sd: float = 1.0) List[float]
Random sampling function for the Normal distribution.
Example
>>> pystats.rnorm(3, 0.0, 1.0) [-0.04796221296447198, -2.165514623383353, 0.7219224921308472]
- Parameters
n (int) – The number of output values.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Normal distribution.
Density function of the Normal distribution |
|
Distribution function of the Normal distribution |
|
Quantile function of the Normal distribution |
|
Sampling function of the Normal distribution |
Poisson Distribution¶
Table of contents
Density Function¶
The density function of the Poisson distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dpois(x: float, rate: float, log: bool = False) float
Density function of the Poisson distribution.
Example
>>> pystats.dpois(8, 10.0) 0.11259903214902026
- Parameters
x (float) – A real-valued input.
rate (float) – The rate parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dpois(x: List[float], rate: float, log: bool = False) List[float]
Density function of the Poisson distribution.
Example
>>> pystats.dpois([2, 3, 4], 10.0) [0.0022699964881242435, 0.007566654960414158, 0.01891663740103532]
- Parameters
x (List[float]) – A standard list input.
rate (float) – The rate parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Poisson distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.ppois(p: float, rate: float, log: bool = False) float
Distribution function of the Poisson distribution.
Example
>>> pystats.ppois(8, 10.0) 0.3328196787507189
- Parameters
p (float) – A real-valued input.
rate (float) – The rate parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.ppois(p: List[float], rate: float, log: bool = False) List[float]
Distribution function of the Poisson distribution.
Example
>>> pystats.ppois([2, 3, 4], 10.0) [0.0027693957155115762, 0.010336050675925718, 0.029252688076961075]
- Parameters
p (List[float]) – A standard list input.
rate (float) – The rate parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Poisson distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qpois(q: float, rate: float) float
Quantile function of the Poisson distribution.
Example
>>> pystats.qpois(0.9, 10.0) 14.0
- Parameters
q (float) – A real-valued input.
rate (float) – The rate parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qpois(q: List[float], rate: float) List[float]
Quantile function of the Poisson distribution.
Example
>>> pystats.qpois([0.3, 0.5, 0.8], 10.0) [8.0, 10.0, 13.0]
- Parameters
q (List[float]) – A standard list input.
rate (float) – The rate parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Scalar Output¶
- pystats.rpois(rate: float) float
Random sampling function for the Poisson distribution.
Example
>>> pystats.rpois(10.0) 7.0
- Parameters
rate (float) – The rate parameter, a real-valued input.
- Returns
A pseudo-random draw from the Poisson distribution.
List Output¶
- pystats.rpois(n: int, rate: float) List[float]
Random sampling function for the Poisson distribution.
Example
>>> pystats.rpois(4, 10.0) [11.0, 8.0, 8.0, 9.0]
- Parameters
n (int) – The number of output values.
rate (float) – The rate parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Poisson distribution.
Density function of the Poisson distribution |
|
Distribution function of the Poisson distribution |
|
Quantile function of the Poisson distribution |
|
Sampling function of the Poisson distribution |
Student’s t-Distribution¶
Table of contents
Density Function¶
The density function of the Student’s t distribution:
where \(\Gamma(\cdot)\) denotes the gamma function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dt(x: float, dof: float = 1.0, log: bool = False) float
Density function of the t-distribution distribution.
Example
>>> pystats.dt(0.37, 11) 0.362095719673348
- Parameters
x (float) – A real-valued input.
dof (float) – The degrees of freedom parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dt(x: List[float], dof: float = 1.0, log: bool = False) List[float]
Density function of the t-distribution distribution.
Example
>>> pystats.dt([1.8, 0.7, 4.2], 11) [0.08286084841281988, 0.3002542334010353, 0.0012519045841828374]
- Parameters
x (List[float]) – A standard list input.
dof (float) – The degrees of freedom parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Student’s t distribution:
where \(\Gamma(\cdot)\) denotes the gamma function and \({}_2 F_1\) denotes the hypergeometric function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pt(p: float, dof: float = 1.0, log: bool = False) float
Distribution function of the t-distribution distribution.
Example
>>> pystats.pt(0.37, 11) 0.6407962382848924
- Parameters
p (float) – A real-valued input.
dof (float) – The degrees of freedom parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pt(p: List[float], dof: float = 1.0, log: bool = False) List[float]
Distribution function of the t-distribution distribution.
Example
>>> pystats.pt([1.8, 0.7, 4.2], 11) [0.9503420534306152, 0.7507677671528026, 0.9992572076935229]
- Parameters
p (List[float]) – A standard list input.
dof (float) – The degrees of freedom parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Student’s t distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qt(q: float, dof: float = 1.0) float
Quantile function of the t-distribution distribution.
Example
>>> pystats.qt(0.5, 11) 0.0
- Parameters
q (float) – A real-valued input.
dof (float) – The degrees of freedom parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qt(q: List[float], dof: float = 1.0) List[float]
Quantile function of the t-distribution distribution.
Example
>>> pystats.qt([0.3, 0.5, 0.8], 11) [-0.5399378774105429, 0.0, 0.8755299114635708]
- Parameters
q (List[float]) – A standard list input.
dof (float) – The degrees of freedom parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Scalar Output¶
- pystats.rt(dof: float = 1.0) float
Random sampling function for the t-distribution distribution.
Example
>>> pystats.rt(dof=11) 0.30585871954611826
- Parameters
dof (float) – The degrees of freedom parameter, a real-valued input.
- Returns
A pseudo-random draw from the t-distribution distribution.
List Output¶
- pystats.rt(n: int, dof: float = 1.0) List[float]
Random sampling function for the t-distribution distribution.
Example
>>> pystats.rt(3, 11) [2.781125786671334, -0.7090818248684807, -0.3220992876319297]
- Parameters
n (int) – The number of output values.
dof (float) – The degrees of freedom parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the t-distribution distribution.
Density function of the t-distribution |
|
Distribution function of the t-distribution |
|
Quantile function of the t-distribution |
|
Sampling function of the t-distribution |
Uniform Distribution¶
Table of contents
Density Function¶
The density function of the Uniform distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dunif(x: float, min: float = 0.0, max: float = 1.0, log: bool = False) float
Density function of the Uniform distribution.
Example
>>> pystats.dunif(0.5, -1.0, 2.0) 0.3333333333333333
- Parameters
x (float) – A real-valued input.
min (float) – The lower limit of the distribution, a real-valued input.
max (float) – The upper limit of the distribution, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dunif(x: List[float], min: float = 0.0, max: float = 1.0, log: bool = False) List[float]
Density function of the Uniform distribution.
Example
>>> pystats.dunif([-2.0, 0.0, 2.0], -1.0, 3.0) [0.0, 0.25, 0.25]
- Parameters
x (List[float]) – A standard list input.
min (float) – The lower limit of the distribution, a real-valued input.
max (float) – The upper limit of the distribution, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Uniform distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.punif(p: float, min: float = 0.0, max: float = 1.0, log: bool = False) float
Distribution function of the Uniform distribution.
Example
>>> pystats.punif(0.5, -1.0, 2.0) 0.5
- Parameters
p (float) – A real-valued input.
min (float) – The lower limit of the distribution, a real-valued input.
max (float) – The upper limit of the distribution, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.punif(p: List[float], min: float = 0.0, max: float = 1.0, log: bool = False) List[float]
Distribution function of the Uniform distribution.
Example
>>> pystats.punif([-2.0, 0.0, 2.0], -1.0, 3.0) [0.0, 0.25, 0.75]
- Parameters
p (List[float]) – A standard list input.
min (float) – The lower limit of the distribution, a real-valued input.
max (float) – The upper limit of the distribution, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Uniform distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qunif(q: float, min: float = 0.0, max: float = 1.0) float
Quantile function of the Uniform distribution.
Example
>>> pystats.qunif(0.75, -1.0, 2.0) 1.25
- Parameters
q (float) – A real-valued input.
min (float) – The lower limit of the distribution, a real-valued input.
max (float) – The upper limit of the distribution, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qunif(q: List[float], min: float = 0.0, max: float = 1.0) List[float]
Quantile function of the Uniform distribution.
Example
>>> pystats.qunif([0.3, 0.5, 0.9], -1.0, 3.0) [0.2, 1.0, 2.6]
- Parameters
q (List[float]) – A standard list input.
min (float) – The lower limit of the distribution, a real-valued input.
max (float) – The upper limit of the distribution, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Uniform distribution is achieved via the uniform_real_distribution
class from the C++ standard library, imported from <random>
.
Scalar Output¶
- pystats.runif(min: float = 0.0, max: float = 1.0) float
Random sampling function for the Uniform distribution.
Example
>>> pystats.runif(-1.0, 2.0) 1.0599044629461352
- Parameters
min (float) – The lower limit of the distribution, a real-valued input.
max (float) – The upper limit of the distribution, a real-valued input.
- Returns
A pseudo-random draw from the Uniform distribution.
List Output¶
- pystats.runif(n: int, min: float = 0.0, max: float = 1.0) List[float]
Random sampling function for the Uniform distribution.
Example
>>> pystats.runif(3, -1.0, 2.0) [1.0552953561528309, 0.81837699091385, 0.17769962603787082]
- Parameters
n (int) – The number of output values.
min (float) – The lower limit of the distribution, a real-valued input.
max (float) – The upper limit of the distribution, a real-valued input.
- Returns
A list of pseudo-random draws from the Uniform distribution.
Density function of the Uniform distribution |
|
Distribution function of the Uniform distribution |
|
Quantile function of the Uniform distribution |
|
Sampling function of the Uniform distribution |
Weibull Distribution¶
Table of contents
Density Function¶
The density function of the Weibull distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dweibull(x: float, alpha: float = 1.0, sigma: float = 1.0, log: bool = False) float
Density function of the Weibull distribution.
Example
>>> pystats.dweibull(1.0, 2.0, 3.0) 0.19885318151430437
- Parameters
x (float) – A real-valued input.
alpha (float) – The shape parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dweibull(x: List[float], alpha: float = 1.0, sigma: float = 1.0, log: bool = False) List[float]
Density function of the Weibull distribution.
Example
>>> pystats.dweibull([1.8, 0.7, 4.2], 2.0, 3.0) [0.27907053042841234, 0.14731284075281734, 0.1314678595263087]
- Parameters
x (List[float]) – A standard list input.
alpha (float) – The shape parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Weibull distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pweibull(p: float, alpha: float = 1.0, sigma: float = 1.0, log: bool = False) float
Distribution function of the Weibull distribution.
Example
>>> pystats.pweibull(1.0, 2.0, 3.0) 0.1051606831856301
- Parameters
p (float) – A real-valued input.
alpha (float) – The shape parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pweibull(p: List[float], alpha: float = 1.0, sigma: float = 1.0, log: bool = False) List[float]
Distribution function of the Weibull distribution.
Example
>>> pystats.pweibull([1.8, 0.7, 4.2], 2.0, 3.0) [0.302323673928969, 0.052988880874744404, 0.859141579078955]
- Parameters
p (List[float]) – A standard list input.
alpha (float) – The shape parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Weibull distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qweibull(q: float, alpha: float = 1.0, sigma: float = 1.0) float
Quantile function of the Weibull distribution.
Example
>>> pystats.qweibull(0.5, 2.0, 3.0) 2.497663833473093
- Parameters
q (float) – A real-valued input.
alpha (float) – The shape parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qweibull(q: List[float], alpha: float = 1.0, sigma: float = 1.0) List[float]
Quantile function of the Weibull distribution.
Example
>>> pystats.qweibull([0.3, 0.5, 0.9], 2.0, 3.0) [1.7916680762486648, 2.497663833473093, 4.552281388155439]
- Parameters
q (List[float]) – A standard list input.
alpha (float) – The shape parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Weibull distribution is achieved via the inverse probability integral transform.
Scalar Output¶
- pystats.rweibull(alpha: float = 1.0, sigma: float = 1.0) float
Random sampling function for the Weibull distribution.
Example
>>> pystats.rweibull(2.0, 3.0) 2.7238639049596536
- Parameters
alpha (float) – The shape parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
A pseudo-random draw from the Weibull distribution.
List Output¶
- pystats.rweibull(n: int, alpha: float = 1.0, sigma: float = 1.0) List[float]
Random sampling function for the Weibull distribution.
Example
>>> pystats.rweibull(3, 2.0, 3.0) [0.563858221268503, 1.10144762159266, 2.0484747373540606]
- Parameters
n (int) – The number of output values.
alpha (float) – The shape parameter, a real-valued input.
sigma (float) – The scale parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Weibull distribution.
Density function of the Weibull distribution |
|
Distribution function of the Weibull distribution |
|
Quantile function of the Weibull distribution |
|
Sampling function of the Weibull distribution |
Other statistical functions¶
Table of contents
Mean¶
The mean of the input data is calculated using:
- pystats.mean(x: List[float]) float
Compute the mean of the given data
Example
>>> pystats.mean([1,2,3,4,5]) 3.0
- Parameters
x (List[float]) – A standard list input.
- Returns
The mean of the values in x.
Standard deviation¶
The standard deviation of the input data is calculated using:
This function returns the standard deviation of the sample; that is, it returns the unbiased standard deviation.
- pystats.sd(x: List[float]) float
Compute the standard deviation of the given data
Example
>>> pystats.sd([1,2,3,4,5]) 1.581138
- Parameters
x (List[float]) – A standard list input.
- Returns
The standard deviation (unbiased) of the values in x.
Variance¶
The variance of the input data is calculated using:
This function returns the variance of the sample; that is, it returns the unbiased variance.
- pystats.var(x: List[float]) float
Compute the variance of the given data
Example
>>> pystats.var([1,2,3,4,5]) 2.5
- Parameters
x (List[float]) – A standard list input.
- Returns
The variance (unbiased) of the values in x.