Package csb :: Package statistics :: Package pdf |
[frames] | no frames]

# Package pdf

source code

Probability density functions.

This module defines AbstractDensity: a common interface for all PDFs. Each AbstractDensity describes a specific type of probability distribution, for example Normal is an implementation of the Gaussian distribution:

    >>> pdf = Normal(mu=10, sigma=1.1)
    >>> pdf.mu, pdf['sigma']
    10.0, 1.1

Every PDF provides an implementation of the AbstractDensity.evaluate method, which evaluates the PDF for a list of input data points:

    >>> pdf.evaluate([10, 9, 11, 12])
    array([ 0.3626748 ,  0.2399147 ,  0.2399147 ,  0.06945048])

PDF instances also behave like functions:

    >>> pdf(data)    # the same as pdf.evaluate(data)

Some AbstractDensity implementations may support drawing random numbers from the distribution (or raise an exception otherwise):

    >>> pdf.random(2)
    array([ 9.86257083,  9.73760515])

Each implementation of AbstractDensity may support infinite number of estimators, used to estimate and re-initialize the PDF parameters from a set of observed data points:

    >>> pdf.estimate([5, 5, 10, 10])
    >>> pdf.mu, pdf.sigma
    (7.5, 2.5)
    >>> pdf.estimator
    <csb.statistics.pdf.GaussianMLEstimator>

Estimators implement the AbstractEstimator interface. They are treated as pluggable tools, which can be exchanged through the AbstractDensity.estimator property (you could create, initialize and plug your own estimator as well). This is a classic Strategy pattern.

Submodules
csb.statistics.pdf.parameterized: Probability density functions with support for shared and computed parameters.

Classes
| AbstractDensity Defines the interface and common operations for all probability density functions.
| AbstractEstimator Density parameter estimation strategy.
| BaseDensity Base abstract class for all PDFs, which operate on simple float or array-of-float parameters.
| Dirichlet
| DirichletEstimator
| EstimationFailureError
| Gamma
| GammaMLEstimator
| GaussianMLEstimator
| GenNormalBruteForceEstimator
| GeneralizedInverseGaussian
| GeneralizedNormal
| GumbelMaxMomentsEstimator
| GumbelMaximum
| GumbelMinMomentsEstimator
| GumbelMinimum
| IncompatibleEstimatorError
| InverseGamma
| InverseGaussian
| InverseGaussianMLEstimator
| Laplace
| LaplaceMLEstimator
| MultivariateGaussian
| MultivariateGaussianMLEstimator
| Normal
| NullEstimator Does not estimate anything.
| ParameterNotFoundError
| ParameterValueError

Variables
| EULER_MASCHERONI = `0.577215664902`
| fabs = `<ufunc 'fabs'>`
| gammaln = `<ufunc 'gammaln'>`
| pi = `3.14159265359`
| power = `<ufunc 'power'>`
| sqrt = `<ufunc 'sqrt'>`