Attributes
- covariance_factor
This can be replaced with silverman_factor if one wants to use Silverman's rule for choosing the bandwidth of the kernels.
covariance_factor = scotts_factor
Method summary
- __init__(self, dataset)
- evaluate(self, points)
- integrate_box(self, low_bounds, high_bounds, maxpts = None)
- integrate_box_1d(self, low, high)
- integrate_gaussian(self, mean, cov)
- integrate_kde(self, other)
- resample(self, size = None)
- scotts_factor(self)
- silverman_factor(self)
Methods
- __init__(self, dataset)
- evaluate(self, points)
Evaluate the estimated pdf on a set of points.
Parameters
- points : (# of dimensions, # of points)-array
- Alternatively, a (# of dimensions,) vector can be passed in and treated as a single point.
Returns
- values : (# of points,)-array
- The values at each point.
Raises
ValueError if the dimensionality of the input points is different than the dimensionality of the KDE.
- integrate_box(self, low_bounds, high_bounds, maxpts = None)
Computes the integral of a pdf over a rectangular interval.
Parameters
- low_bounds : vector
- lower bounds of integration
- high_bounds : vector
- upper bounds of integration
- maxpts=None : int
- maximum number of points to use for integration
Returns
- value : scalar
- the result of the integral
- integrate_box_1d(self, low, high)
Computes the integral of a 1D pdf between two bounds.
Parameters
- low : scalar
- lower bound of integration
- high : scalar
- upper bound of integration
Returns
- value : scalar
- the result of the integral
Raises
ValueError if the KDE is over more than one dimension.
- integrate_gaussian(self, mean, cov)
Multiply estimated density by a multivariate Gaussian and integrate over the wholespace.
Parameters
- mean : vector
- the mean of the Gaussian
- cov : matrix
- the covariance matrix of the Gaussian
Returns
- result : scalar
- the value of the integral
Raises
ValueError if the mean or covariance of the input Gaussian differs from the KDE's dimensionality.
- integrate_kde(self, other)
Computes the integral of the product of this kernel density estimate with another.
Parameters
- other : gaussian_kde instance
- the other kde
Returns
- value : scalar
- the result of the integral
Raises
ValueError if the KDEs have different dimensionality.
- resample(self, size = None)
Randomly sample a dataset from the estimated pdf.
Parameters
- size : int, optional
- The number of samples to draw. If not provided, then the size is the same as the underlying dataset.
Returns
- dataset : (self.d, size)-array
- sampled dataset
- scotts_factor(self)
- silverman_factor(self)
