GetPercentile(pctile, range)
Last updated January 7, 2003
Version: 2 | Requires: ColdFusion 5 | Library: MathLib
Description:
GetPercentile is a UDF provided for the purpose of getting a statistically valid percentile from a comma-delimited list of values. When this list is passed in, the UDF will sort the values within an array, and then, using the percentile value passed in (0-100) grab the statistically valid value that corresponds to said percentile.
Return Values:
Returns a number.
Example:
jack=GetPercentile(25, '12,10,20,14');
WriteOutput(jack);
</cfscript>
Parameters:
| Name | Description | Required |
|---|---|---|
| pctile | Percentile | Yes |
| range | List of numeric values. | Yes |
Full UDF Source:
<cfscript>
/**
* Function which gets the value corresponding to a certain percentile from a list of numeric values.
* Error in second to last line.
*
* @param pctile Percentile (Required)
* @param range List of numeric values. (Required)
* @return Returns a number.
* @author Kreig Zimmerman (kreig303@yahoo.com)
* @version 2, January 7, 2003
*/
function GetPercentile(pctile, range) {
var rangeArr = ListToArray(range);
var rangepoint = "";
pctile = pctile * .01;
ArraySort(rangeArr, "numeric");
rangePoint = Max(Round(ArrayLen(rangeArr)*pctile), 1);
return rangeArr[rangePoint];
}
</cfscript>
Search CFLib.org
Latest Additions
Shawn Porter added
DeMoronize
3 hour(s) ago
Chris Carey added
readPropertiesFi...
1 day(s) ago
Randy Johnson added
lastDayofWeek
3 day(s) ago
Frank Marion added
sitemapPing
7 day(s) ago
Top Rated
QuickSort
Rated 5.0, 3 time(s)
indentXml
Rated 5.0, 3 time(s)
queryColumnsToSt...
Rated 5.0, 3 time(s)
generateSsccAsn
Rated 5.0, 3 time(s)