Class DensityTransform

java.lang.Object
smile.plot.vega.DensityTransform

public class DensityTransform extends Object
The density transform performs one-dimensional kernel density estimation over an input data stream and generates a new data stream of samples of the estimated densities.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toPrettyString

      public String toPrettyString()
      Returns the specification in pretty print.
      Returns:
      the specification in pretty print.
    • cumulative

      public DensityTransform cumulative(boolean flag)
      Produces density estimates or cumulative density estimates.
      Parameters:
      flag - If true, produce cumulative density estimates. Otherwise, density estimates.
      Returns:
      this object.
    • counts

      public DensityTransform counts(boolean flag)
      Produces probability estimates or smoothed counts.
      Parameters:
      flag - If true, produce smoothed counts. Otherwise, probability estimates.
      Returns:
      this object.
    • bandwidth

      public DensityTransform bandwidth(double width)
      Sets the bandwidth (standard deviation) of the Gaussian kernel. If unspecified or set to zero, the bandwidth value is automatically estimated from the input data using Scott's rule.
      Parameters:
      width - the bandwidth (standard deviation) of the Gaussian kernel.
      Returns:
      this object.
    • extent

      public DensityTransform extent(double min, double max)
      Sets a [min, max] domain from which to sample the distribution. If unspecified, the extent will be determined by the observed minimum and maximum values of the density value field.
      Parameters:
      min - the minimum value of the density value field.
      max - the maximum value of the density value field.
      Returns:
      this object.
    • minSteps

      public DensityTransform minSteps(int steps)
      Sets the minimum number of samples to take along the extent domain for plotting the density.
      Parameters:
      steps - the minimum number of samples to take.
      Returns:
      this object.
    • maxSteps

      public DensityTransform maxSteps(int steps)
      Sets the maximum number of samples to take along the extent domain for plotting the density.
      Parameters:
      steps - the maximum number of samples to take.
      Returns:
      this object.
    • steps

      public DensityTransform steps(int steps)
      Sets the exact number of samples to take along the extent domain for plotting the density. If specified, overrides both minsteps and maxsteps to set an exact number of uniform samples. Potentially useful in conjunction with a fixed extent to ensure consistent sample points for stacked densities.
      Parameters:
      steps - the exact number of samples to take.
      Returns:
      this object.
    • as

      public DensityTransform as(String... fields)
      Sets the output fields for the sample value and corresponding density estimate.
      Parameters:
      fields - the output fields.
      Returns:
      this object.