RangeFractile - script and chart function
RangeFractile() returns the value that corresponds to the n-th fractile (quantile) of a range of numbers.
Syntax:
RangeFractile(fractile, first_expr[, Expression])
Return data type: numeric
Arguments:
The arguments of this function may contain inter-record functions which in themselves return a list of values.
Argument | Description |
---|---|
|
A number between 0 and 1 corresponding to the fractile (quantile expressed as a fraction) to be calculated. |
|
The expression or field containing the data to be measured. |
|
Optional expressions or fields containing the range of data to be measured. |
Examples and results:
Examples | Results |
---|---|
RangeFractile (0.24,1,2,4,6) | Returns 1.72 |
RangeFractile(0.5,1,2,3,4,6) |
Returns 3 |
RangeFractile (0.5,1,2,5,6) |
Returns 3.5 |
Example:
Add the example script to your app and run it. Then add, at least, the fields listed in the results column to a sheet in your app to see the result.
RangeTab:
LOAD recno() as RangeID, RangeFractile(0.5,Field1,Field2,Field3) as MyRangeFrac INLINE [
Field1, Field2, Field3
10,5,6
2,3,7
8,2,8
18,11,9
5,5,9
9,4,2
];
The resulting table shows the returned values of
RangeID | MyRangeFrac |
---|---|
1 | 6 |
2 | 3 |
3 | 8 |
4 | 11 |
5 | 5 |
6 | 4 |
Example with expression:
RangeFractile (0.5, Above(Sum(MyField),0,3))
In this example, the inter-record function Above() contains the optional
MyField | RangeFractile(0.5, Above(Sum(MyField),0,3)) |
---|---|
1 | 1 |
2 | 1.5 |
3 | 2 |
4 | 3 |
5 | 4 |
6 | 5 |
Data used in examples:
RangeTab:
LOAD * INLINE [
MyField
1
2
3
4
5
6
] ;