import type { FieldStats } from './program-stats'; export declare function fieldStatsToJSON(stats: FieldStats): unknown; export declare function fieldStatsFromJSON(json: unknown): FieldStats; /** * Total Variation distance between two discrete probability distributions. * TV(P, Q) = 0.5 * sum_x |P(x) - Q(x)| * Result is in [0, 1]. 0 means identical; 1 means disjoint support. */ export declare function totalVariationDistance(a: Map, b: Map): number; /** * KL divergence D(a || b) = sum_x a(x) * log(a(x) / b(x)). * Terms with a(x) = 0 contribute 0 (convention 0*log(0) = 0). * Returns `Infinity` if any x has a(x) > 0 but b(x) = 0 (undefined in that case). */ export declare function klDivergence(a: Map, b: Map): number; /** * Probability that X > Y where X has distribution `a` and Y has distribution `b`, * assuming independence. */ export declare function probabilityGreaterThan(a: Map, b: Map): number; /** * Probability that X < Y for independent X ~ `a`, Y ~ `b`. */ export declare function probabilityLessThan(a: Map, b: Map): number; /** * Probability that X == Y for independent X ~ `a`, Y ~ `b`. */ export declare function probabilityEqual(a: Map, b: Map): number; /** * Box plot data for a numeric distribution: quartiles, whiskers, outliers. * Uses the standard 1.5*IQR rule for whisker extents, clamped to the actual * minimum and maximum values present in the distribution. */ export interface BoxPlotData { min: number; q1: number; median: number; q3: number; max: number; iqr: number; /** q1 - 1.5 * iqr, clamped to the smallest value with nonzero probability. */ lowerWhisker: number; /** q3 + 1.5 * iqr, clamped to the largest value with nonzero probability. */ upperWhisker: number; /** Values with nonzero probability that fall outside the whisker range, sorted. */ outliers: number[]; } /** * Compute box-plot data for a numeric distribution. Quartiles use the * "first value with cumulative probability >= p" rule (matches * `program-stats`' `percentileFromCdf`). For empty or invalid distributions, * throws. */ export declare function boxPlotData(dist: Map): BoxPlotData; /** * Sample `n` values from a numeric discrete distribution using the provided * `rng` (defaults to `Math.random`). Uses cumulative inverse method: builds a * sorted CDF once, then for each sample generates a uniform and binary-searches * for the first bucket whose CDF is >= the uniform sample. */ export declare function sampleFromDistribution(dist: Map, n: number, rng?: () => number): number[]; /** * Return the stats for a specific field within a record FieldStats, * or `undefined` if `stats` is not a record or the field is not present. * * Note: this is a projection to a marginal — joint information across * fields is not preserved by `FieldStats`, so this is strictly a convenience * accessor, not a true conditional. */ export declare function fieldFromRecord(stats: FieldStats, fieldName: string): FieldStats | undefined; /** * Return the stats for a specific element index within an array FieldStats, * or `undefined` if `stats` is not an array or the index is out of range. */ export declare function elementFromArray(stats: FieldStats, index: number): FieldStats | undefined;