Class KernelDensity
java.lang.Object
smile.stat.distribution.KernelDensity
- All Implemented Interfaces:
 Serializable, Distribution
Kernel density estimation is a non-parametric way of estimating the
probability density function of a random variable. Kernel density estimation
is a fundamental data smoothing problem where inferences about the population
are made, based on a finite data sample. It is also known as the
Parzen window method.
- See Also:
 
- 
Constructor Summary
ConstructorsConstructorDescriptionKernelDensity(double[] x) Constructor.KernelDensity(double[] x, double h) Constructor. - 
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the bandwidth of kernel.doublecdf(double x) Cumulative distribution function.doubleentropy()Shannon's entropy.intlength()Returns the number of parameters of the distribution.doublelikelihood(double[] x) The likelihood of the samples.doublelogLikelihood(double[] x) The log likelihood of the samples.doublelogp(double x) The density at x in log scale, which may prevents the underflow problem.doublemean()Returns the mean of distribution.doublep(double x) The probability density function for continuous distribution or probability mass function for discrete distribution at x.doublequantile(double p) Inverse of CDF.doublerand()Random number generator.doublesd()Returns the standard deviation of distribution.doublevariance()Returns the variance of distribution.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Distribution
inverseTransformSampling, quantile, quantile, rand, rejectionSampling 
- 
Constructor Details
- 
KernelDensity
public KernelDensity(double[] x) Constructor. The bandwidth of kernel will be estimated by the rule of thumb.- Parameters:
 x- the samples to estimate the density function.
 - 
KernelDensity
public KernelDensity(double[] x, double h) Constructor.- Parameters:
 x- the samples to estimate the density function.h- a bandwidth parameter for smoothing.
 
 - 
 - 
Method Details
- 
bandwidth
public double bandwidth()Returns the bandwidth of kernel.- Returns:
 - the bandwidth of kernel
 
 - 
length
public int length()Description copied from interface:DistributionReturns the number of parameters of the distribution. The "length" is in the sense of the minimum description length principle.- Specified by:
 lengthin interfaceDistribution- Returns:
 - The number of parameters.
 
 - 
mean
public double mean()Description copied from interface:DistributionReturns the mean of distribution.- Specified by:
 meanin interfaceDistribution- Returns:
 - The mean.
 
 - 
variance
public double variance()Description copied from interface:DistributionReturns the variance of distribution.- Specified by:
 variancein interfaceDistribution- Returns:
 - The variance.
 
 - 
sd
public double sd()Description copied from interface:DistributionReturns the standard deviation of distribution.- Specified by:
 sdin interfaceDistribution- Returns:
 - The standard deviation.
 
 - 
entropy
public double entropy()Shannon's entropy. Not supported.- Specified by:
 entropyin interfaceDistribution- Returns:
 - Shannon entropy.
 
 - 
rand
public double rand()Random number generator. Not supported.- Specified by:
 randin interfaceDistribution- Returns:
 - a random number.
 
 - 
p
public double p(double x) Description copied from interface:DistributionThe probability density function for continuous distribution or probability mass function for discrete distribution at x.- Specified by:
 pin interfaceDistribution- Parameters:
 x- a real number.- Returns:
 - the density.
 
 - 
logp
public double logp(double x) Description copied from interface:DistributionThe density at x in log scale, which may prevents the underflow problem.- Specified by:
 logpin interfaceDistribution- Parameters:
 x- a real number.- Returns:
 - the log density.
 
 - 
cdf
public double cdf(double x) Cumulative distribution function. Not supported.- Specified by:
 cdfin interfaceDistribution- Parameters:
 x- a real number.- Returns:
 - the probability.
 
 - 
quantile
public double quantile(double p) Inverse of CDF. Not supported.- Specified by:
 quantilein interfaceDistribution- Parameters:
 p- the probability.- Returns:
 - the quantile.
 
 - 
likelihood
public double likelihood(double[] x) The likelihood of the samples. Not supported.- Specified by:
 likelihoodin interfaceDistribution- Parameters:
 x- a set of samples.- Returns:
 - the likelihood.
 
 - 
logLikelihood
public double logLikelihood(double[] x) The log likelihood of the samples. Not supported.- Specified by:
 logLikelihoodin interfaceDistribution- Parameters:
 x- a set of samples.- Returns:
 - the log likelihood.
 
 
 -