public class Quantile extends Object implements Statistic
quantile.
Different interpolation conventions can return different quartiles for the same sample. The S convention matches R type 7 and linearly interpolates between ordered observations.
import dev.nm.stat.descriptive.rank.Quantile;
Quantile quantiles = new Quantile(new double[]{4, 1, 3, 2}, Quantile.QuantileType.S);
assert Math.abs(quantiles.value(0.25) - 1.75) < 1e-12;
assert Math.abs(quantiles.value(0.5) - 2.5) < 1e-12;
assert quantiles.value(0) == 1.0;
assert quantiles.value(1) == 4.0;
| Modifier and Type | Class and Description |
|---|---|
static class |
Quantile.QuantileType
the available quantile definitions
|
| Constructor and Description |
|---|
Quantile()
Construct a
Quantile calculator using the default type:
Quantile.QuantileType.APPROXIMATELY_MEDIAN_UNBIASED, without initial data. |
Quantile(double[] data)
Construct a
Quantile calculator using the default type:
Quantile.QuantileType.APPROXIMATELY_MEDIAN_UNBIASED. |
Quantile(double[] data,
Quantile.QuantileType type)
Construct a
Quantile calculator. |
| Modifier and Type | Method and Description |
|---|---|
void |
addData(double... data)
Recompute the statistic with more data, incrementally if possible.
|
long |
N()
Get the size of the sample.
|
double |
value()
Get the value of the statistic.
|
double |
value(double q)
Compute the sample value corresponding to a quantile.
|
public Quantile(double[] data,
Quantile.QuantileType type)
Quantile calculator.data - the datatype - the algorithm to compute Q(q)public Quantile(double[] data)
Quantile calculator using the default type:
Quantile.QuantileType.APPROXIMATELY_MEDIAN_UNBIASED.data - the datapublic Quantile()
Quantile calculator using the default type:
Quantile.QuantileType.APPROXIMATELY_MEDIAN_UNBIASED, without initial data.public double value(double q)
q - a quantileq quantilepublic void addData(double... data)
Statisticpublic double value()
StatisticCopyright © 2010-2026 NM Group. All Rights Reserved.