Home
Products
Support
Blog
Resources
Company
NMath Stats User's Guide
TOC |  Previous |  Next |  Index

3.5 Ranks, Percentiles, Deciles, and Quartiles

The static Ranks() method on class StatsFunctions returns the rank of each element in a data set an as array of integers. For example:

int[] ranks  = StatsFunctions.Ranks( data );

By default, the ranks are calculated using ascending order. Alternatively, you can specify a sort order using a value from the SortingType enumeration. Thus:

int[] ranks  =
  StatsFunctions.Ranks( data, SortingType.Descending );

NOTE- StatsSettings.Sorting specifies the default SortingType.

The Rank() method returns where a given value would rank within a data set, if it were part of the data set. Again, the sorting order can be specified using a value from the SortingType enumeration. For instance:

double x = 5.342;
int rank = StatsFunctions.Rank( data, x, SortingType.Descending );

Percentile() calculates the value at the nth percentile of the elements in a data set, where . For example, to find the value at the 95th percentile:

double x = StatsFunctions.Percentile( data, 0.95 );

PercentileRank() performs the inverse calculation, returning the percentile a given value would have if it were part of the data set:

double x = 23.653;
double percentile = StatsFunctions.Percentile( data, x );

The returned percentile value is between 0 and 1.

Similarly, Decile() calculates a given decile, specified as an integer between 0 and 10, of the elements in a data set. Quartile() calculates a given quartile, specified as an integer between 0 and 4. For example, this code finds the third quartile value:

double x = StatsFunctions.Quartile( data, 3 );

TOC |  Previous |  Next |  Index

Copyright © 2008 CenterSpace Software, LLC. All rights reserved.
All trademarks and registered trademarks mentioned on this web site are the property of their respective owners.
Contact Webmaster