percentile
Table of Contents
Overview
The percentile function takes a numerical value 'n' as argument, and returns the nth percentile in a collection of values
Note:
- This task is applicable to all services except Zoho Creator.
- A percentile is a value below which a given percentage of values in a data set fall.
- See how the percentile gets calculated
Return Type
- NUMBER/DECIMAL
Syntax
<variable> = <collection>.percentile(<n>);
where,
Parameter | Data type | Description |
<variable> | NUMBER/DECIMAL | Variable which will contain the calculated percentile value. |
<collection> | COLLECTION | The collection of numbers/decimals/text(containing numbers or decimals) whose percentile needs to be determined. Note:
|
<n> | NUMBER/DECIMAL | The nth percentile which will be calculated.
|
Examples
Let's consider a collection of numerical values. Calculating the 50th percentile of the collection of numbers.
marks = Collection(300,455,124,926,780); info marks.percentile(50); // returns 455
Percentile calculation:
- Multiply the percentile (50 in this case)to be calculated with the number of elements (5 in this case).
- Dividing the product by 100, we get 2.5 (50*5/100 = 2.5)
- Rounding up the result to the nearest whole number, we get 'n' (3).
- Ordering the collection in ascending order, we get {124,300,455,780,926}.
- Find the n'th (3rd) value from the collection. 455 is the 50th percentile for the collection.