CFLib.org – Common Function Library Project

GetPercentile(pctile, range)

Last updated January 7, 2003
Download UDF

author

Kreig Zimmerman                                   Kreig Zimmerman

Version: 2 | Requires: ColdFusion 5 | Library: MathLib

 
Rated 0 time(s). Average Rating: 0

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:

<cfscript>
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 Shawn Porter added
DeMoronize
3 hour(s) ago

Chris Carey Chris Carey added
readPropertiesFi...
1 day(s) ago

Randy Johnson Randy Johnson added
lastDayofWeek
3 day(s) ago

Frank Marion Frank Marion added
sitemapPing
7 day(s) ago

Top Rated

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Barney Boisvert indentXml
Rated 5.0, 3 time(s)

Nathan Dintenfass                                 queryColumnsToSt...
Rated 5.0, 3 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson