11.2.2.3. astroML.density_estimation.EmpiricalDistribution

class astroML.density_estimation.EmpiricalDistribution(data)[source]

Empirically learn a distribution from one-dimensional data

Parameters
dataone-dimensional array

input data

Notes

This function works by approximating the inverse of the cumulative distribution using an efficient spline fit to the sorted values.

Examples

>>> import numpy as np
>>> np.random.seed(0)
>>> x = np.random.normal(size=10000)  # normally-distributed variables
>>> x.mean(), x.std()
(-0.018433720158265783, 0.98755656817612003)
>>> x2 = EmpiricalDistribution(x).rvs(10000)
>>> x2.mean(), x2.std()
(-0.020293716681613363, 1.0039249294845276)

Methods

rvs(shape)

Draw random variables from the distribution

__init__(data)[source]

Initialize self. See help(type(self)) for accurate signature.