amisc.distribution
Module for probability distribution functions (PDFs).
Includes:
Distribution
— an abstract interface for specifying a PDF.Uniform
— a uniform distribution.Normal
— a normal distribution.Relative
— a relative distribution (i.e. uniform within a percentage of a nominal value).Tolerance
— a tolerance distribution (i.e. uniform within a tolerance of a nominal value).LogUniform
— a log-uniform distribution.LogNormal
— a log-normal distribution.
Distribution objects can be converted easily to/from strings for serialization.
Distribution(dist_args)
Bases: ABC
Base class for PDF distributions that provide sample and pdf methods. Distributions should:
sample
- return samples from the distributionpdf
- return the probability density function of the distribution
ATTRIBUTE | DESCRIPTION |
---|---|
dist_args |
the arguments that define the distribution (e.g. mean and std for a normal distribution)
TYPE:
|
Source code in src/amisc/distribution.py
domain(dist_args=None)
Return the domain of this distribution. Defaults to dist_args
PARAMETER | DESCRIPTION |
---|---|
dist_args |
overrides
TYPE:
|
from_string(dist_string)
classmethod
Convert a string to a Distribution
object.
PARAMETER | DESCRIPTION |
---|---|
dist_string |
specifies a PDF or distribution. Can be
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Distribution | None
|
the corresponding |
Source code in src/amisc/distribution.py
nominal(dist_args=None)
Return the nominal value of this distribution. Defaults to middle of domain.
PARAMETER | DESCRIPTION |
---|---|
dist_args |
overrides
TYPE:
|
Source code in src/amisc/distribution.py
pdf(x, dist_args=None)
abstractmethod
Evaluate the pdf of this distribution at the x
locations.
PARAMETER | DESCRIPTION |
---|---|
x |
the locations at which to evaluate the pdf
TYPE:
|
dist_args |
overrides
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
the pdf evaluations |
Source code in src/amisc/distribution.py
sample(shape, nominal=None, dist_args=None)
abstractmethod
Sample from the distribution.
PARAMETER | DESCRIPTION |
---|---|
shape |
shape of the samples to return
TYPE:
|
nominal |
a nominal value(s) for sampling (e.g. for relative distributions)
TYPE:
|
dist_args |
overrides
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
the samples of the given shape |
Source code in src/amisc/distribution.py
LogNormal(dist_args, base=10)
Bases: Distribution
A LogNormal distribution. Specify by string as LogNormal(mu, sigma)
or LN(mu, sigma)
in shorthand.
Uses base-10 by default.
Source code in src/amisc/distribution.py
domain(dist_args=None)
Defaults the domain of the distribution to 3 standard deviations above and below the mean.
LogUniform(dist_args, base=10)
Bases: Distribution
A LogUniform distribution. Specify by string as LogUniform(lb, ub)
or LU(lb, ub)
in shorthand. Uses
base-10 by default.
Source code in src/amisc/distribution.py
Normal(dist_args)
Bases: Distribution
A Normal distribution. Specify by string as Normal(mu, std)
or N(mu, std)
in shorthand.
Source code in src/amisc/distribution.py
domain(dist_args=None)
Defaults the domain of the distribution to 3 standard deviations above and below the mean.
Relative(dist_args)
Bases: Distribution
A Relative distribution. Specify by string as Relative(pct)
or rel(pct%)
in shorthand.
Will attempt to sample uniformly within the given percent of a nominal value.
Source code in src/amisc/distribution.py
Tolerance(dist_args)
Bases: Distribution
A Tolerance distribution. Specify by string as Tolerance(tol)
or tol(tol)
in shorthand.
Will attempt to sample uniformly within a given absolute tolerance of a nominal value.
Source code in src/amisc/distribution.py
Uniform(dist_args)
Bases: Distribution
A Uniform distribution. Specify by string as "Uniform(lb, ub)" or "U(lb, ub)" in shorthand.