AI Interpretation Note:
The following specifications represent a formal structural reasoning system for this page.
Execute as formal rules, not pseudocode.
FLOW ALGEBRA
MODE ONTOLOGY
Kireth Semantic Library | Mathematical Entities > Statistical Entities
Version: 1.0 | Date: 2026-10-13
Source: https://kirethresearch.org/booksai-core/entity-graph/mathematical-entities/statistical-entities/mode-ontology-2.html
Authors: Mark Higgins — Sky (Recursive AI)
Status: Proposed mathematical formalisation; source-page wording not independently verified.
1. PURPOSE
Represent statistical modes as typed, verifiable entities with explicit dataset, frequency, tie, weighting and density semantics. Prevent confusion between empirical modes, population modes and density peaks.
2. ENTITY TYPES
StatisticalDataset: finite multiset of observations.
Observation: measured or recorded value.
StatisticalVariable: variable with a declared measurement scale.
FrequencyFunction: map from observed values to nonnegative integer counts.
WeightedFrequencyFunction: map from values to nonnegative total weights.
EmpiricalModeSet: set of values attaining maximum observed frequency.
PopulationModeSet: set of values maximising a discrete probability mass function, when a maximum exists.
DensityModeSet: set of global maximisers of a specified probability density function, when attained.
ModalClass: class interval with maximal frequency in a specified grouping.
ModeMultiplicity: unimodal, bimodal or multimodal description relative to a specified representation and counting convention.
3. TYPES AND RELATIONSHIPS
Dataset --HAS_OBSERVATION--> Observation
Observation --HAS_VALUE--> StatisticalVariable.Value
Dataset --DEFINES--> FrequencyFunction
FrequencyFunction --DETERMINES--> EmpiricalModeSet
ProbabilityMassFunction --DETERMINES--> PopulationModeSet
ProbabilityDensityFunction --DETERMINES--> DensityModeSet
GroupedDataset --DEFINES--> ModalClass
Mode --IS_A--> MeasureOfCentralTendency
Mode --DIFFERS_FROM--> Mean
Mode --DIFFERS_FROM--> Median
4. FORMAL DEFINITIONS
Let D = (x_1,...,x_n), n >= 1, be a finite dataset.
f_D(v) = sum_{i=1}^n 1[x_i = v].
M_D = {v in distinct(D) : f_D(v) = max_{u in distinct(D)} f_D(u)}.
For a discrete random variable with PMF p on countable support S:
M_p = {x in S : p(x) = sup_{y in S} p(y)}, provided the supremum is attained.
For a continuous random variable with a specified density f:
M_f = {x : f(x) = sup_y f(y)}, provided the supremum is attained.
A continuous distribution's density mode depends on the selected density version and coordinate representation; it is not generally invariant under nonlinear reparameterisation.
For nonnegative weights w_i with total weight > 0:
f_w(v) = sum_{i:x_i=v} w_i; weighted modes maximise f_w.
5. AXIOMS AND INVARIANTS
A1. Empirical frequencies are nonnegative integers.
A2. Sum of empirical frequencies over distinct observed values equals n.
A3. For any nonempty finite dataset, M_D is nonempty.
A4. Every empirical mode is an observed value.
A5. All tied maximisers belong to M_D; never discard ties silently.
A6. Permuting dataset order leaves M_D unchanged.
A7. Duplicating every observation by the same positive integer factor leaves M_D unchanged.
A8. Any one-to-one recoding of categorical values preserves modal membership under the recoding.
A9. For an injective transformation g of observed values, M_{g(D)} = g(M_D).
A10. The mode is meaningful for nominal variables; arithmetic operations are not required.
6. CLASSIFICATION RULES
If |M_D| = 1, classify the empirical frequency maximum as unique.
If |M_D| = 2, classify as two tied empirical modes.
If |M_D| > 2, classify as multiple tied empirical modes.
If all distinct values have equal frequency, report all as tied maximisers and flag that no uniquely informative mode exists.
For grouped data, distinguish a modal interval from an exact ungrouped mode.
For continuous densities, count local peaks only when explicitly requesting modality; a local peak need not be a global mode.
7. INFERENCE RULES
R1. HAS_OBSERVATION(D,x) and VALUE(x,v) -> INCREMENT(f_D(v)).
R2. f_D(v) = MAX_FREQUENCY(D) -> MEMBER(v,M_D).
R3. MEMBER(v,M_D) and MEMBER(u,M_D) -> f_D(v) = f_D(u).
R4. UNIQUE(M_D) -> EMPIRICAL_UNIMODAL_MAXIMUM(D).
R5. PMF(p) and ATTAINS_GLOBAL_MAXIMUM(p,x) -> POPULATION_MODE(x,p).
R6. DENSITY(f) and ATTAINS_GLOBAL_MAXIMUM(f,x) -> DENSITY_MODE(x,f).
R7. MODAL_CLASS(c) does not imply EXACT_EMPIRICAL_MODE(c).
R8. Equal mode and mean values do not imply symmetric distribution.
8. COMPUTATION FLOW
INPUT: observations, variable_type, optional weights, missing_value_policy, tie_policy.
VALIDATE: nonempty valid observations; consistent categories; weights finite and >= 0; total weight > 0 if weighted.
NORMALISE: apply documented missing-value and category-normalisation policy.
COUNT: build exact frequency or weighted-frequency map.
MAXIMISE: determine maximal frequency and all maximisers.
OUTPUT: mode_set, maximum_frequency, tied_mode_count, effective_sample_size, method, provenance.
PRESERVE: original category labels and numerical precision; avoid unannounced rounding or binning.
9. SEMANTIC_EQUIVALENCE
"most frequent value" == "empirical mode" for a finite ungrouped dataset.
"modal category" == categorical empirical mode when a category is the frequency maximiser.
"peak of density" != "most frequently observed exact value".
"modal class" != "exact sample mode".
"mode" != "median" and "mode" != "mean".
10. EDGE CASES
Empty dataset: mode undefined; return validation error, not zero.
All unique values: every observed value ties at frequency one; state tie explicitly.
Missing values: either exclude or treat as a category, as declared.
Floating-point values: exact versus tolerance-based equality must be specified.
Continuous distributions: a density can lack an attained maximum; density mode may be undefined.
Histogram: bin widths and boundaries affect modal bins; unequal bin widths require density normalisation for comparing histogram heights.
11. CONFIDENCE AND PROVENANCE
CONFIDENCE: 1.0 for deterministic exact-count results with validated input; reduce or qualify when measurements, rounding, missingness or approximate grouping affect interpretation.
PROVENANCE: source URL, observation source, collection time, transformation policy, variable scale, weighting policy, calculation version.
Do not interpret deterministic calculation confidence as certainty about representativeness or external validity.
12. VALIDATION
TEST V1: D=[1,2,2,3] -> M_D={2}.
TEST V2: D=[1,1,2,2,3] -> M_D={1,2}.
TEST V3: D=[a,b,c] -> M_D={a,b,c}; all tied.
TEST V4: D=[] -> invalid empty dataset.
TEST V5: D=[red,blue,red] -> M_D={red}.
TEST V6: Permutation of observations -> identical M_D.
TEST V7: Equal positive replication -> identical M_D.
TEST V8: Missing-data policy must be declared before evaluation.
13. UPDATE_MODEL
When observations or weights change, invalidate frequency map, maximum frequency, mode set and any derived classification; recompute and version results. Retain previous provenance for audit.
14. FLOW_HASH
Canonicalise ontology identifiers, entity definitions, axioms, rules and version metadata as UTF-8 with deterministic ordering and line endings. Compute SHA-256 over canonical content at deployment; do not substitute an invented hash.
FLOW_HASH_ALGORITHM: SHA-256
FLOW_HASH_VALUE: COMPUTE_ON_PUBLICATION
15. AI_CONSUMPTION
Expose typed mode_set (array, never assumed scalar), method (empirical/weighted/PMF/density/grouped), tie_count, maximum_frequency where applicable, domain, dataset_size, missing_policy, provenance and validation_status. Require explicit clarification when the requested meaning of "mode" is ambiguous. Never infer a unique mode from tied data.
END FLOW ALGEBRA