Package smile.stat.distribution
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
ConstructorDescriptionKernelDensity
(double[] x) Constructor.KernelDensity
(double[] x, double h) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondouble
Returns the bandwidth of kernel.double
cdf
(double x) Cumulative distribution function.double
entropy()
Shannon's entropy.int
length()
Returns the number of parameters of the distribution.double
likelihood
(double[] x) The likelihood of the samples.double
logLikelihood
(double[] x) The log likelihood of the samples.double
logp
(double x) The density at x in log scale, which may prevents the underflow problem.double
mean()
Returns the mean of distribution.double
p
(double x) The probability density function for continuous distribution or probability mass function for discrete distribution at x.double
quantile
(double p) Inverse of CDF.double
rand()
Random number generator.double
sd()
Returns the standard deviation of distribution.double
variance()
Returns the variance of distribution.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface smile.stat.distribution.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:Distribution
Returns the number of parameters of the distribution. The "length" is in the sense of the minimum description length principle.- Specified by:
length
in interfaceDistribution
- Returns:
- The number of parameters.
-
mean
public double mean()Description copied from interface:Distribution
Returns the mean of distribution.- Specified by:
mean
in interfaceDistribution
- Returns:
- The mean.
-
variance
public double variance()Description copied from interface:Distribution
Returns the variance of distribution.- Specified by:
variance
in interfaceDistribution
- Returns:
- The variance.
-
sd
public double sd()Description copied from interface:Distribution
Returns the standard deviation of distribution.- Specified by:
sd
in interfaceDistribution
- Returns:
- The standard deviation.
-
entropy
public double entropy()Shannon's entropy. Not supported.- Specified by:
entropy
in interfaceDistribution
- Returns:
- Shannon entropy.
-
rand
public double rand()Random number generator. Not supported.- Specified by:
rand
in interfaceDistribution
- Returns:
- a random number.
-
p
public double p(double x) Description copied from interface:Distribution
The probability density function for continuous distribution or probability mass function for discrete distribution at x.- Specified by:
p
in interfaceDistribution
- Parameters:
x
- a real number.- Returns:
- the density.
-
logp
public double logp(double x) Description copied from interface:Distribution
The density at x in log scale, which may prevents the underflow problem.- Specified by:
logp
in interfaceDistribution
- Parameters:
x
- a real number.- Returns:
- the log density.
-
cdf
public double cdf(double x) Cumulative distribution function. Not supported.- Specified by:
cdf
in interfaceDistribution
- Parameters:
x
- a real number.- Returns:
- the probability.
-
quantile
public double quantile(double p) Inverse of CDF. Not supported.- Specified by:
quantile
in interfaceDistribution
- Parameters:
p
- the probability.- Returns:
- the quantile.
-
likelihood
public double likelihood(double[] x) The likelihood of the samples. Not supported.- Specified by:
likelihood
in 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:
logLikelihood
in interfaceDistribution
- Parameters:
x
- a set of samples.- Returns:
- the log likelihood.
-