You are here: Symbol Reference > Statistics Namespace > Functions > Statistics.Percentile Function
Stats Master VCL
ContentsIndex
PreviousUpNext
Statistics.Percentile Function

Percentile.

Pascal
function Percentile(const X: TVec; P: double; Method: TPercentileMethod = pctMethodNPlus): double; overload;
Parameters 
Description 
Data. An exception is raised if X is complex. 
Defines the 100*p percentile. The parameter P must lie in the interval (0,1), otherwise an exception is raised. 
Method 
Defines 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. 

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.

Calculate the 2nd quantile location = median position.

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;
#include "MtxExpr.hpp"
#include "Math387.hpp"
#include "Statistics.hpp"
void __fastcall Example()
{
  sVector a;
  double pctile;
  a.SetIt(false,OPENARRAY(double,(1,2,3,10,15,21)));
  pctile = Percentile(a,0.75,pctMethodNPlus); //  = 16.5
  pctile = Percentile(a,0.75, pctMethodNMinus); //  = 13.75
  pctile = Percentile(a,0.75,pctMethodClosestN); //  = 10
}
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!