@danielsimonjr/mathts-functions 0.70.1 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -1
- package/dist/algebra/decomposition/qr.d.ts.map +1 -1
- package/dist/cas/real-roots.d.ts +30 -0
- package/dist/cas/real-roots.d.ts.map +1 -0
- package/dist/descriptive-stats.d.ts +1 -1
- package/dist/descriptive-stats.d.ts.map +1 -1
- package/dist/factories/evaluate.d.ts.map +1 -1
- package/dist/factories/index.d.ts +3 -3
- package/dist/factories/index.d.ts.map +1 -1
- package/dist/fit-scalar.d.ts +28 -0
- package/dist/fit-scalar.d.ts.map +1 -1
- package/dist/geometry/curves.d.ts +48 -0
- package/dist/geometry/curves.d.ts.map +1 -0
- package/dist/geometry/polygon-ops.d.ts +19 -0
- package/dist/geometry/polygon-ops.d.ts.map +1 -0
- package/dist/geometry/predicates.d.ts +38 -0
- package/dist/geometry/predicates.d.ts.map +1 -0
- package/dist/index.d.ts +53 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5495 -892
- package/dist/linalg-extra2.d.ts +36 -0
- package/dist/linalg-extra2.d.ts.map +1 -0
- package/dist/linalg-special-matrices.d.ts +62 -0
- package/dist/linalg-special-matrices.d.ts.map +1 -0
- package/dist/numbertheory/arithmetic-functions.d.ts +50 -0
- package/dist/numbertheory/arithmetic-functions.d.ts.map +1 -0
- package/dist/numbertheory/diophantine.d.ts +43 -0
- package/dist/numbertheory/diophantine.d.ts.map +1 -0
- package/dist/numbertheory/extra.d.ts +12 -6
- package/dist/numbertheory/extra.d.ts.map +1 -1
- package/dist/numbertheory/integer-matrices.d.ts +26 -0
- package/dist/numbertheory/integer-matrices.d.ts.map +1 -0
- package/dist/numbertheory/modular.d.ts +27 -0
- package/dist/numbertheory/modular.d.ts.map +1 -0
- package/dist/numbertheory/sequences.d.ts +36 -0
- package/dist/numbertheory/sequences.d.ts.map +1 -0
- package/dist/numeric/constrained.d.ts +42 -0
- package/dist/numeric/constrained.d.ts.map +1 -0
- package/dist/numeric/finite-differences.d.ts +54 -0
- package/dist/numeric/finite-differences.d.ts.map +1 -0
- package/dist/numeric/gauss-nodes-extra.d.ts +73 -0
- package/dist/numeric/gauss-nodes-extra.d.ts.map +1 -0
- package/dist/numeric/global-optimizers.d.ts +64 -0
- package/dist/numeric/global-optimizers.d.ts.map +1 -0
- package/dist/numeric/quadrature-extra.d.ts +64 -0
- package/dist/numeric/quadrature-extra.d.ts.map +1 -0
- package/dist/numeric/solveODE.d.ts +29 -4
- package/dist/numeric/solveODE.d.ts.map +1 -1
- package/dist/probability/combinations.d.ts.map +1 -1
- package/dist/regression-extra.d.ts +6 -0
- package/dist/regression-extra.d.ts.map +1 -1
- package/dist/scalar-batch-parallel.d.ts +15 -9
- package/dist/scalar-batch-parallel.d.ts.map +1 -1
- package/dist/scalar-batch-parallel.js +108 -0
- package/dist/{scalar-batch-task-CZd6LPg9.js → scalar-batch-task-DApUqK6j.js} +21 -15
- package/dist/scalar-batch.worker.js +1 -1
- package/dist/scalar-compile.d.ts +4 -4
- package/dist/scalar-compile.d.ts.map +1 -1
- package/dist/scalar-dimension.d.ts +25 -0
- package/dist/scalar-dimension.d.ts.map +1 -1
- package/dist/scalar-eval.d.ts +4 -2
- package/dist/scalar-eval.d.ts.map +1 -1
- package/dist/scalar-node-bridge.d.ts.map +1 -1
- package/dist/scalar-search.d.ts +323 -14
- package/dist/scalar-search.d.ts.map +1 -1
- package/dist/signal/dtw.d.ts +32 -0
- package/dist/signal/dtw.d.ts.map +1 -0
- package/dist/signal/freqz.d.ts +17 -2
- package/dist/signal/freqz.d.ts.map +1 -1
- package/dist/signal/lomb-scargle.d.ts +25 -0
- package/dist/signal/lomb-scargle.d.ts.map +1 -0
- package/dist/signal/system-response.d.ts +82 -0
- package/dist/signal/system-response.d.ts.map +1 -0
- package/dist/signal/waveforms.d.ts +52 -0
- package/dist/signal/waveforms.d.ts.map +1 -0
- package/dist/signal/windows-extra.d.ts +52 -0
- package/dist/signal/windows-extra.d.ts.map +1 -0
- package/dist/signal/zpk2tf.d.ts +22 -2
- package/dist/signal/zpk2tf.d.ts.map +1 -1
- package/dist/special/angular-momentum.d.ts +38 -0
- package/dist/special/angular-momentum.d.ts.map +1 -0
- package/dist/special/erf-extra.d.ts +47 -0
- package/dist/special/erf-extra.d.ts.map +1 -0
- package/dist/special/exp-integrals.d.ts +38 -0
- package/dist/special/exp-integrals.d.ts.map +1 -0
- package/dist/special/spherical-bessel.d.ts +28 -0
- package/dist/special/spherical-bessel.d.ts.map +1 -0
- package/dist/special/zeta-extra.d.ts +36 -0
- package/dist/special/zeta-extra.d.ts.map +1 -0
- package/dist/stats/distances.d.ts +28 -0
- package/dist/stats/distances.d.ts.map +1 -0
- package/dist/stats/distributions-extra.d.ts +36 -0
- package/dist/stats/distributions-extra.d.ts.map +1 -0
- package/dist/stats/effect-sizes.d.ts +21 -0
- package/dist/stats/effect-sizes.d.ts.map +1 -0
- package/dist/stats/nonparametric-extra.d.ts +52 -0
- package/dist/stats/nonparametric-extra.d.ts.map +1 -0
- package/dist/stats/robust-stats.d.ts +38 -0
- package/dist/stats/robust-stats.d.ts.map +1 -0
- package/dist/stats/weighted-stats.d.ts +27 -0
- package/dist/stats/weighted-stats.d.ts.map +1 -0
- package/dist/typed/algebra.d.ts +7 -3
- package/dist/typed/algebra.d.ts.map +1 -1
- package/dist/typed/cas.d.ts +2 -0
- package/dist/typed/cas.d.ts.map +1 -1
- package/dist/typed/hypothesis.d.ts.map +1 -1
- package/dist/typed/probability.d.ts.map +1 -1
- package/dist/typed/signal.d.ts.map +1 -1
- package/dist/typed/special.d.ts.map +1 -1
- package/dist/typed/statistics.d.ts.map +1 -1
- package/dist/wasm/sort/wasm-bridge.d.ts +3 -13
- package/dist/wasm/sort/wasm-bridge.d.ts.map +1 -1
- package/dist/wasm/special/scalars.d.ts +27 -0
- package/dist/wasm/special/scalars.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test waveform generators (scipy.signal.waveforms parity).
|
|
3
|
+
*
|
|
4
|
+
* Phase offsets `phi` are in radians (scipy takes degrees for chirp/sweep_poly).
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
type Vec = readonly number[] | Float64Array;
|
|
9
|
+
/** Frequency sweep method for {@link chirp}. */
|
|
10
|
+
export type ChirpMethod = 'linear' | 'quadratic' | 'logarithmic' | 'hyperbolic';
|
|
11
|
+
/** Options for {@link chirp}. */
|
|
12
|
+
export interface ChirpOptions {
|
|
13
|
+
/** Sweep law (default `'linear'`). */
|
|
14
|
+
method?: ChirpMethod;
|
|
15
|
+
/** Phase offset in radians (default 0). */
|
|
16
|
+
phi?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Cosine chirp sweeping from f0 at t = 0 to f1 at t = t1 (frequencies in Hz).
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* chirp([0], 1, 1, 10); // [1]
|
|
23
|
+
*/
|
|
24
|
+
export declare function chirp(t: Vec, f0: number, t1: number, f1: number, opts?: ChirpOptions): number[];
|
|
25
|
+
/**
|
|
26
|
+
* Square wave: +1 while frac(t / 2 pi) < duty, otherwise -1.
|
|
27
|
+
*/
|
|
28
|
+
export declare function squareWave(t: Vec, duty?: number): number[];
|
|
29
|
+
/**
|
|
30
|
+
* Sawtooth wave: -1 at phase 0 rising to +1 at phase 2 pi * width, then falling
|
|
31
|
+
* back. `width = 1` is a rising ramp; `width = 0.5` is a triangle.
|
|
32
|
+
*/
|
|
33
|
+
export declare function sawtooth(t: Vec, width?: number): number[];
|
|
34
|
+
/**
|
|
35
|
+
* Gaussian-modulated cosine pulse.
|
|
36
|
+
*
|
|
37
|
+
* @param fc - Centre frequency (Hz)
|
|
38
|
+
* @param bw - Fractional bandwidth (default 0.5)
|
|
39
|
+
* @param bwr - Reference level in dB for the bandwidth (default -6)
|
|
40
|
+
*/
|
|
41
|
+
export declare function gaussPulse(t: Vec, fc: number, bw?: number, bwr?: number): number[];
|
|
42
|
+
/**
|
|
43
|
+
* Discrete unit impulse of length n. `idx` defaults to 0, `'mid'` is floor(n / 2).
|
|
44
|
+
*/
|
|
45
|
+
export declare function unitImpulse(n: number, idx?: number | 'mid'): number[];
|
|
46
|
+
/**
|
|
47
|
+
* Cosine with a polynomial instantaneous frequency f(t) = sum_k c_k t^(p-k) Hz.
|
|
48
|
+
* `polyCoeffs` are highest-order first (numpy poly1d order).
|
|
49
|
+
*/
|
|
50
|
+
export declare function sweepPoly(t: Vec, polyCoeffs: readonly number[], phi?: number): number[];
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=waveforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waveforms.d.ts","sourceRoot":"","sources":["../../src/signal/waveforms.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,KAAK,GAAG,GAAG,SAAS,MAAM,EAAE,GAAG,YAAY,CAAC;AAI5C,gDAAgD;AAChD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,aAAa,GAAG,YAAY,CAAC;AAEhF,iCAAiC;AACjC,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,2CAA2C;IAC3C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,MAAM,EAAE,CAM/F;AAuCD;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,GAAE,MAAY,GAAG,MAAM,EAAE,CAM/D;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM,EAAE,CAO5D;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,GAAE,MAAY,EAAE,GAAG,GAAE,MAAW,GAAG,MAAM,EAAE,CAI3F;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,GAAG,KAAS,GAAG,MAAM,EAAE,CASxE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,GAAE,MAAU,GAAG,MAAM,EAAE,CAW1F"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extra window functions (scipy.signal.windows parity).
|
|
3
|
+
*
|
|
4
|
+
* Every window takes `opts.sym` (default `true`, symmetric). `sym: false` builds
|
|
5
|
+
* the periodic variant (length n+1, last sample dropped), as scipy does.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/** Window names accepted by {@link getWindow}. */
|
|
10
|
+
export type ExtraWindowName = 'kaiser' | 'gaussian' | 'tukey' | 'blackmanharris' | 'nuttall' | 'flattop' | 'bohman' | 'parzen' | 'cosine' | 'exponential';
|
|
11
|
+
/** Options shared by the window constructors. */
|
|
12
|
+
export interface WindowOptions {
|
|
13
|
+
/** Symmetric window (default `true`). `false` gives the periodic variant. */
|
|
14
|
+
sym?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Kaiser window with shape parameter beta (beta = 0 gives a rectangular window).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* kaiserWindow(5, 0); // [1, 1, 1, 1, 1]
|
|
21
|
+
*/
|
|
22
|
+
export declare function kaiserWindow(n: number, beta: number, opts?: WindowOptions): number[];
|
|
23
|
+
/** Gaussian window with standard deviation `std` (in samples). */
|
|
24
|
+
export declare function gaussianWindow(n: number, std: number, opts?: WindowOptions): number[];
|
|
25
|
+
/**
|
|
26
|
+
* Tukey (tapered cosine) window. alpha = 0 gives rectangular, alpha = 1 gives Hann.
|
|
27
|
+
*/
|
|
28
|
+
export declare function tukeyWindow(n: number, alpha?: number, opts?: WindowOptions): number[];
|
|
29
|
+
/** Blackman-Harris 4-term window (scipy coefficients). */
|
|
30
|
+
export declare function blackmanHarrisWindow(n: number, opts?: WindowOptions): number[];
|
|
31
|
+
/** Nuttall 4-term window. */
|
|
32
|
+
export declare function nuttallWindow(n: number, opts?: WindowOptions): number[];
|
|
33
|
+
/** Flat-top 5-term window (scipy coefficients). */
|
|
34
|
+
export declare function flattopWindow(n: number, opts?: WindowOptions): number[];
|
|
35
|
+
/** Bohman window (zero at both ends). */
|
|
36
|
+
export declare function bohmanWindow(n: number, opts?: WindowOptions): number[];
|
|
37
|
+
/** Parzen window (piecewise cubic). */
|
|
38
|
+
export declare function parzenWindow(n: number, opts?: WindowOptions): number[];
|
|
39
|
+
/** Cosine (half-sine) window: sin(pi (i + 0.5) / M). */
|
|
40
|
+
export declare function cosineWindow(n: number, opts?: WindowOptions): number[];
|
|
41
|
+
/**
|
|
42
|
+
* Exponential (two-sided) window exp(-|i - center| / tau), centred on (M-1)/2.
|
|
43
|
+
*/
|
|
44
|
+
export declare function exponentialWindow(n: number, tau: number, opts?: WindowOptions): number[];
|
|
45
|
+
/**
|
|
46
|
+
* Build a window by name. `param` is beta (kaiser, default 0), std (gaussian,
|
|
47
|
+
* default 1), alpha (tukey, default 0.5) or tau (exponential, default 1). The
|
|
48
|
+
* classic names (hamming, hann, blackman, bartlett, rectangular) delegate to
|
|
49
|
+
* {@link windowFunction} and are always symmetric.
|
|
50
|
+
*/
|
|
51
|
+
export declare function getWindow(name: ExtraWindowName | 'hamming' | 'hann' | 'blackman' | 'bartlett' | 'rectangular', n: number, param?: number): number[];
|
|
52
|
+
//# sourceMappingURL=windows-extra.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windows-extra.d.ts","sourceRoot":"","sources":["../../src/signal/windows-extra.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,kDAAkD;AAClD,MAAM,MAAM,eAAe,GACvB,QAAQ,GACR,UAAU,GACV,OAAO,GACP,gBAAgB,GAChB,SAAS,GACT,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,aAAa,CAAC;AAElB,iDAAiD;AACjD,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAmCD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAWpF;AAED,kEAAkE;AAClE,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAWrF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,MAAY,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAoB1F;AAED,0DAA0D;AAC1D,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAE9E;AAED,6BAA6B;AAC7B,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAEvE;AAED,mDAAmD;AACnD,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAIvE;AAED,yCAAyC;AACzC,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAStE;AAED,uCAAuC;AACvC,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAYtE;AAED,wDAAwD;AACxD,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAItE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAMxF;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,eAAe,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,aAAa,EACpF,CAAC,EAAE,MAAM,EACT,KAAK,CAAC,EAAE,MAAM,GACb,MAAM,EAAE,CA+BV"}
|
package/dist/signal/zpk2tf.d.ts
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
import type { TypedFunction } from '../types.js';
|
|
2
|
-
|
|
1
|
+
import type { Matrix, Complex, TypedFunction } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Transfer function representation [numerator, denominator]
|
|
4
|
+
*/
|
|
5
|
+
export type TransferFunction = [Complex[], Complex[]];
|
|
6
|
+
/**
|
|
7
|
+
* Zero, pole, or gain value (can be number, Complex, or BigNumber)
|
|
8
|
+
*/
|
|
9
|
+
export type ZPKValue = number | Complex | {
|
|
10
|
+
type: string;
|
|
11
|
+
re?: number;
|
|
12
|
+
im?: number;
|
|
13
|
+
};
|
|
14
|
+
/** Call signatures of `zpk2tf` (zeros, poles, optional gain defaulting to 1). */
|
|
15
|
+
interface Zpk2tfOverloads {
|
|
16
|
+
(z: ZPKValue[], p: ZPKValue[], k?: number): TransferFunction;
|
|
17
|
+
(z: Matrix, p: Matrix, k?: number): TransferFunction;
|
|
18
|
+
}
|
|
19
|
+
/** `zpk2tf` with its precise call signatures; still a `TypedFunction`. */
|
|
20
|
+
export type Zpk2tfFunction = Zpk2tfOverloads & TypedFunction;
|
|
21
|
+
export declare const createZpk2tf: import("../utils/factory.js").FactoryFunction<any, Zpk2tfFunction>;
|
|
22
|
+
export {};
|
|
3
23
|
//# sourceMappingURL=zpk2tf.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zpk2tf.d.ts","sourceRoot":"","sources":["../../src/signal/zpk2tf.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"zpk2tf.d.ts","sourceRoot":"","sources":["../../src/signal/zpk2tf.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMlE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErF,iFAAiF;AACjF,UAAU,eAAe;IACvB,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;IAC7D,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACtD;AAED,0EAA0E;AAC1E,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,aAAa,CAAC;AAE7D,eAAO,MAAM,YAAY,oEAiHxB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular-momentum coupling (Wigner 3j, Clebsch–Gordan, Wigner 6j) via the Racah
|
|
3
|
+
* formulas, and spherical harmonics with the Condon–Shortley phase.
|
|
4
|
+
*
|
|
5
|
+
* All angular momenta may be integers or half-integers. Inputs that are not
|
|
6
|
+
* multiples of ½ raise `RangeError`; selection-rule violations return 0.
|
|
7
|
+
*/
|
|
8
|
+
import { Complex } from '@danielsimonjr/mathts-core';
|
|
9
|
+
/**
|
|
10
|
+
* Wigner 3j symbol `(j1 j2 j3; m1 m2 m3)` by the Racah formula.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* wigner3j(1, 1, 0, 0, 0, 0) // -0.5773502691896258
|
|
14
|
+
*/
|
|
15
|
+
export declare function wigner3j(j1: number, j2: number, j3: number, m1: number, m2: number, m3: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Clebsch–Gordan coefficient `⟨j1 m1; j2 m2 | J M⟩`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* clebschGordan(1, 0, 1, 0, 2, 0) // 0.816496580927726
|
|
21
|
+
*/
|
|
22
|
+
export declare function clebschGordan(j1: number, m1: number, j2: number, m2: number, J: number, M: number): number;
|
|
23
|
+
/**
|
|
24
|
+
* Wigner 6j symbol `{j1 j2 j3; j4 j5 j6}` by the Racah formula.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* wigner6j(1, 1, 1, 1, 1, 1) // 1/6
|
|
28
|
+
*/
|
|
29
|
+
export declare function wigner6j(j1: number, j2: number, j3: number, j4: number, j5: number, j6: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* Spherical harmonic `Y_l^m(θ, φ)` with the Condon–Shortley phase.
|
|
32
|
+
* `θ` is the polar angle and `φ` the azimuth. Returns zero when `|m| > l`.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* sphericalHarmonic(0, 0, 0.3, 1.2) // re 0.28209479177387814, im 0
|
|
36
|
+
*/
|
|
37
|
+
export declare function sphericalHarmonic(l: number, m: number, theta: number, phi: number): Complex;
|
|
38
|
+
//# sourceMappingURL=angular-momentum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-momentum.d.ts","sourceRoot":"","sources":["../../src/special/angular-momentum.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAiCrD;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACT,MAAM,CAkCR;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACT,MAAM,CAgDR;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAe3F"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inverse and scaled error functions, and Dawson's integral.
|
|
3
|
+
*
|
|
4
|
+
* - `erfinv` / `erfcinv`: Newton iteration seeded from `normalQuantile`, with
|
|
5
|
+
* the complementary branch used for `|y| > 1/2` to avoid cancellation.
|
|
6
|
+
* - `erfcx`: scaled complementary error function `e^{x²} erfc(x)`.
|
|
7
|
+
* - `dawson`: Dawson's integral `F(x) = e^{-x²} ∫₀ˣ e^{t²} dt`.
|
|
8
|
+
*
|
|
9
|
+
* Scalar kernels only (number in, number out).
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Scaled complementary error function `erfcx(x) = e^{x²} erfc(x)`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* erfcx(0) // 1
|
|
16
|
+
* erfcx(1) // 0.42758357615580705
|
|
17
|
+
*/
|
|
18
|
+
export declare function erfcx(x: number): number;
|
|
19
|
+
/**
|
|
20
|
+
* Inverse error function: `erf(erfinv(y)) = y` for `y ∈ [−1, 1]`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* erfinv(0) // 0
|
|
24
|
+
* erfinv(0.5) // 0.4769362762044699
|
|
25
|
+
* erfinv(1) // Infinity
|
|
26
|
+
*/
|
|
27
|
+
export declare function erfinv(y: number): number;
|
|
28
|
+
/**
|
|
29
|
+
* Inverse complementary error function: `erfc(erfcinv(y)) = y` for `y ∈ [0, 2]`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* erfcinv(1) // 0
|
|
33
|
+
* erfcinv(0) // Infinity
|
|
34
|
+
*/
|
|
35
|
+
export declare function erfcinv(y: number): number;
|
|
36
|
+
/**
|
|
37
|
+
* Dawson's integral `F(x) = e^{-x²} ∫₀ˣ e^{t²} dt`.
|
|
38
|
+
*
|
|
39
|
+
* Uses the positive series `F(x) = e^{-x²} Σ x^{2n+1}/(n!(2n+1))` for |x| ≤ 25
|
|
40
|
+
* (no cancellation) and a four-term asymptotic expansion beyond.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* dawson(0) // 0
|
|
44
|
+
* dawson(1) // 0.5380795069127684
|
|
45
|
+
*/
|
|
46
|
+
export declare function dawson(x: number): number;
|
|
47
|
+
//# sourceMappingURL=erf-extra.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erf-extra.d.ts","sourceRoot":"","sources":["../../src/special/erf-extra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAmCH;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAKvC;AAiBD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAmBxC;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAOzC;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAoBxC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exponential-type integrals: E1 / E_n, Shi (sinh integral) and Chi (cosh integral).
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Generalized exponential integral `E_n(x) = ∫₁^∞ e^{-xt} t^{-n} dt`.
|
|
6
|
+
*
|
|
7
|
+
* - `n = 0`: `e^{-x}/x`.
|
|
8
|
+
* - `x ≤ 1`: E1 by its power series, then the (stable for x < 1) upward recurrence.
|
|
9
|
+
* - `x > 1`: continued fraction.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* expn(2, 1) // 0.14849550677592205
|
|
13
|
+
* expn(3, 0) // 0.5
|
|
14
|
+
*/
|
|
15
|
+
export declare function expn(n: number, x: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Exponential integral E1(x) for real x > 0 (`−Ei(−x)`). Returns Infinity at 0, NaN for x < 0.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* expIntegralE1(1) // 0.21938393439552029
|
|
21
|
+
*/
|
|
22
|
+
export declare function expIntegralE1(x: number): number;
|
|
23
|
+
/**
|
|
24
|
+
* Sinh integral `Shi(x) = ∫₀ˣ sinh(t)/t dt` (odd function).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* sinhIntegral(1) // 1.0572508753757285
|
|
28
|
+
*/
|
|
29
|
+
export declare function sinhIntegral(x: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* Cosh integral `Chi(x) = γ + ln x + ∫₀ˣ (cosh t − 1)/t dt` for x > 0.
|
|
32
|
+
* Returns −Infinity at 0 and NaN for x < 0.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* coshIntegral(1) // 0.8378669409802082
|
|
36
|
+
*/
|
|
37
|
+
export declare function coshIntegral(x: number): number;
|
|
38
|
+
//# sourceMappingURL=exp-integrals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exp-integrals.d.ts","sourceRoot":"","sources":["../../src/special/exp-integrals.ts"],"names":[],"mappings":"AAAA;;GAEG;AAyBH;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAoBjD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAI/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAe9C;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAc9C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spherical Bessel functions j_n, y_n, i_n, k_n, Hankel functions of real order,
|
|
3
|
+
* and the first positive zeros of J_ν.
|
|
4
|
+
*
|
|
5
|
+
* Conventions: `j_n(x) = √(π/2x) J_{n+1/2}(x)`, `y_n` likewise from Y, `i_n = √(π/2x) I_{n+1/2}(x)`,
|
|
6
|
+
* `k_n = √(π/2x) K_{n+1/2}(x)` (so `k_0(x) = (π/2) e^{-x}/x`).
|
|
7
|
+
*/
|
|
8
|
+
import { Complex } from '@danielsimonjr/mathts-core';
|
|
9
|
+
/** Spherical Bessel function of the first kind `j_n(x)`. */
|
|
10
|
+
export declare function sphericalBesselJ(n: number, x: number): number;
|
|
11
|
+
/** Spherical Bessel function of the second kind `y_n(x)`. */
|
|
12
|
+
export declare function sphericalBesselY(n: number, x: number): number;
|
|
13
|
+
/** Modified spherical Bessel function of the first kind `i_n(x)`. */
|
|
14
|
+
export declare function sphericalBesselI(n: number, x: number): number;
|
|
15
|
+
/** Modified spherical Bessel function of the second kind `k_n(x)`. */
|
|
16
|
+
export declare function sphericalBesselK(n: number, x: number): number;
|
|
17
|
+
/** Hankel function of the first kind `H¹_ν(x) = J_ν(x) + i Y_ν(x)`. */
|
|
18
|
+
export declare function hankelH1(nu: number, x: number): Complex;
|
|
19
|
+
/** Hankel function of the second kind `H²_ν(x) = J_ν(x) − i Y_ν(x)`. */
|
|
20
|
+
export declare function hankelH2(nu: number, x: number): Complex;
|
|
21
|
+
/**
|
|
22
|
+
* First `k` positive zeros of `J_ν(x)`, via McMahon's asymptotic guess refined by Newton.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* besselJZeros(0, 2) // [2.404825557695773, 5.520078110286311]
|
|
26
|
+
*/
|
|
27
|
+
export declare function besselJZeros(nu: number, k: number): number[];
|
|
28
|
+
//# sourceMappingURL=spherical-bessel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spherical-bessel.d.ts","sourceRoot":"","sources":["../../src/special/spherical-bessel.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AA4FrD,4DAA4D;AAC5D,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED,6DAA6D;AAC7D,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED,qEAAqE;AACrE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAIvD;AAED,wEAAwE;AACxE,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAIvD;AAYD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAkB5D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hurwitz zeta, Dirichlet eta, and Bernoulli / Euler polynomials.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Hurwitz zeta `ζ(s, a) = Σ_{k≥0} (k + a)^{−s}` for `s > 1`, `a > 0`, by Euler–Maclaurin
|
|
6
|
+
* with `N = 10` leading terms and eight Bernoulli correction terms. NaN outside the domain.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* hurwitzZeta(2, 1) // 1.6449340668482264
|
|
10
|
+
*/
|
|
11
|
+
export declare function hurwitzZeta(s: number, a: number): number;
|
|
12
|
+
/**
|
|
13
|
+
* Dirichlet eta function `η(s) = (1 − 2^{1−s}) ζ(s)`, all real s, by Borwein's
|
|
14
|
+
* alternating-series algorithm (n = 40, error below 1e-20 relative).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* dirichletEta(1) // 0.6931471805599453
|
|
18
|
+
* dirichletEta(2) // 0.8224670334241132
|
|
19
|
+
*/
|
|
20
|
+
export declare function dirichletEta(s: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* Bernoulli polynomial `B_n(x) = Σ_k C(n,k) B_k x^{n−k}` (with `B_1 = −1/2`).
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* bernoulliPolynomial(2, 0.5) // -0.08333333333333333
|
|
26
|
+
*/
|
|
27
|
+
export declare function bernoulliPolynomial(n: number, x: number): number;
|
|
28
|
+
/**
|
|
29
|
+
* Euler polynomial `E_n(x) = 2/(n+1) · (B_{n+1}(x) − 2^{n+1} B_{n+1}(x/2))`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* eulerPolynomial(2, 0.5) // -0.25
|
|
33
|
+
* eulerPolynomial(1, 0) // -0.5
|
|
34
|
+
*/
|
|
35
|
+
export declare function eulerPolynomial(n: number, x: number): number;
|
|
36
|
+
//# sourceMappingURL=zeta-extra.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zeta-extra.d.ts","sourceRoot":"","sources":["../../src/special/zeta-extra.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAoBxD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAuB9C;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAWhE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAM5D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Distances between samples and discrete information measures (gap-analysis
|
|
3
|
+
* 2026-11-04, Batch A).
|
|
4
|
+
*/
|
|
5
|
+
type Vec = readonly number[] | Float64Array;
|
|
6
|
+
/**
|
|
7
|
+
* 1-D Wasserstein (earth mover's) distance: ∫|F_u(t) − F_v(t)| dt, computed
|
|
8
|
+
* exactly over the merged support. Default weights are uniform.
|
|
9
|
+
*/
|
|
10
|
+
export declare function wassersteinDistance(u: Vec, v: Vec, opts?: {
|
|
11
|
+
uWeights?: Vec;
|
|
12
|
+
vWeights?: Vec;
|
|
13
|
+
}): number;
|
|
14
|
+
/**
|
|
15
|
+
* Energy distance √(2E|U−V| − E|U−U′| − E|V−V′|) using V-statistic means
|
|
16
|
+
* (diagonal pairs included).
|
|
17
|
+
*/
|
|
18
|
+
export declare function energyDistance(u: Vec, v: Vec): number;
|
|
19
|
+
/** Mutual information (nats) of two discrete label sequences. */
|
|
20
|
+
export declare function mutualInformation(x: readonly number[], y: readonly number[]): number;
|
|
21
|
+
/** Empirical CDF: step points and an `evaluate(t)` function (fraction of values ≤ t). */
|
|
22
|
+
export declare function ecdf(x: Vec): {
|
|
23
|
+
x: number[];
|
|
24
|
+
y: number[];
|
|
25
|
+
evaluate: (t: number) => number;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=distances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distances.d.ts","sourceRoot":"","sources":["../../src/stats/distances.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,KAAK,GAAG,GAAG,SAAS,MAAM,EAAE,GAAG,YAAY,CAAC;AAI5C;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,CAAC,EAAE,GAAG,EACN,CAAC,EAAE,GAAG,EACN,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAC;IAAC,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAE,GACxC,MAAM,CAwBR;AAgBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAWrD;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAoBpF;AAED,yFAAyF;AACzF,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG;IAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,CAyB1F"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Owen's T function T(h, a) = (1/2π)∫₀ᵃ exp(−h²(1+x²)/2)/(1+x²) dx.
|
|
3
|
+
*/
|
|
4
|
+
export declare function owensT(h: number, a: number): number;
|
|
5
|
+
/** Skew-normal PDF: 2φ(z)Φ(αz)/scale with z = (x − loc)/scale. */
|
|
6
|
+
export declare function skewNormalPDF(x: number, alpha: number, loc?: number, scale?: number): number;
|
|
7
|
+
/** Skew-normal CDF: Φ(z) − 2T(z, α). */
|
|
8
|
+
export declare function skewNormalCDF(x: number, alpha: number, loc?: number, scale?: number): number;
|
|
9
|
+
/** Truncated normal PDF on [a, b]. */
|
|
10
|
+
export declare function truncatedNormalPDF(x: number, a: number, b: number, mu?: number, sigma?: number): number;
|
|
11
|
+
/** Truncated normal CDF on [a, b]. */
|
|
12
|
+
export declare function truncatedNormalCDF(x: number, a: number, b: number, mu?: number, sigma?: number): number;
|
|
13
|
+
/** Mean of the truncated normal on [a, b]: μ + σ(φ(α) − φ(β))/(Φ(β) − Φ(α)), tail-stable. */
|
|
14
|
+
export declare function truncatedNormalMean(a: number, b: number, mu?: number, sigma?: number): number;
|
|
15
|
+
/** Inverse gamma PDF: β^α x^(−α−1) e^(−β/x) / Γ(α). */
|
|
16
|
+
export declare function inverseGammaPDF(x: number, alpha: number, beta: number): number;
|
|
17
|
+
/** Inverse gamma CDF: 1 − P(α, β/x) (regularized upper incomplete gamma). */
|
|
18
|
+
export declare function inverseGammaCDF(x: number, alpha: number, beta: number): number;
|
|
19
|
+
/** GEV CDF exp(−t), t = (1 + ξz)^(−1/ξ) (ξ = 0: t = e^(−z)). Outside support: 0 or 1. */
|
|
20
|
+
export declare function gevCDF(x: number, xi: number, mu?: number, sigma?: number): number;
|
|
21
|
+
/** GEV PDF t^(ξ+1) e^(−t) / σ, with t as in {@link gevCDF}. Zero outside support. */
|
|
22
|
+
export declare function gevPDF(x: number, xi: number, mu?: number, sigma?: number): number;
|
|
23
|
+
/**
|
|
24
|
+
* Skellam PMF: e^(−(μ₁+μ₂)) (μ₁/μ₂)^(k/2) I_|k|(2√(μ₁μ₂)). Requires μ₁, μ₂ > 0.
|
|
25
|
+
*/
|
|
26
|
+
export declare function skellamPMF(k: number, mu1: number, mu2: number): number;
|
|
27
|
+
/** Zipf PMF on {1..n}: k^(−s) / H_{n,s}. Zero for non-integer or out-of-range k. */
|
|
28
|
+
export declare function zipfPMF(k: number, s: number, n: number): number;
|
|
29
|
+
/** Nakagami PDF: 2 m^m x^(2m−1) e^(−m x²/ω) / (Γ(m) ω^m), x > 0. */
|
|
30
|
+
export declare function nakagamiPDF(x: number, m: number, omega: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* Rice PDF: (x/σ²) e^(−(x²+ν²)/(2σ²)) I₀(xν/σ²), x ≥ 0. Evaluated with the scaled
|
|
33
|
+
* I₀ so that exp(−(x−ν)²/(2σ²)) · I₀e does not overflow for large xν/σ².
|
|
34
|
+
*/
|
|
35
|
+
export declare function ricePDF(x: number, nu: number, sigma: number): number;
|
|
36
|
+
//# sourceMappingURL=distributions-extra.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distributions-extra.d.ts","sourceRoot":"","sources":["../../src/stats/distributions-extra.ts"],"names":[],"mappings":"AA2BA;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAMnD;AAED,kEAAkE;AAClE,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAI,EAAE,KAAK,SAAI,GAAG,MAAM,CAGlF;AAED,wCAAwC;AACxC,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAI,EAAE,KAAK,SAAI,GAAG,MAAM,CAGlF;AAuCD,sCAAsC;AACtC,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,SAAI,EAAE,KAAK,SAAI,GAAG,MAAM,CAO7F;AAED,sCAAsC;AACtC,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,SAAI,EAAE,KAAK,SAAI,GAAG,MAAM,CAU7F;AAED,6FAA6F;AAC7F,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,SAAI,EAAE,KAAK,SAAI,GAAG,MAAM,CASnF;AAED,uDAAuD;AACvD,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG9E;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG9E;AAED,yFAAyF;AACzF,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,SAAI,EAAE,KAAK,SAAI,GAAG,MAAM,CAMvE;AAED,qFAAqF;AACrF,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,SAAI,EAAE,KAAK,SAAI,GAAG,MAAM,CAWvE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQtE;AAED,oFAAoF;AACpF,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAK/D;AAED,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAUvE;AA6BD;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMpE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standardized effect sizes (gap-analysis 2026-11-04, Batch A).
|
|
3
|
+
*/
|
|
4
|
+
type Vec = readonly number[] | Float64Array;
|
|
5
|
+
/** Cohen's d with the pooled (ddof 1) standard deviation. */
|
|
6
|
+
export declare function cohensD(a: Vec, b: Vec): number;
|
|
7
|
+
/** Hedges' g: Cohen's d with the small-sample correction 1 − 3/(4(n₁+n₂) − 9). */
|
|
8
|
+
export declare function hedgesG(a: Vec, b: Vec): number;
|
|
9
|
+
/** Glass's Δ: (mean a − mean b) / sd(b). */
|
|
10
|
+
export declare function glassDelta(a: Vec, b: Vec): number;
|
|
11
|
+
/** η² = SS_between / SS_total across groups. */
|
|
12
|
+
export declare function etaSquared(groups: readonly Vec[]): number;
|
|
13
|
+
/**
|
|
14
|
+
* Rank-biserial correlation r = 2U_a/(n₁n₂) − 1, where U_a counts pairs with
|
|
15
|
+
* aᵢ > bⱼ (ties count ½). r is positive when a tends to exceed b, so its sign
|
|
16
|
+
* is opposite to `cohensD(a, b)`'s convention only in magnitude form; it equals
|
|
17
|
+
* 1 − 2U_b/(n₁n₂) with U_b = n₁n₂ − U_a.
|
|
18
|
+
*/
|
|
19
|
+
export declare function rankBiserial(a: Vec, b: Vec): number;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=effect-sizes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effect-sizes.d.ts","sourceRoot":"","sources":["../../src/stats/effect-sizes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,KAAK,GAAG,GAAG,SAAS,MAAM,EAAE,GAAG,YAAY,CAAC;AAS5C,6DAA6D;AAC7D,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAQ9C;AAED,kFAAkF;AAClF,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAG9C;AAED,4CAA4C;AAC5C,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAKjD;AAED,gDAAgD;AAChD,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,EAAE,GAAG,MAAM,CAQzD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAYnD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
type Vec = readonly number[] | Float64Array;
|
|
2
|
+
/** Sign test on the median. Ties with `median` are dropped; two-sided exact binomial p. */
|
|
3
|
+
export declare function signTest(x: Vec, medianValue?: number): {
|
|
4
|
+
statistic: number;
|
|
5
|
+
pValue: number;
|
|
6
|
+
nPos: number;
|
|
7
|
+
nNeg: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Wald–Wolfowitz runs test. Booleans are used directly; numeric values are
|
|
11
|
+
* classified against `cutoff` (default: the median), with values equal to the
|
|
12
|
+
* cutoff dropped. Normal approximation, two-sided p. With n₁ = 0 or n₂ = 0,
|
|
13
|
+
* z is NaN and p is 1.
|
|
14
|
+
*/
|
|
15
|
+
export declare function runsTest(x: Vec | readonly boolean[], opts?: {
|
|
16
|
+
cutoff?: number;
|
|
17
|
+
}): {
|
|
18
|
+
runs: number;
|
|
19
|
+
z: number;
|
|
20
|
+
pValue: number;
|
|
21
|
+
};
|
|
22
|
+
/** Mood's median test: chi-square test of the above/at-or-below-grand-median table. */
|
|
23
|
+
export declare function moodMedianTest(groups: readonly Vec[]): {
|
|
24
|
+
statistic: number;
|
|
25
|
+
pValue: number;
|
|
26
|
+
grandMedian: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Cressie–Read power divergence statistic for observed counts against expected
|
|
30
|
+
* counts (default: uniform). λ = 1 gives Pearson χ², λ = 0 gives G, λ = −1 is
|
|
31
|
+
* rejected as singular. Zero observed counts contribute 0 when λ = 0.
|
|
32
|
+
*/
|
|
33
|
+
export declare function powerDivergence(observed: Vec, expected?: Vec, lambda?: number): {
|
|
34
|
+
statistic: number;
|
|
35
|
+
pValue: number;
|
|
36
|
+
};
|
|
37
|
+
/** Log-likelihood ratio G-test: `powerDivergence(observed, expected, 0)`. */
|
|
38
|
+
export declare function gTest(observed: Vec, expected?: Vec): {
|
|
39
|
+
statistic: number;
|
|
40
|
+
pValue: number;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Delete-one jackknife. `estimate` is the bias-corrected estimate
|
|
44
|
+
* θ̂ − bias, `bias` = (n−1)(θ̄₋ᵢ − θ̂), and `se` = √((n−1)/n · Σ(θ₋ᵢ − θ̄₋ᵢ)²).
|
|
45
|
+
*/
|
|
46
|
+
export declare function jackknife(x: Vec, stat: (sample: number[]) => number): {
|
|
47
|
+
estimate: number;
|
|
48
|
+
bias: number;
|
|
49
|
+
se: number;
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=nonparametric-extra.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nonparametric-extra.d.ts","sourceRoot":"","sources":["../../src/stats/nonparametric-extra.ts"],"names":[],"mappings":"AAOA,KAAK,GAAG,GAAG,SAAS,MAAM,EAAE,GAAG,YAAY,CAAC;AAc5C,2FAA2F;AAC3F,wBAAgB,QAAQ,CACtB,CAAC,EAAE,GAAG,EACN,WAAW,SAAI,GACd;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAUnE;AAQD;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,CAAC,EAAE,GAAG,GAAG,SAAS,OAAO,EAAE,EAC3B,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAmB7C;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG,EAAE,GAAG;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,CAkBA;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,GAAG,EACb,QAAQ,CAAC,EAAE,GAAG,EACd,MAAM,SAAI,GACT;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAiBvC;AAED,6EAA6E;AAC7E,wBAAgB,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAE1F;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,CAAC,EAAE,GAAG,EACN,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,MAAM,GACjC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAWhD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generalized means, geometric standard deviation, robust regression slopes
|
|
3
|
+
* and partial correlation (gap-analysis 2026-11-04, Batch A).
|
|
4
|
+
*/
|
|
5
|
+
type Vec = readonly number[] | Float64Array;
|
|
6
|
+
/**
|
|
7
|
+
* Power mean M_p = (Σxᵖ / n)^(1/p). p = 0 is the geometric mean, p = 1 the
|
|
8
|
+
* arithmetic mean and p = −1 the harmonic mean. Non-integer p requires x > 0.
|
|
9
|
+
*/
|
|
10
|
+
export declare function pmean(x: Vec, p: number): number;
|
|
11
|
+
/** Geometric standard deviation: exp(std(ln x)). Default ddof 1 (scipy). */
|
|
12
|
+
export declare function gstd(x: Vec, opts?: {
|
|
13
|
+
ddof?: number;
|
|
14
|
+
}): number;
|
|
15
|
+
/** Geometric z-score: (ln xᵢ − mean(ln x)) / std(ln x). */
|
|
16
|
+
export declare function gzscore(x: Vec, opts?: {
|
|
17
|
+
ddof?: number;
|
|
18
|
+
}): number[];
|
|
19
|
+
/**
|
|
20
|
+
* Theil–Sen estimator: slope = median of all pairwise slopes, intercept =
|
|
21
|
+
* median(y) − slope·median(x).
|
|
22
|
+
*/
|
|
23
|
+
export declare function theilSen(x: Vec, y: Vec): {
|
|
24
|
+
slope: number;
|
|
25
|
+
intercept: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Siegel repeated-medians estimator: slope = median over i of the median of
|
|
29
|
+
* slopes from point i to every other point; intercept = median(y − slope·x).
|
|
30
|
+
*/
|
|
31
|
+
export declare function siegelSlopes(x: Vec, y: Vec): {
|
|
32
|
+
slope: number;
|
|
33
|
+
intercept: number;
|
|
34
|
+
};
|
|
35
|
+
/** Partial correlation of x and y controlling for z (first-order formula). */
|
|
36
|
+
export declare function partialCorrelation(x: Vec, y: Vec, z: Vec): number;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=robust-stats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"robust-stats.d.ts","sourceRoot":"","sources":["../../src/stats/robust-stats.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,KAAK,GAAG,GAAG,SAAS,MAAM,EAAE,GAAG,YAAY,CAAC;AAoB5C;;;GAGG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAe/C;AAED,4EAA4E;AAC5E,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAK7D;AAED,2DAA2D;AAC3D,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,EAAE,CAQlE;AAqBD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAM7E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAajF;AAgBD,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAWjE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Weighted descriptive statistics (gap-analysis 2026-11-04, Batch A).
|
|
3
|
+
*
|
|
4
|
+
* Weights are non-negative frequency-style weights. Zero-weight points never
|
|
5
|
+
* contribute to a quantile.
|
|
6
|
+
*/
|
|
7
|
+
type Vec = readonly number[] | Float64Array;
|
|
8
|
+
/** Weighted arithmetic mean: Σwᵢxᵢ / Σwᵢ. */
|
|
9
|
+
export declare function weightedMean(x: Vec, w: Vec): number;
|
|
10
|
+
/**
|
|
11
|
+
* Weighted variance. `ddof: 0` (default) gives Σw(x−m)²/Σw; `ddof: 1` divides
|
|
12
|
+
* by (Σw − Σw²/Σw), the reliability-weights unbiased form (equal weights give
|
|
13
|
+
* n/(n−1) scaling, and it stays finite for normalised weights).
|
|
14
|
+
*/
|
|
15
|
+
export declare function weightedVariance(x: Vec, w: Vec, opts?: {
|
|
16
|
+
ddof?: 0 | 1;
|
|
17
|
+
}): number;
|
|
18
|
+
/**
|
|
19
|
+
* Weighted quantile, lower rule: sort by x and return the first value whose
|
|
20
|
+
* cumulative weight reaches p·Σw. Points with zero weight are never returned
|
|
21
|
+
* unless every weight is zero (which is rejected).
|
|
22
|
+
*/
|
|
23
|
+
export declare function weightedQuantile(x: Vec, w: Vec, p: number): number;
|
|
24
|
+
/** Weighted median (lower rule): `weightedQuantile(x, w, 0.5)`. */
|
|
25
|
+
export declare function weightedMedian(x: Vec, w: Vec): number;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=weighted-stats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weighted-stats.d.ts","sourceRoot":"","sources":["../../src/stats/weighted-stats.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,KAAK,GAAG,GAAG,SAAS,MAAM,EAAE,GAAG,YAAY,CAAC;AAqB5C,6CAA6C;AAC7C,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAWnD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;CAAE,GAAG,MAAM,CAgBhF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAgBlE;AAED,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAErD"}
|
package/dist/typed/algebra.d.ts
CHANGED
|
@@ -47,9 +47,9 @@ export declare function polyadd(a: number[], b: number[]): number[];
|
|
|
47
47
|
* @param b - Second polynomial coefficients
|
|
48
48
|
* @returns Product polynomial coefficients
|
|
49
49
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
50
|
+
* Multiplies through `polyMulDispatch` (the shared `polyMulJS` kernel, or the
|
|
51
|
+
* WASM kernel at or above `WASM_POLY_THRESHOLD` coefficients when the policy
|
|
52
|
+
* allows), then strips high-end zeros with `trimPoly`.
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
55
55
|
* ```typescript
|
|
@@ -88,6 +88,10 @@ export declare function polyder(coeffs: number[], n?: number): number[];
|
|
|
88
88
|
* @param b - Second polynomial coefficients (index = power)
|
|
89
89
|
* @returns GCD polynomial coefficients (monic); `[0]` when both inputs are zero
|
|
90
90
|
*
|
|
91
|
+
* Integer coefficients, and rational coefficients whose common denominator is at most 1e6
|
|
92
|
+
* (checked to 1e-12 relative), are scaled to integers and solved exactly; other input
|
|
93
|
+
* uses floating-point Euclid.
|
|
94
|
+
*
|
|
91
95
|
* @example
|
|
92
96
|
* ```typescript
|
|
93
97
|
* // GCD of x^2-1 and x-1 is x-1
|