Statistics.Percentile Method

Overload List

#SignatureDescription
1Double Percentile(TVec X, Double P, TPercentileMethod Method)Percentile.
2void Percentile(TVec X, Double[] P, ref Double[] Percentiles, TPercentileMethod Method)Percentile (several percentiles in one go).

Overload 1: Double Percentile(TVec X, Double P, TPercentileMethod Method)

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
using Dew.Math;
using Dew.Stats;
using Dew.Stats.Units;
namespace Dew.Examples
{
    private void Example()
    {
        Vector a = new Vector(0);
        double pctile;
        a.SetIt(false, new double[] {1,2,3,10,15,21});
        pctile = Statistics.Percentile(a,0.75,TPercentileMethod.pctMethodNPlus); //  = 16.5
        pctile = Statistics.Percentile(a,0.75, TPercentileMethod.pctMethodNMinus); //  = 13.75
        pctile = Statistics.Percentile(a,0.75,TPercentileMethod.pctMethodClosestN); //  = 10
    }
}
See Also: Statistics.InterQuartile

Overload 2: void Percentile(TVec X, Double[] P, ref Double[] Percentiles, TPercentileMethod Method)

Percentile (several percentiles in one go).

#NameTypeDescription
1XTVecsource TVec
2PDouble[]
3PercentilesDouble[] (ref)
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.