Class EmpiricalQuantiles
- All Implemented Interfaces:
Serializable,Cloneable
The class EmpiricalQuantiles determines the empirical quantiles, as indicated
in the array qProp, from the data in x. The algorithm first checks to
see if x is sorted; if x is not sorted, the algorithm
does either a complete or partial sort, depending on how many order
statistics are required to compute the quantiles requested.
The algorithm returns the empirical quantiles and, for each quantile, the two
order statistics from the sample that are at least as large and at least as
small as the quantile. For a sample of size n, the quantile corresponding to
the proportion p is defined as
$$Q(p) = (1 - f)x_{(j)} + fx_{(j+1)} $$
where \(j = \lfloor p(n+1) \rfloor \),
\(f = p(n+1) - j\), and
\(x_{(j)}\),
is the j-th order statistic, if
\(1 \leq j \le n\);
otherwise, the empirical quantile is the smallest or largest order statistic.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe computations cannot continue because a scale factor is zero. -
Constructor Summary
ConstructorsConstructorDescriptionEmpiricalQuantiles(double[] x, double[] qProp) Constructor forEmpiricalQuantiles. -
Method Summary
Modifier and TypeMethodDescriptionfinal double[]getQ()Returns the empirical quantiles.intReturns the total number of missing values.final double[]getXHi()Returns the smallest element ofxgreater than or equal to the desired quantile.final double[]getXLo()Returns the largest element ofxless than or equal to the desired quantile.
-
Constructor Details
-
EmpiricalQuantiles
public EmpiricalQuantiles(double[] x, double[] qProp) Constructor forEmpiricalQuantiles.- Parameters:
x- Adoublearray containing the data.qProp- Adoublearray containing the quantile proportions.
-
-
Method Details
-
getTotalMissing
public int getTotalMissing()Returns the total number of missing values.- Returns:
- an
intscalar value representing the total number of missing values (NaN) in inputx.
-
getQ
public final double[] getQ()Returns the empirical quantiles.- Returns:
- A
doublearray containing the empirical quantiles.Q[i]corresponds to the empirical quantile at proportionqProp[i]. The quantiles are determined by linear interpolation between adjacent ordered sample values.
-
getXLo
public final double[] getXLo()Returns the largest element ofxless than or equal to the desired quantile.- Returns:
- A
doublearray containing the largest element ofxless than or equal to the desired quantile.
-
getXHi
public final double[] getXHi()Returns the smallest element ofxgreater than or equal to the desired quantile.- Returns:
- A
doublearray containing the smallest element ofxgreater than or equal to the desired quantile.
-