/** * Maximum-likelihood distribution fitting (Phase 4 Task 1). * * `fitDistribution(name, data)` fits one of five common distributions to a * sample by maximum likelihood and reports the fitted parameters plus the * achieved log-likelihood. * * - `normal` — closed form: mu = mean, sigma = population std (ddof=0). * - `exponential` — closed form: lambda = 1 / mean. * - `lognormal` — fit a normal to ln(data) (requires all data > 0). * - `poisson` — closed form: lambda = mean. * - `gamma` — no closed form for the shape parameter. Given shape k, * the MLE scale is theta = xbar / k; substituting back yields the * 1-D shape equation `ln(k) - psi(k) = ln(xbar) - mean(ln x)` * (psi = digamma), solved here with the secant method starting from the * Choi & Wette (1969) initial guess. * * @packageDocumentation */ /** Supported distribution families for {@link fitDistribution}. */ export type DistributionName = 'normal' | 'exponential' | 'lognormal' | 'poisson' | 'gamma'; /** Result of {@link fitDistribution}: fitted parameters + achieved log-likelihood. */ export interface FitDistributionResult { /** Fitted parameters, named per distribution (see {@link fitDistribution}). */ params: Record; /** Log-likelihood of `data` under the fitted parameters. */ logLikelihood: number; } /** * Fit a distribution to `data` by maximum likelihood. * * @param name - Distribution family: 'normal' | 'exponential' | 'lognormal' | 'poisson' | 'gamma' * @param data - Sample data * @returns Fitted parameters and the log-likelihood achieved under them * * @example * fitDistribution('normal', [2, 4, 4, 4, 5, 5, 7, 9]); * // { params: { mean: 5, std: 2 }, logLikelihood: ... } * * fitDistribution('exponential', [1, 2, 3, 2]); * // { params: { lambda: 0.5 }, logLikelihood: ... } */ export declare function fitDistribution(name: DistributionName, data: readonly number[]): FitDistributionResult; //# sourceMappingURL=fit-distribution.d.ts.map