Class KernelDensity

java.lang.Object
smile.stat.distribution.KernelDensity
All Implemented Interfaces:
Serializable, Distribution

public class KernelDensity extends Object implements 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

    Constructors
    Constructor
    Description
    KernelDensity(double[] x)
    Constructor.
    KernelDensity(double[] x, double h)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the bandwidth of kernel.
    double
    cdf(double x)
    Cumulative distribution function.
    double
    Shannon entropy.
    int
    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
    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
    Random number generator.
    double
    sd()
    The standard deviation of distribution.
    double
    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

    rand
  • 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
      The number of parameters of the distribution. The "length" is in the sense of the minimum description length principle.
      Specified by:
      length in interface Distribution
      Returns:
      The number of parameters.
    • mean

      public double mean()
      Description copied from interface: Distribution
      The mean of distribution.
      Specified by:
      mean in interface Distribution
      Returns:
      The mean.
    • variance

      public double variance()
      Description copied from interface: Distribution
      The variance of distribution.
      Specified by:
      variance in interface Distribution
      Returns:
      The variance.
    • sd

      public double sd()
      Description copied from interface: Distribution
      The standard deviation of distribution.
      Specified by:
      sd in interface Distribution
      Returns:
      The standard deviation.
    • entropy

      public double entropy()
      Shannon entropy. Not supported.
      Specified by:
      entropy in interface Distribution
      Returns:
      Shannon entropy.
    • rand

      public double rand()
      Random number generator. Not supported.
      Specified by:
      rand in interface Distribution
      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 interface Distribution
      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 interface Distribution
      Parameters:
      x - a real number.
      Returns:
      the log density.
    • cdf

      public double cdf(double x)
      Cumulative distribution function. Not supported.
      Specified by:
      cdf in interface Distribution
      Parameters:
      x - a real number.
      Returns:
      the probability.
    • quantile

      public double quantile(double p)
      Inverse of CDF. Not supported.
      Specified by:
      quantile in interface Distribution
      Parameters:
      p - the probability.
      Returns:
      the quantile.
    • likelihood

      public double likelihood(double[] x)
      The likelihood of the samples. Not supported.
      Specified by:
      likelihood in interface Distribution
      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 interface Distribution
      Parameters:
      x - a set of samples.
      Returns:
      the log likelihood.