Statistics.Percentile Method

Overload List

#SignatureDescription
1function Percentile(const X: TVec; P: Double; Method: TPercentileMethod): Double;Percentile.
2procedure Percentile(const X: TVec; const P: TDoubleArray; var Percentiles: TDoubleArray; Method: TPercentileMethod);Percentile (several percentiles in one go).

Overload 1: function Percentile(const X: TVec; P: Double; Method: TPercentileMethod): Double;

Percentile.

#NameDescription
1XData. An exception is raised if X is complex.
2PDefines the 100*p percentile. The parameter P must lie in the interval (0,1), otherwise an exception is raised.
3MethodDefines one of the available methods for calculating percentile. Software packages use different methods to calculate percentiles. For example, Excel uses pctMethodNMinus, while on the other hand, NCSS's default method is pctMethodNPlus.

Returns: Double - the 100*P th percentile of all X vector elements. The 100*P -th percentile is defined as the value that is greater than 100*P percent of the values in X.

Examples
Uses MtxExpr, Math387, Statistics;
procedure Example;
var a: Vector;
PrcRes: double;
begin
    a.SetIt(false,[1, 2, 3, 10, 15, 21]);
    PrcRes := Percentile(a,0.75); // PrcRes = 16.5
    PrcRes := Percentile(a,0.75, pctMethodNMinus); // PrcRes = 13.75
    PrcRes := Percentile(a,0.75,pctMethodClosestN); // PrcRes = 10
end;
See Also: Statistics.InterQuartile

Overload 2: procedure Percentile(const X: TVec; const P: TDoubleArray; var Percentiles: TDoubleArray; Method: TPercentileMethod);

Percentile (several percentiles in one go).

#NameTypeDescription
1XTVec
2PTDoubleArray
3PercentilesTDoubleArray
4MethodTPercentileMethod

Result: stored in self (calling object)

Remarks:

This overload calculates percentiles for all P elements in one pass. The advantage of this overload is X sample values only have to be sorted once.

Examples
procedure Example;
var Data: Vector;
    P, Pct: Array of double;
begin
    Data.LoadFromFile('c:\temp\Examples\Data\Percentile.vec');
    SetLength(P,4);
    SetLength(Pct,4);
    Percentile(Data,P,Pct);
end;