Probability Distributions

class paramnormal.dist.normal[source]

Bases: paramnormal.dist.BaseDist_Mixin

Create and fit data to a normal distribution.

Parameters:

mu : float

The expected value (mean) of the underlying normal distribution. Acts as the location parameter of the distribution.

sigma : float

The standard deviation of the underlying normal distribution. Also acts as the scale parameter of distribution.

See also

scipy.stats.norm, numpy.random.normal

References

http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.norm.html https://en.wikipedia.org/wiki/normal_distribution

Examples

>>> import numpy
>>> import paramnormal as pn
>>> numpy.random.seed(0)
>>> pn.normal(mu=5, sigma=2).rvs(size=3)
array([ 8.52810469,  5.80031442,  6.95747597])
>>> # english names and greek symbols are interchangeable
>>> numpy.random.seed(0)
>>> pn.normal(μ=5, σ=2).rvs(size=3)
array([ 8.52810469,  5.80031442,  6.95747597])
>>> # silly fake data
>>> numpy.random.seed(0)
>>> data = numpy.random.normal(5, 2, size=37)
>>> # pretend `data` is unknown and we want to fit a dist. to it
>>> pn.normal.fit(data)
params(mu=5.6480512782619359, sigma=2.1722505742582769)
>>> # estimate sigma when mu is fixed a known value:
>>> pn.normal.fit(data, mu=4.75)
params(mu=4.75, sigma=2.3505677305181645)

Methods

dist = <scipy.stats._continuous_distns.norm_gen object>
param_template

alias of params

name = 'normal'
class paramnormal.dist.lognormal[source]

Bases: paramnormal.dist.BaseDist_Mixin

Create and fit data to a lognormal distribution.

Parameters:

mu : float

The expected value (mean) of the underlying normal distribution. Acts as the scale parameter of the distribution.

sigma : float

The standard deviation of the underlying normal distribution. Also acts as the shape parameter of distribution.

offset : float, optional

The location parameter of the distribution. It’s effectively the lower bound of the distribution. In other works, if you’re investigating some quantity that cannot go below zero (e.g., pollutant concentrations), leave this as the default (zero).

Note

When fitting a lognormal distribution to a dataset, this will be fixed at its default value unless you explicitly set it to another value. Set it to None if wish that it be estimated entirely from scratch.

See also

scipy.stats.lognorm, numpy.random.lognormal

References

http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.lognorm.html https://en.wikipedia.org/wiki/lognormal_distribution

Examples

>>> import numpy
>>> import paramnormal as pn
>>> numpy.random.seed(0)
>>> pn.lognormal(mu=5, sigma=2).rvs(size=3)
array([ 5054.85624027,   330.40342795,  1050.97750604])
>>> # you can also use greek letters
>>> numpy.random.seed(0)
>>> pn.lognormal(μ=5, σ=2).rvs(size=3)
array([ 5054.85624027,   330.40342795,  1050.97750604])
>>> # silly fake data
>>> numpy.random.seed(0)
>>> data = numpy.random.lognormal(5, 2, size=37)
>>> # pretend `data` is unknown and we want to fit a dist. to it
>>> pn.lognormal.fit(data)
params(mu=5.6480511731060181, sigma=2.172250571711877, offset=0)
>>> # estimate sigma when mu is fixed a known value:
>>> pn.lognormal.fit(data, mu=4.75)
params(mu=4.75, sigma=2.3505859375000036, offset=0)
>>> # include `offset` in the estimate
>>> pn.lognormal.fit(data, offset=None)
params(mu=5.6538159643068386, sigma=2.1596452081058795, offset=-0.12039282461824304)

Methods

dist = <scipy.stats._continuous_distns.lognorm_gen object>
param_template

alias of params

name = 'lognormal'
classmethod fit(data, **guesses)[source]
class paramnormal.dist.weibull[source]

Bases: paramnormal.dist.BaseDist_Mixin

Create and fit data to a weibull distribution.

Parameters:

k : float

The shape parameter of the distribution.

Note

Strictly speaking, the weibull distribution has a second shape parameter, lambda. However, it seems to be always set to 1. So much so that scipy doesn’t give you any other option.

loc, scale : floats, optional

Location and scale parameters of the distribution. These default to, and should probably be left at, 0 and 1, respectively.

Note

When fitting a weibull distribution to a dataset, these will be fixed at their default values unless you explicitly set them to other values. Set them to None if you wish that they be estimated entirely from scratch.

See also

scipy.stats.weibull_min, scipy.stats.frechet_min, numpy.random.weibull

References

http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.weibull_min.html https://en.wikipedia.org/wiki/weibull_distribution

Examples

>>> import numpy
>>> import paramnormal as pn
>>> numpy.random.seed(0)
>>> pn.weibull(k=5).rvs(size=3)
array([ 0.9553641 ,  1.04662991,  0.98415009])
>>> # silly fake data
>>> numpy.random.seed(0)
>>> data = numpy.random.weibull(5, size=37)
>>> # pretend `data` is unknown and we want to fit a dist. to it
>>> pn.weibull.fit(data)
params(k=5.4158203125000091, loc=0, scale=1)
>>> # include `loc` and `scale` in the estimate
>>> pn.weibull.fit(data, loc=None, scale=None)
params(k=14.120107702486127, loc=-1.389856535577052, scale=2.4320324339845572)

Methods

dist = <scipy.stats._continuous_distns.frechet_r_gen object>
param_template

alias of params

name = 'weibull'
class paramnormal.dist.alpha[source]

Bases: paramnormal.dist.BaseDist_Mixin

Create and fit data to a alpha distribution.

Parameters:

alpha : float

The shape parameter of the distribution.

loc, scale : floats, optional

Location and scale parameters of the distribution. These default to, and should probably be left at, 0 and 1, respectively.

Note

When fitting a alpha distribution to a dataset, these will be fixed at their default values unless you explicitly set them to other values. Set them to None if you wish that they be estimated entirely from scratch.

See also

scipy.stats.alpha

References

http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.alpha.html

Examples

>>> import numpy
>>> from scipy import stats
>>> import paramnormal as pn
>>> numpy.random.seed(0)
>>> pn.alpha(alpha=5).rvs(size=3)
array([ 0.20502995,  0.22566277,  0.21099298])
>>> # you can also use greek letters
>>> numpy.random.seed(0)
>>> pn.alpha(α=5).rvs(size=3)
array([ 0.20502995,  0.22566277,  0.21099298])
>>> # silly fake data
>>> numpy.random.seed(0)
>>> data = stats.alpha.rvs(5, size=37)
>>> # pretend `data` is unknown and we want to fit a dist. to it
>>> pn.alpha.fit(data)
params(alpha=4.8356445312500096, loc=0, scale=1)
>>> # include `loc` and `scale` in the estimate
>>> pn.alpha.fit(data, loc=None, scale=None)
params(alpha=8.6781299501492342, loc=-0.15002784429644306, scale=3.1262971852456447)

Methods

dist = <scipy.stats._continuous_distns.alpha_gen object>
param_template

alias of params

name = 'alpha'
class paramnormal.dist.beta[source]

Bases: paramnormal.dist.BaseDist_Mixin

Create and fit data to a beta distribution.

Parameters:

alpha, beta : float

The (positive) shape parameters of the distribution.

loc, scale : floats, optional

Location and scale parameters of the distribution. These default to, and should probably be left at, 0 and 1, respectively.

Note

When fitting a beta distribution to a dataset, these will be fixed at their default values unless you explicitly set them to other values. Set them to None if you wish that they be estimated entirely from scratch.

See also

scipy.stats.beta, numpy.random.beta

References

http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.beta.html https://en.wikipedia.org/wiki/beta_distribution

Examples

>>> import numpy
>>> import paramnormal as pn
>>> numpy.random.seed(0)
>>> pn.beta(alpha=2, beta=5).rvs(size=3)
array([ 0.47917138,  0.6550558 ,  0.21501632])
>>> # you can also use greek letters
>>> numpy.random.seed(0)
>>> pn.beta(α=2, β=5).rvs(size=3)
array([ 0.47917138,  0.6550558 ,  0.21501632])
>>> # silly fake data
>>> numpy.random.seed(0)
>>> data = pn.beta(alpha=2, beta=5).rvs(size=37)
>>> # pretend `data` is unknown and we want to fit a dist. to it
>>> pn.beta.fit(data)
params(alpha=1.6784891179355115, beta=4.2459121691279398, loc=0, scale=1)
>>> # just estimate beta with a known alpha
>>> pn.beta.fit(data, alpha=2)
params(alpha=2, beta=4.9699264393421139, loc=0, scale=1)
>>> # include `loc` and `scale` in the estimate
>>> pn.beta.fit(data, loc=None, scale=None)
params(alpha=1.8111139255547926, beta=4.6972775768688697, loc=-0.0054013993799938431, scale=1.0388376932132561)

Methods

dist = <scipy.stats._continuous_distns.beta_gen object>
param_template

alias of params

name = 'beta'
class paramnormal.dist.gamma[source]

Bases: paramnormal.dist.BaseDist_Mixin

Create and fit data to a gamma distribution.

Parameters:

k, theta : float

The shape and scale parameters of the distribution, respectively.

loc : float, optional

Location parameter of the distribution. This defaults to, and should probably be left at, 0.

Note

When fitting a beta distribution to a dataset, this will be fixed at its default value unless you explicitly set it to other values. Set to None if you wish that it be estimated entirely from scratch.

See also

scipy.stats.gamma, numpy.random.gamma

References

http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.gamma.html https://en.wikipedia.org/wiki/gamma_distribution

Examples

>>> import numpy
>>> import paramnormal as pn
>>> numpy.random.seed(0)
>>> pn.gamma(k=2, theta=5).rvs(size=3)
array([ 25.69414788,  11.19240456,  27.13566137])
>>> # you can also use greek letters
>>> numpy.random.seed(0)
>>> pn.gamma(k=2, θ=5).rvs(size=3)
array([ 25.69414788,  11.19240456,  27.13566137])
>>> # silly fake data
>>> numpy.random.seed(0)
>>> data = pn.gamma(k=2, θ=5).rvs(size=37)
>>> # pretend `data` is unknown and we want to fit a dist. to it
>>> pn.gamma.fit(data)
params(k=1.3379069223213471, loc=0, theta=7.5830062081633622)
>>> # just estimate theta with a known k
>>> pn.gamma.fit(data, theta=5)
params(k=1.8060453251225814, loc=0, theta=5)
>>> # include `loc` in the estimate
>>> pn.gamma.fit(data, loc=None)
params(k=1.0996117768860174, loc=0.29914735266576881, theta=8.9542450315590756)

Methods

dist = <scipy.stats._continuous_distns.gamma_gen object>
param_template

alias of params

name = 'gamma'
class paramnormal.dist.chi_squared[source]

Bases: paramnormal.dist.BaseDist_Mixin

Create and fit data to a chi-squared distribution.

Parameters:

k : float

The degrees of freedom of the distribution, respectively.

loc, scale : floats, optional

Location and scale parameters of the distribution. These default to, and should probably be left at, 0 and 1, respectively.

Note

When fitting a chi-squared distribution to a dataset, these will be fixed at their default value unless you explicitly set them to other values. Set to None if you wish that they be estimated entirely from scratch.

See also

scipy.stats.chi2, numpy.random.chisquare

References

http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chi2.html https://en.wikipedia.org/wiki/Chi-squared_distribution

Examples

>>> import numpy
>>> import paramnormal as pn
>>> numpy.random.seed(0)
>>> pn.chi_squared(k=2).rvs(size=3)
array([ 1.59174902,  2.51186153,  1.84644629])
>>> # silly fake data
>>> numpy.random.seed(0)
>>> data = pn.chi_squared(k=2).rvs(size=37)
>>> # pretend `data` is unknown and we want to fit a dist. to it
>>> pn.chi_squared.fit(data)
params(k=2.2668945312500028, loc=0, scale=1)
>>> # include `loc` in the estimate
>>> pn.chi_squared.fit(data, loc=None)
params(k=1.9361813889429524, loc=0.037937143324767775, scale=1)

Methods

dist = <scipy.stats._continuous_distns.chi2_gen object>
param_template

alias of params

nane = 'chi_squared'
class paramnormal.dist.pareto[source]

Bases: paramnormal.dist.BaseDist_Mixin

Create and fit data to a pareto distribution.

Parameters:

alpha : float

The shape parameter of the distribution.

loc, scale : floats, optional

Location and scale parameters of the distribution. These default to, and should probably be left at, 0 and 1, respectively.

Note

When fitting a pareto distribution to a dataset, this will be fixed at its default value unless you explicitly set it to other values. Set to None if you wish that it be estimated entirely from scratch.

See also

scipy.stats.pareto, numpy.random.pareto

References

http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.pareto.html https://en.wikipedia.org/wiki/pareto_distribution

Examples

>>> import numpy
>>> import paramnormal as pn
>>> numpy.random.seed(0)
>>> pn.pareto(alpha=2).rvs(size=3)
array([ 1.48875061,  1.87379424,  1.58662889])
>>> # you can also use greek letters
>>> numpy.random.seed(0)
>>> pn.pareto(α=2).rvs(size=3)
array([ 1.48875061,  1.87379424,  1.58662889])
>>> # silly fake data
>>> numpy.random.seed(0)
>>> data = pn.pareto(alpha=2).rvs(size=37)
>>> # pretend `data` is unknown and we want to fit a dist. to it
>>> pn.pareto.fit(data)
params(alpha=1.7850585937500019, loc=0, scale=1)
>>> # include `loc` in the estimate
>>> pn.pareto.fit(data, loc=None)
params(alpha=1.8040853559635659, loc=0.009529403810858695, scale=1)

Methods

dist = <scipy.stats._continuous_distns.pareto_gen object>
param_template

alias of params

name = 'pareto'
class paramnormal.dist.exponential[source]

Bases: paramnormal.dist.BaseDist_Mixin

Create and fit data to an exponential distribution.

Parameters:

lambda_ : float

The shape parameter of the distribution.

loc : float, optional

Location parameter of the distribution. This defaults to, and should probably be left at, 0.

Note

When fitting an exponential distribution to a dataset, this will be fixed at its default value unless you explicitly set it to other values. Set to None if you wish that it be estimated entirely from scratch.

See also

scipy.stats.expon, numpy.random.exponential

References

http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.expon.html https://en.wikipedia.org/wiki/exponential_distribution

Examples

>>> import numpy
>>> import paramnormal as pn
>>> numpy.random.seed(0)
>>> pn.exponential(lambda_=2).rvs(size=3)
array([ 0.39793725,  0.62796538,  0.46161157])
>>> # you can also use greek letters
>>> numpy.random.seed(0)
>>> pn.exponential(λ=2).rvs(size=3)
array([ 0.39793725,  0.62796538,  0.46161157])
>>> # silly fake data
>>> numpy.random.seed(0)
>>> data = pn.exponential(λ=2).rvs(size=37)
>>> # pretend `data` is unknown and we want to fit a dist. to it
>>> pn.exponential.fit(data)
params(lambda_=1.7849050026146085, loc=0)
>>> # include `loc` in the estimate
>>> pn.exponential.fit(data, loc=None)
params(lambda_=1.8154701618164411, loc=0.0094842718426853996)

Methods

dist = <scipy.stats._continuous_distns.expon_gen object>
param_template

alias of params

name = 'exponential'
classmethod fit(data, **guesses)[source]
class paramnormal.dist.rice[source]

Bases: paramnormal.dist.BaseDist_Mixin

Create and fit data to a Rice distribution.

Parameters:

R : float

The shape parameter of the distribution.

sigma : float

The standard deviate of the distribution.

loc : float, optional

Location parameter of the distribution. This defaults to, and should probably be left at, 0.

Note

When fitting an Rice distribution to a dataset, this will be fixed at its default value unless you explicitly set it to other values. Set to None if you wish that it be estimated entirely from scratch.

See also

scipy.stats.rice, numpy.random.exponential

References

http://scipy.github.io/devdocs/generated/scipy.stats.rice https://en.wikipedia.org/wiki/Rice_distribution

Examples

>>> import numpy
>>> import paramnormal as pn
>>> numpy.random.seed(0)
>>> pn.rice(R=10, sigma=2).rvs(size=3)
array([ 15.67835764,  13.36907874,  10.37753817])
>>> # you can also use greek letters
>>> numpy.random.seed(0)
>>> pn.rice(R=10, σ=2).rvs(size=3)
array([ 15.67835764,  13.36907874,  10.37753817])
>>> # silly fake data
>>> numpy.random.seed(0)
>>> data = pn.rice(R=10, sigma=2).rvs(size=37)
>>> # pretend `data` is unknown and we want to fit a dist. to it
>>> pn.rice.fit(data)
params(R=10.100674084593422, sigma=1.759817171541185, loc=0)
>>> # include `loc` in the estimate (bad idea)
>>> pn.rice.fit(data, loc=None)
params(R=4.249154300734, sigma=1.862167512728, loc=5.570921659394)

Methods

dist = <scipy.stats._continuous_distns.rice_gen object>
param_template

alias of params

name = 'rice'
classmethod fit(data, **guesses)[source]