/** * UncertaintyQuantification — Stochastic wrapper around ExperimentOrchestrator. * * Performs uncertainty propagation via Latin Hypercube Sampling over uncertain * input parameters, runs an ensemble of solver evaluations, and computes * probability distributions (mean, variance, confidence intervals, percentiles, * CDFs) on every output field quantity. * * Implements SimSolver so it can be used anywhere a regular solver is expected: * - `solve()` runs the full UQ ensemble * - `getField(name)` returns the **mean** field (best estimate) * - `getStats()` returns full distributional statistics * * @see ExperimentOrchestrator — underlying parameter sweep engine * @see ParameterSpace — Latin Hypercube Sampling implementation * @see SimSolver — generic solver interface this implements */ import type { SimSolver, SolverMode, FieldData } from './SimSolver'; import { type ExperimentResult, type SolverHandle } from './experiment/ExperimentOrchestrator'; import type { ParameterRange } from './experiment/ParameterSpace'; import { ProvenanceTracker } from './provenance/index'; /** Statistical distribution for a single scalar quantity. */ export interface ScalarDistribution { /** Number of ensemble samples */ n: number; /** Sample mean */ mean: number; /** Sample standard deviation */ std: number; /** Sample variance */ variance: number; /** Coefficient of variation (std / |mean|, or Infinity if mean ≈ 0) */ cov: number; /** Minimum observed value */ min: number; /** Maximum observed value */ max: number; /** Percentile values: p5, p25 (Q1), p50 (median), p75 (Q3), p95 */ percentiles: { p5: number; p25: number; p50: number; p75: number; p95: number; }; /** Confidence interval at the configured level (default 95%) */ confidenceInterval: { lower: number; upper: number; level: number; }; /** Skewness (Fisher's definition) */ skewness: number; /** Excess kurtosis */ kurtosis: number; } /** Statistical distribution for a field (per-node/per-cell array). */ export interface FieldDistribution { /** Field name */ name: string; /** Number of ensemble samples contributing */ n: number; /** Mean value at each node/cell */ mean: Float64Array; /** Standard deviation at each node/cell */ std: Float64Array; /** Lower bound of confidence interval at each node/cell */ ciLower: Float64Array; /** Upper bound of confidence interval at each node/cell */ ciUpper: Float64Array; /** Confidence level used (e.g. 0.95) */ ciLevel: number; /** Coefficient of variation at each node/cell */ cov: Float64Array; /** Per-node percentiles: p5, p50, p95 */ percentiles: { p5: Float64Array; p50: Float64Array; p95: Float64Array; }; } /** Configuration for the UQ analysis. */ export interface UQConfig { /** Human-readable name */ name: string; /** Base solver config (deterministic parameters) */ baseConfig: Record; /** Solver type identifier */ solverType: string; /** Uncertain parameters with their ranges (treated as uniform distributions) */ uncertainParameters: ParameterRange[]; /** Number of LHS samples (default: 50) */ sampleCount?: number; /** PRNG seed for reproducibility (default: 42) */ seed?: number; /** Confidence level for intervals: 0 < level < 1 (default: 0.95) */ confidenceLevel?: number; /** Max concurrent solver runs (default: 1) */ concurrency?: number; /** Field names to collect full distributions for (default: all available) */ fieldNames?: string[]; /** Scalar stat keys to extract from solver stats (default: all numeric) */ scalarKeys?: string[]; /** Progress callback */ onProgress?: (completed: number, total: number) => void; } /** Full UQ results. */ export interface UQResult { /** Config used */ config: UQConfig; /** Number of ensemble runs completed */ ensembleSize: number; /** Scalar distributions keyed by stat name */ scalarDistributions: Map; /** Field distributions keyed by field name */ fieldDistributions: Map; /** Fraction of runs that converged */ convergenceRate: number; /** Underlying experiment result (for further analysis) */ experimentResult: ExperimentResult; /** Total wall-clock time */ totalTimeMs: number; } /** Extension of SolverHandle that also exposes fields for UQ collection. */ export interface UQSolverHandle extends SolverHandle { /** Available field names */ fieldNames?: readonly string[]; /** Retrieve a named field */ getField?(name: string): FieldData | null; } export declare class UncertaintyQuantification implements SimSolver { readonly mode: SolverMode; private config; private solverFactory; private tracker; private result; private meanFields; private solved; get fieldNames(): readonly string[]; /** * @param config — UQ configuration * @param solverFactory — Creates solver handles that support field extraction * @param tracker — Optional provenance tracker */ constructor(config: UQConfig, solverFactory: (type: string, config: Record) => UQSolverHandle, tracker?: ProvenanceTracker); /** * Run the full UQ ensemble analysis. * * 1. Generates LHS samples across uncertain parameter space * 2. Runs each sample through the solver * 3. Collects field data and scalar stats from every run * 4. Computes per-field and per-scalar probability distributions */ solve(): Promise; /** No-op — UQ is always steady-state (ensemble solve). */ step(_dt: number): void; /** * Returns the **mean** field as the best estimate. * Returns a Float64Array (not Float32Array) for precision. */ getField(name: string): FieldData | null; /** * Returns UQ summary statistics. * Includes convergence rate, ensemble size, and flattened scalar distributions. */ getStats(): Record; /** Get full UQ results (only available after solve()). */ getResult(): UQResult | null; /** Get distribution for a specific scalar quantity. */ getScalarDistribution(key: string): ScalarDistribution | null; /** Get distribution for a specific field. */ getFieldDistribution(name: string): FieldDistribution | null; /** Get the underlying provenance tracker. */ getTracker(): ProvenanceTracker; dispose(): void; } /** * Compute full distributional statistics for a scalar sample. */ export declare function computeScalarDistribution(values: number[], confidenceLevel?: number): ScalarDistribution; /** * Compute per-node distributional statistics for an ensemble of field arrays. */ export declare function computeFieldDistribution(name: string, samples: Float64Array[], confidenceLevel?: number): FieldDistribution; //# sourceMappingURL=UncertaintyQuantification.d.ts.map