FLOW ALGEBRA
PERCENTILE ONTOLOGY
Kireth Semantic Library | Mathematical Entities > Statistical Entities
Version: 1.0 | Date: 2026-10-13
Authors: Mark Higgins — Sky (Recursive AI)
Source: https://kirethresearch.org/booksai-core/entity-graph/mathematical-entities/statistical-entities/percentile-ontology-2.html
Status: Proposed formalisation; source page wording not independently verified.
1. PURPOSE
Represent percentiles as typed statistical entities, relate them to quantiles and cumulative distributions, and support validated computation and AI reasoning.
2. TYPES
entity PercentileLevel { p: Real; constraint: 0 <= p <= 100 }
entity ProbabilityLevel { q: Real; constraint: 0 <= q <= 1 }
entity Distribution { cdf: Function<Real, [0,1]> }
entity PopulationPercentile { level: PercentileLevel; value: Real }
entity SamplePercentile { level: PercentileLevel; value: Real; method: QuantileMethod; sample_id: String }
entity Observation { value: Real; sample_id: String }
entity OrderedSample { values: Sequence<Real>; size: Integer }
entity PercentileRank { value: Real; rank_percent: Real; tie_policy: String }
entity QuantileMethod { name: String; interpolation: String; index_convention: String }
3. DEFINITIONS
let q = p / 100.
Population percentile (generalised inverse): Q(q) = inf {x in R : F(x) >= q}, for 0 < q < 1.
For q = 0 or q = 1, endpoints require explicit conventions and may be infinite.
A sample percentile is an estimate calculated from ordered observations using a declared quantile method.
Percentile rank reports relative position of a value in a dataset; it is not itself a percentile value.
4. RELATIONSHIPS
PercentileLevel --normalises_to--> ProbabilityLevel
PopulationPercentile --derived_from--> Distribution
SamplePercentile --estimated_from--> OrderedSample
SamplePercentile --uses_method--> QuantileMethod
Percentile --specialises--> Quantile
50thPercentile --corresponds_to--> Median (under the chosen quantile convention)
25thPercentile --corresponds_to--> FirstQuartile
75thPercentile --corresponds_to--> ThirdQuartile
InterquartileRange --equals--> Q(0.75) - Q(0.25)
PercentileRank --distinct_from--> PercentileValue
5. MATHEMATICAL INVARIANTS
P1: 0 <= p <= 100.
P2: For p1 <= p2, Q(p1/100) <= Q(p2/100), whenever both values are defined.
P3: F is nondecreasing and right-continuous, with limits 0 and 1 at negative and positive infinity.
P4: For 0 < q < 1, F(Q(q)) >= q whenever Q(q) is finite.
P5: For strictly increasing continuous F, F(Q(q)) = q.
P6: Percentiles transform equivariantly under strictly increasing continuous transformations g: Q_g(X)(q) = g(Q_X(q)); decreasing transformations require adjusted tail conventions.
P7: Sample-percentile results must declare the algorithm and handling of missing values.
6. INFERENCE RULES
rule R1: valid_distribution(F) and 0 < p < 100 => percentile(F,p) = inf{x | F(x) >= p/100}.
rule R2: p1 <= p2 and both_percentiles_defined => percentile(F,p1) <= percentile(F,p2).
rule R3: sample_sorted(S) and method_specified(M) => compute_sample_percentile(S,p,M).
rule R4: q25_defined and q75_defined => IQR = Q(0.75) - Q(0.25).
rule R5: sample_percentile_method_missing => flag_ambiguous_result.
rule R6: percentile_rank_requested => do_not_substitute_quantile_value.
7. EXAMPLE
Sample S = [2,4,6,8,10]. Under nearest-rank convention for 0 < p <= 100:
rank = ceil((p/100) * n); value = S[rank] (1-based indexing).
P80 = S[ceil(0.8*5)] = S[4] = 8.
Other interpolation methods may produce different results on the same data.
8. VALIDATION
check V1: percentile level in [0,100].
check V2: nonempty sample and finite numeric observations after declared missing-value policy.
check V3: sample size matches retained observations.
check V4: ordering and quantile method recorded.
check V5: CDF meets monotonicity, right-continuity and limit conditions.
check V6: endpoint conventions explicit.
check V7: percentile rank distinguished from percentile value.
check V8: units of percentile value match measured variable; percentile level is dimensionless.
9. SEMANTIC EQUIVALENCE AND DIFFERENCE
SEMANTIC_EQUIVALENCE: percentile(p) <=> quantile(p/100) under identical distribution and inverse convention.
SEMANTIC_DIFFERENCE: population percentile != sample percentile estimator.
SEMANTIC_DIFFERENCE: percentile value != percentile rank.
SEMANTIC_DIFFERENCE: quantile definition != interpolation algorithm.
CONFIDENCE: 1.0 for deductive results when all premises and conventions are verified; otherwise explicitly lower or unresolved.
10. FLOW_HASH AND UPDATE_MODEL
FLOW_HASH: SHA-256 of canonical UTF-8 representation of ontology identifier, version, types, rules and source provenance; computed by the consuming implementation (not precomputed here).
UPDATE_MODEL: On changes to quantile conventions, source content, sample preprocessing or inference rules, increment version and recompute FLOW_HASH.
11. AI_CONSUMPTION
Input: {distribution_or_sample, percentile_level, definition_or_method, units, provenance}.
Process: validate -> select population/sample interpretation -> compute -> check invariants -> attach uncertainty and method metadata.
Output: {percentile_value, level, method, units, confidence, provenance, validation_status}.
Do not assert a unique sample percentile where the estimation convention is unspecified.
END FLOW ALGEBRA
Download Code
Copy to Clipboard