quantile, quantile ignore zero
Quantiles are points in a distribution that relate to the rank order of values in that distribution. As an example, the middle
quantile (quantile parameter p = 0.5) is referred as median() function. B4P also supports this function directly.
Quantile calculation is the inverse of the empirical probability distribution. Following calculation rule is applied:
n refers to the number numeric values provided. p is referred as the quantile parameter.
Examples:
The function quantile ignore zero ignores all zero values provided. If the sequence of values does only contain zeros, then an exception will be asserted because the quantile cannot be calculated.
2
No. | Type | Description |
---|---|---|
1 input |
numeral | Quantile parameter The value must lie between 0 and 1. |
2 input |
set | Set of values The set must contain at least one numeric element which will be included in the calculation. Blank strings are tolerated (no exceptions asserted) and ignored as well (not treated as zero). The values do not need to be ordered in ascending order. This function will take of it. |
Opt. 3 input |
numeral | Starting set element to include Points to the starting set element. Negative indexing is allowed here, i.e. -1 refers to last element in the set. Default value: 0 |
Opt. 4 input |
numeral | Ending set element to include Points to the ending set element. Negative indexing is allowed here, i.e. -1 refers to last element in the set. Default value: Last value |
Type | Description |
---|---|
numeral | Calculated quantile |
Quantile parameter not between 0 and 1
No numbers available to calculate
ps[] = { 0, 0.0001, 0.1, 0.2, 0.25, 1/3, 0.5, 2/3, 0.75, 0.8, 0.9, 0.9999, 1.0 };
for all( ps[], p[] )
{
echo("p: ", p[]," quantile = ", quantile( p[], { 1, 2, 2, 3, 5, 8, 9, 12, 12, 13 } ) );
}
echo( "Call with 4 parameters: ", quantile( 0.5, { 8,7,6,5,4,3,2,1 }, 1, 3 ) );
// Values 7,6,5 are calculated and result in 6.
p: 0 quantile = 1
p: 0.0001 quantile = 1
p: 0.1 quantile = 1.5
p: 0.2 quantile = 2
p: 0.25 quantile = 2
p: 0.3333333333 quantile = 3
p: 0.5 quantile = 6.5
p: 0.6666666667 quantile = 9
p: 0.75 quantile = 12
p: 0.8 quantile = 12
p: 0.9 quantile = 12.5
p: 0.9999 quantile = 13
p: 1.0 quantile = 13
Call with 4 parameters: 6