edu.mines.jtk.util
Class Quantiler

java.lang.Object
  extended by edu.mines.jtk.util.Quantiler

public class Quantiler
extends java.lang.Object

A quantile estimator that enables incremental updates. In other words, the estimator processes samples sequentially in one pass, and does not require all samples to be sorted, or even partially sorted, in fast random-access memory.

The quantile estimate is probably not useful for fewer than 10 samples.

The estimate is most accurate for cumulative distribution functions that are smooth in the neighborhood of the desired quantile q. For such distributions, the accuracy of the estimate improves with successive updates.

This class is an implementation of the algorithm published by Jain, R. and Chlamtac, I., 1985, The PP algorithm for dynamic calculation of quantiles and histograms without storing observations: Comm. ACM, v. 28, n. 10.

Version:
2002.03.03, 2006.07.13
Author:
Dave Hale, Colorado School of Mines

Constructor Summary
Quantiler(float q)
          Constructs a quantiler for the specified quantile fraction.
Quantiler(float q, float fnull)
          Constructs a quantiler for the specified quantile fraction and null value.
 
Method Summary
 float estimate()
          Returns the current quantile estimate.
static float estimate(float q, float[] f)
          Estimates the specified quantile for the specified and samples.
static float estimate(float q, float[][] f)
          Estimates the specified quantile for the specified and samples.
static float estimate(float q, float[][][] f)
          Estimates the specified quantile for the specified and samples.
static float estimate(float q, float fnull, float[] f)
          Estimates the specified quantile for the specified null value and samples.
static float estimate(float q, float fnull, float[][] f)
          Estimates the specified quantile for the specified null value and samples.
static float estimate(float q, float fnull, float[][][] f)
          Estimates the specified quantile for the specified null value and samples.
 float update(float f)
          Updates the quantile estimate with the specified sample.
 float update(float[] f)
          Updates the quantile estimate with the specified samples.
 float update(float[][] f)
          Updates the quantile estimate with the specified samples.
 float update(float[][][] f)
          Updates the quantile estimate with the specified samples.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Quantiler

public Quantiler(float q)
Constructs a quantiler for the specified quantile fraction.

Parameters:
q - the quantile fraction; 0 <= q <= 1 is required.

Quantiler

public Quantiler(float q,
                 float fnull)
Constructs a quantiler for the specified quantile fraction and null value.

Parameters:
q - the quantile; 0 <= q <= 1 is required.
fnull - the null value to be ignored in estimating the quantile.
Method Detail

estimate

public float estimate()
Returns the current quantile estimate.

Returns:
the current quantile estimate.

update

public float update(float f)
Updates the quantile estimate with the specified sample.

Parameters:
f - the sample used to update the estimate.
Returns:
the updated quantile estimate.

update

public float update(float[] f)
Updates the quantile estimate with the specified samples.

Parameters:
f - array[] of samples used to update the estimate.
Returns:
the updated quantile estimate.

update

public float update(float[][] f)
Updates the quantile estimate with the specified samples.

Parameters:
f - array[][] of samples used to update the estimate.
Returns:
the updated quantile estimate.

update

public float update(float[][][] f)
Updates the quantile estimate with the specified samples.

Parameters:
f - array[][][] of samples used to update the estimate.
Returns:
the updated quantile estimate.

estimate

public static float estimate(float q,
                             float[] f)
Estimates the specified quantile for the specified and samples.

Parameters:
q - the quantile; 0 <= q <= 1 is required.
f - array[] of samples used to compute the estimate.
Returns:
the quantile estimate.

estimate

public static float estimate(float q,
                             float[][] f)
Estimates the specified quantile for the specified and samples.

Parameters:
q - the quantile; 0 <= q <= 1 is required.
f - array[][] of samples used to compute the estimate.
Returns:
the quantile estimate.

estimate

public static float estimate(float q,
                             float[][][] f)
Estimates the specified quantile for the specified and samples.

Parameters:
q - the quantile; 0 <= q <= 1 is required.
f - array[][][] of samples used to compute the estimate.
Returns:
the quantile estimate.

estimate

public static float estimate(float q,
                             float fnull,
                             float[] f)
Estimates the specified quantile for the specified null value and samples.

Parameters:
q - the quantile; 0 <= q <= 1 is required.
fnull - the null value to be ignored in estimating the quantile.
f - array[] of samples used to compute the estimate.
Returns:
the quantile estimate.

estimate

public static float estimate(float q,
                             float fnull,
                             float[][] f)
Estimates the specified quantile for the specified null value and samples.

Parameters:
q - the quantile; 0 <= q <= 1 is required.
fnull - the null value to be ignored in estimating the quantile.
f - array[][] of samples used to compute the estimate.
Returns:
the quantile estimate.

estimate

public static float estimate(float q,
                             float fnull,
                             float[][][] f)
Estimates the specified quantile for the specified null value and samples.

Parameters:
q - the quantile; 0 <= q <= 1 is required.
fnull - the null value to be ignored in estimating the quantile.
f - array[][][] of samples used to compute the estimate.
Returns:
the quantile estimate.