/** * Anomaly injection — `anomaly="p"` on a numeric ``. * * With probability `p` a value is turned into an OUTLIER: multiplied by * `anomaly_factor` (default 10), so it lands far outside the normal range. One * PRNG draw per row → deterministic and seekable, both engines (same wrapper as * `missing`). Useful for stress-testing pipelines and detectors against spikes. * * v1 injects the outliers; a ground-truth label column (which rows are * anomalous) is the next iteration — it needs sequence-level plumbing so a * companion `_anomaly` flag stays consistent across both engines. */ export interface AnomalySpec { /** Probability in [0, 1] a value becomes an outlier. */ readonly p: number; /** Multiplier applied to a value that is selected as an outlier. */ readonly factor: number; } /** Parse `anomaly` / `anomaly_factor`; `undefined` when no `anomaly` is set. Throws on bad input. */ export declare function parseAnomaly(attrs: Record): AnomalySpec | undefined; /** * Turn each selected value into an outlier (× `factor`), one PRNG draw per row. * Non-numeric values are left untouched (outliers only make sense for numbers). * Mutates and returns `values`. * * `flagsOut`, when given, records what ACTUALLY HAPPENED to the row, so an * `anomaly_flag` column is ground truth rather than a record of intent. * * It used to record the SELECTION (`draw < p`) on the reasoning that anomaly is a * numeric-only feature, so selected == spiked. That holds only for the gens whose * output is numeric by construction. A `type="template"` column of surnames is * selected like any other and then left alone here — and came out flagged `true` * beside an untouched ordinary name, while the page promised the flag and the * spike "can never disagree". A label that marks a row nothing happened to is * worse than no label: it is training data for an anomaly detector, and every * such row teaches it something false. * * `draw` is asked for the uniform of row i rather than for "the next" one: the * streaming engine derives it from the row, and the in-memory engine passes a * closure over its own PRNG. Same rows selected either way. */ export declare function applyAnomaly(values: string[], spec: AnomalySpec, draw: (i: number) => number, flagsOut?: boolean[]): string[]; /** * The spike keeps the SHAPE of the value it replaced. * * Multiplying and re-stringifying threw away everything the column had already * been rendered with — the zero padding `length=` asked for, and the decimal * places `decimals=` asked for — so the outlier rows were the only ones in the * file with a different shape: * * length="5" 00014 00046 00053 … and then 117 * decimals="2" 85.66 40.97 11.52 … and then 6.445 * * That is worse than it looks. A column of fixed-width identifiers stops being * fixed width on exactly the rows a test is about to exercise, and a column * declared with `decimals` is typed a float in Parquet — a spike with a third * place is a value the declared type never promised. An outlier is meant to be * far from the others in VALUE, not in format. * * So: the same number of decimal places, and at least the same digit width. The * padding only ever adds, so a spike that genuinely outgrew the width keeps its * extra digits — which is the whole point of one. */ export declare function keepShape(original: string, spiked: number): string; //# sourceMappingURL=anomaly.d.ts.map