Choose where you’d like to start

percentile

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,

ParameterData typeDescription
<variable>NUMBER/DECIMALVariable 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:

  • If the collection contains alphanumeric elements, then an error message will be thrown at runtime.
<n>NUMBER/DECIMALThe nth percentile which will be calculated.
  • The numerical value n can be either a number or a decimal.
  • The numerical value n should be within the range 0 (exclusive) and 100 (inclusive).

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:

  1. Multiply the percentile (50 in this case)to be calculated with the number of elements (5 in this case).
  2. Dividing the product by 100, we get 2.5 (50*5/100 = 2.5)
  3. Rounding up the result to the nearest whole number, we get 'n' (3).
  4. Ordering the collection in ascending order, we get {124,300,455,780,926}.
  5. Find the n'th (3rd) value from the collection. 455 is the 50th percentile for the collection.

Get Started Now

Execute