/** * @license * Copyright (c) 2025 Handsoncode. All rights reserved. */ import { ProcedureAst } from '../../parser'; import { InterpreterState } from '../InterpreterState'; import { InterpreterValue } from '../InterpreterValue'; import { FunctionPlugin, FunctionPluginTypecheck, ImplementedFunctions } from './FunctionPlugin'; /** * Interpreter plugin for percentile and quartile statistical functions. * * Implements inclusive (INC) and exclusive (EXC) interpolation variants. * QUARTILE functions delegate to PERCENTILE by converting quart index to * a percentile fraction (quart / 4) after truncating to integer. */ export declare class PercentilePlugin extends FunctionPlugin implements FunctionPluginTypecheck { static implementedFunctions: ImplementedFunctions; static aliases: { PERCENTILE: string; QUARTILE: string; }; /** * Corresponds to PERCENTILE(array, k) and PERCENTILE.INC(array, k). * * Returns the k-th percentile of values in a range using inclusive interpolation. * * @param ast - procedure AST node * @param state - interpreter state * @returns interpolated percentile value, or CellError on invalid input */ percentile(ast: ProcedureAst, state: InterpreterState): InterpreterValue; /** * Corresponds to PERCENTILE.EXC(array, k). * * Returns the k-th percentile of values in a range using exclusive interpolation. * * @param ast - procedure AST node * @param state - interpreter state * @returns interpolated percentile value, or CellError on invalid input */ percentileExc(ast: ProcedureAst, state: InterpreterState): InterpreterValue; /** * Corresponds to QUARTILE(array, quart) and QUARTILE.INC(array, quart). * * Returns the quartile of a data set using inclusive interpolation. * quart is truncated to an integer and validated in [0, 4]. * * @param ast - procedure AST node * @param state - interpreter state * @returns quartile value, or CellError on invalid input */ quartile(ast: ProcedureAst, state: InterpreterState): InterpreterValue; /** * Corresponds to QUARTILE.EXC(array, quart). * * Returns the quartile of a data set using exclusive interpolation. * quart is truncated to an integer and validated in [1, 3]. * * @param ast - procedure AST node * @param state - interpreter state * @returns quartile value, or CellError on invalid input */ quartileExc(ast: ProcedureAst, state: InterpreterState): InterpreterValue; /** * Extracts numeric values from a range, filters non-numbers, and returns them sorted. * Returns CellError if the range contains an error, or if no numeric values exist. * * @param range - input range from the spreadsheet * @returns sorted numeric values (ascending), or CellError */ private getSortedValues; }