@danielsimonjr/mathts-functions 0.31.0 → 0.32.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/dist/descriptive-stats.d.ts +16 -0
- package/dist/descriptive-stats.d.ts.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +914 -477
- package/dist/stats/fit-distribution.d.ts +44 -0
- package/dist/stats/fit-distribution.d.ts.map +1 -0
- package/dist/stats/inference-extra2.d.ts +127 -0
- package/dist/stats/inference-extra2.d.ts.map +1 -0
- package/dist/stats/timeseries.d.ts +50 -0
- package/dist/stats/timeseries.d.ts.map +1 -0
- package/dist/typed/hypothesis.d.ts +24 -6
- package/dist/typed/hypothesis.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maximum-likelihood distribution fitting (Phase 4 Task 1).
|
|
3
|
+
*
|
|
4
|
+
* `fitDistribution(name, data)` fits one of five common distributions to a
|
|
5
|
+
* sample by maximum likelihood and reports the fitted parameters plus the
|
|
6
|
+
* achieved log-likelihood.
|
|
7
|
+
*
|
|
8
|
+
* - `normal` — closed form: mu = mean, sigma = population std (ddof=0).
|
|
9
|
+
* - `exponential` — closed form: lambda = 1 / mean.
|
|
10
|
+
* - `lognormal` — fit a normal to ln(data) (requires all data > 0).
|
|
11
|
+
* - `poisson` — closed form: lambda = mean.
|
|
12
|
+
* - `gamma` — no closed form for the shape parameter. Given shape k,
|
|
13
|
+
* the MLE scale is theta = xbar / k; substituting back yields the
|
|
14
|
+
* 1-D shape equation `ln(k) - psi(k) = ln(xbar) - mean(ln x)`
|
|
15
|
+
* (psi = digamma), solved here with the secant method starting from the
|
|
16
|
+
* Choi & Wette (1969) initial guess.
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
/** Supported distribution families for {@link fitDistribution}. */
|
|
21
|
+
export type DistributionName = 'normal' | 'exponential' | 'lognormal' | 'poisson' | 'gamma';
|
|
22
|
+
/** Result of {@link fitDistribution}: fitted parameters + achieved log-likelihood. */
|
|
23
|
+
export interface FitDistributionResult {
|
|
24
|
+
/** Fitted parameters, named per distribution (see {@link fitDistribution}). */
|
|
25
|
+
params: Record<string, number>;
|
|
26
|
+
/** Log-likelihood of `data` under the fitted parameters. */
|
|
27
|
+
logLikelihood: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Fit a distribution to `data` by maximum likelihood.
|
|
31
|
+
*
|
|
32
|
+
* @param name - Distribution family: 'normal' | 'exponential' | 'lognormal' | 'poisson' | 'gamma'
|
|
33
|
+
* @param data - Sample data
|
|
34
|
+
* @returns Fitted parameters and the log-likelihood achieved under them
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* fitDistribution('normal', [2, 4, 4, 4, 5, 5, 7, 9]);
|
|
38
|
+
* // { params: { mean: 5, std: 2 }, logLikelihood: ... }
|
|
39
|
+
*
|
|
40
|
+
* fitDistribution('exponential', [1, 2, 3, 2]);
|
|
41
|
+
* // { params: { lambda: 0.5 }, logLikelihood: ... }
|
|
42
|
+
*/
|
|
43
|
+
export declare function fitDistribution(name: DistributionName, data: readonly number[]): FitDistributionResult;
|
|
44
|
+
//# sourceMappingURL=fit-distribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fit-distribution.d.ts","sourceRoot":"","sources":["../../src/stats/fit-distribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,aAAa,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAE5F,sFAAsF;AACtF,MAAM,WAAW,qBAAqB;IACpC,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,4DAA4D;IAC5D,aAAa,EAAE,MAAM,CAAC;CACvB;AA8FD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,qBAAqB,CAoBvB"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noncentral chi-squared CDF via the Poisson-mixture representation:
|
|
3
|
+
*
|
|
4
|
+
* F(x; k, λ) = Σ_{j=0}^∞ Pois(j; λ/2) · chiSquaredCDF(x, k + 2j)
|
|
5
|
+
*
|
|
6
|
+
* Truncated once the cumulative Poisson mass covers `1 − 1e-12` of the total
|
|
7
|
+
* (past the Poisson mode, so truncation never fires during the rising phase).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* noncentralChi2CDF(10, 3, 2); // ~0.89856 (scipy ncx2.cdf)
|
|
11
|
+
*/
|
|
12
|
+
export declare function noncentralChi2CDF(x: number, df: number, nc: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Noncentral F CDF via the Poisson-mixture representation over the numerator
|
|
15
|
+
* degrees of freedom:
|
|
16
|
+
*
|
|
17
|
+
* F(x; d1, d2, λ) = Σ_{j=0}^∞ Pois(j; λ/2) · fCDF(x·d1/(d1+2j), d1+2j, d2)
|
|
18
|
+
*
|
|
19
|
+
* Truncated the same way as {@link noncentralChi2CDF}.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* noncentralFCDF(2, 3, 10, 4); // ~0.46636 (scipy ncf.cdf)
|
|
23
|
+
*/
|
|
24
|
+
export declare function noncentralFCDF(x: number, dfn: number, dfd: number, nc: number): number;
|
|
25
|
+
/**
|
|
26
|
+
* Noncentral Student-t CDF via the mixture representation
|
|
27
|
+
* `T = (Z + δ) / sqrt(V/ν)`, `Z ~ N(0,1)`, `V ~ χ²_ν` independent:
|
|
28
|
+
*
|
|
29
|
+
* F(t; ν, δ) = E_V[ Φ(t·sqrt(V/ν) − δ) ] = ∫₀^∞ Φ(t·sqrt(v/ν) − δ) · χ²_ν(v) dv
|
|
30
|
+
*
|
|
31
|
+
* Evaluated by composite Simpson's rule over `v` (central-χ² density; `δ`
|
|
32
|
+
* only enters the normal-CDF term). The upper integration bound is set
|
|
33
|
+
* generously past the χ²_ν tail so the truncation error is negligible
|
|
34
|
+
* relative to the ~1e-4 Simpson discretization error at the panel count used.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* noncentralTCDF(1.5, 10, 2); // ~0.30479 (scipy nct.cdf)
|
|
38
|
+
*/
|
|
39
|
+
export declare function noncentralTCDF(t: number, df: number, nc: number): number;
|
|
40
|
+
/** Options shared by the circular-statistics functions. */
|
|
41
|
+
export interface CircularOptions {
|
|
42
|
+
/** Upper bound of the angular range. Default `2π`. */
|
|
43
|
+
high?: number;
|
|
44
|
+
/** Lower bound of the angular range. Default `0`. */
|
|
45
|
+
low?: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Circular (angular) mean, mapped back into `[low, high)`.
|
|
49
|
+
*
|
|
50
|
+
* `mean = atan2(Σsinθ, Σcosθ)`, where `θ` is `angles` rescaled into
|
|
51
|
+
* `[0, 2π)` when a non-default `[low, high)` range is given (matching
|
|
52
|
+
* `scipy.stats.circmean`).
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* circmean([0.1, 0.2, 6.2]); // ~0.07236 (scipy circmean; wraps near 0)
|
|
56
|
+
*/
|
|
57
|
+
export declare function circmean(angles: readonly number[], opts?: CircularOptions): number;
|
|
58
|
+
/**
|
|
59
|
+
* Circular variance `1 − R`, where `R = |Σcosθ + iΣsinθ| / n` is the mean
|
|
60
|
+
* resultant length. `R ∈ [0, 1]`, so `circvar ∈ [0, 1]`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function circvar(angles: readonly number[], opts?: CircularOptions): number;
|
|
63
|
+
/**
|
|
64
|
+
* Circular standard deviation `sqrt(−2·ln(R))` (matches `scipy.stats.circstd`
|
|
65
|
+
* with the default `normalize=False` low/high dispersion measure).
|
|
66
|
+
*/
|
|
67
|
+
export declare function circstd(angles: readonly number[], opts?: CircularOptions): number;
|
|
68
|
+
/**
|
|
69
|
+
* Von Mises probability density function (the circular analogue of the
|
|
70
|
+
* normal distribution).
|
|
71
|
+
*
|
|
72
|
+
* f(θ; μ, κ) = exp(κ·cos(θ − μ)) / (2π·I₀(κ))
|
|
73
|
+
*
|
|
74
|
+
* `I₀` is the modified Bessel function of the first kind, order 0
|
|
75
|
+
* (`besselIScalar` — the shared special-function scalar backing the public
|
|
76
|
+
* `besselI`).
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* vonMisesPDF(0, 0, 2); // ~0.51589 (scipy vonmises.pdf(0, 2))
|
|
80
|
+
*/
|
|
81
|
+
export declare function vonMisesPDF(theta: number, mu: number, kappa: number): number;
|
|
82
|
+
/** Options for {@link mcnemar}. */
|
|
83
|
+
export interface McNemarOptions {
|
|
84
|
+
/** Apply the continuity correction (`|b−c| − 1`). Default `true`. */
|
|
85
|
+
correction?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** Result of {@link mcnemar}. */
|
|
88
|
+
export interface McNemarResult {
|
|
89
|
+
chi2: number;
|
|
90
|
+
pValue: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* McNemar's test for paired nominal data on a 2x2 table
|
|
94
|
+
* `[[a, b], [c, d]]` (only the discordant pairs `b`, `c` matter):
|
|
95
|
+
*
|
|
96
|
+
* chi2 = (|b − c| − correction)² / (b + c)
|
|
97
|
+
*
|
|
98
|
+
* with the continuity correction (`1`) applied by default, matching
|
|
99
|
+
* `statsmodels.stats.contingency_tables.mcnemar`. `pValue = 1 −
|
|
100
|
+
* chiSquaredCDF(chi2, 1)`.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* mcnemar([[10, 5], [3, 12]], { correction: false }); // { chi2: 0.5, pValue: ... }
|
|
104
|
+
*/
|
|
105
|
+
export declare function mcnemar(table: readonly (readonly number[])[], opts?: McNemarOptions): McNemarResult;
|
|
106
|
+
/** Result of {@link cochranQ}. */
|
|
107
|
+
export interface CochranQResult {
|
|
108
|
+
Q: number;
|
|
109
|
+
pValue: number;
|
|
110
|
+
dof: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Cochran's Q test — the extension of McNemar's test to `k > 2` matched
|
|
114
|
+
* binary treatments. `data` has one row per subject, one column per
|
|
115
|
+
* treatment (0/1 entries).
|
|
116
|
+
*
|
|
117
|
+
* Q = (k−1)·(k·ΣCⱼ² − N²) / (k·N − ΣRᵢ²)
|
|
118
|
+
*
|
|
119
|
+
* where `Cⱼ` are column sums, `Rᵢ` are row sums, and `N = ΣRᵢ`. `dof = k −
|
|
120
|
+
* 1`; `pValue = 1 − chiSquaredCDF(Q, k−1)`. Matches
|
|
121
|
+
* `statsmodels.stats.contingency_tables.cochrans_q`.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* cochranQ([[1, 1, 0], [1, 0, 0], [1, 1, 1], [0, 1, 0], [1, 1, 0]]);
|
|
125
|
+
*/
|
|
126
|
+
export declare function cochranQ(data: readonly (readonly number[])[]): CochranQResult;
|
|
127
|
+
//# sourceMappingURL=inference-extra2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inference-extra2.d.ts","sourceRoot":"","sources":["../../src/stats/inference-extra2.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAiB3E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAkBtF;AAED;;;;;;;;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;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,GAAG,cAAc,CA8B7E"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Partial autocorrelation function up to `nlags` (inclusive), via the
|
|
3
|
+
* Levinson-Durbin recursion applied to the biased autocorrelations (`acf`).
|
|
4
|
+
* `pacf[0] = 1`. Matches `statsmodels.tsa.stattools.pacf(x, nlags, method='ldb')`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* pacf([1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2], 3) // => [1, 0, -0.8333..., 0]
|
|
8
|
+
*/
|
|
9
|
+
export declare function pacf(x: number[], nlags: number): number[];
|
|
10
|
+
/** Result of {@link ljungBox}. */
|
|
11
|
+
export interface LjungBoxResult {
|
|
12
|
+
statistic: number;
|
|
13
|
+
pValue: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Ljung-Box portmanteau test for autocorrelation up to lag `lags`.
|
|
17
|
+
* `Q = n(n+2) * Σ_{k=1}^{lags} ρ_k² / (n-k)`, `pValue = 1 - chiSquaredCDF(Q, lags)`.
|
|
18
|
+
* Matches `statsmodels.stats.diagnostic.acorr_ljungbox`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function ljungBox(x: number[], lags: number): LjungBoxResult;
|
|
21
|
+
/**
|
|
22
|
+
* Durbin-Watson statistic for residual autocorrelation:
|
|
23
|
+
* `Σ_{t=2}^{n}(e_t - e_{t-1})² / Σ_{t=1}^{n} e_t²`. Ranges (0, 4); ~2 indicates
|
|
24
|
+
* no autocorrelation, <2 positive autocorrelation, >2 negative. Matches
|
|
25
|
+
* `statsmodels.stats.stattools.durbin_watson`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function durbinWatson(residuals: number[]): number;
|
|
28
|
+
/** Result of {@link adfuller}. */
|
|
29
|
+
export interface AdfullerResult {
|
|
30
|
+
statistic: number;
|
|
31
|
+
pValue: number;
|
|
32
|
+
usedLag: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Augmented Dickey-Fuller unit-root test (constant-only "c" model):
|
|
36
|
+
* regresses `Δx_t` on `[1, x_{t-1}, Δx_{t-1}, ..., Δx_{t-maxlag}]` via OLS.
|
|
37
|
+
* `statistic = coefficients[1] / stderr[1]` (the t-stat on the lagged level,
|
|
38
|
+
* `coefficients[0]` being the intercept). `pValue` is an approximate
|
|
39
|
+
* MacKinnon-style interpolation (see module docstring) — not exact.
|
|
40
|
+
*
|
|
41
|
+
* Default `maxlag = floor(12 * (n/100)^0.25)` (matches
|
|
42
|
+
* `statsmodels.tsa.stattools.adfuller`'s default rule), clamped downward if
|
|
43
|
+
* needed so the regression has more observations than parameters; `usedLag`
|
|
44
|
+
* reports the lag count actually used.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* adfuller(whiteNoiseSeries) // => { statistic: <very negative>, pValue: <small>, usedLag }
|
|
48
|
+
*/
|
|
49
|
+
export declare function adfuller(x: number[], maxlag?: number): AdfullerResult;
|
|
50
|
+
//# sourceMappingURL=timeseries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeseries.d.ts","sourceRoot":"","sources":["../../src/stats/timeseries.ts"],"names":[],"mappings":"AA6BA;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CA+BzD;AAED,kCAAkC;AAClC,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAUlE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAUxD;AAED,kCAAkC;AAClC,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAkDD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CAwCrE"}
|
|
@@ -270,22 +270,40 @@ export declare function shapiroWilkTest(sample: f64[], opts?: BootstrapOptions):
|
|
|
270
270
|
* result.explained // [1.0]
|
|
271
271
|
*/
|
|
272
272
|
export declare function principalComponentAnalysis(data: f64[][], k?: number): PCAResult;
|
|
273
|
+
/** Options for {@link kolmogorovSmirnov2Test}. */
|
|
274
|
+
export interface KS2Options {
|
|
275
|
+
/**
|
|
276
|
+
* `'asymp'` (default): large-sample `kstwobign` asymptotic p-value —
|
|
277
|
+
* unchanged from the original implementation, so omitting `opts` entirely
|
|
278
|
+
* preserves the exact prior behavior.
|
|
279
|
+
* `'exact'`: exact lattice-path p-value (Kim & Jennrich), matching
|
|
280
|
+
* `scipy.stats.ks_2samp(..., method='exact')`.
|
|
281
|
+
* `'auto'`: exact when n1*n2 <= 10000, else asymptotic (scipy's own
|
|
282
|
+
* threshold for switching to the asymptotic approximation).
|
|
283
|
+
*/
|
|
284
|
+
method?: 'auto' | 'exact' | 'asymp';
|
|
285
|
+
}
|
|
273
286
|
/**
|
|
274
287
|
* Two-sample Kolmogorov–Smirnov test: are two samples drawn from the same
|
|
275
288
|
* continuous distribution? The statistic is the maximum gap between the two
|
|
276
|
-
* empirical CDFs, D = maxₓ |F₁(x) − F₂(x)
|
|
277
|
-
* asymptotic Q(√(n₁n₂/(n₁+n₂))·D) (the `kstwobign` survival
|
|
278
|
-
* scipy's asymptotic method
|
|
279
|
-
*
|
|
289
|
+
* empirical CDFs, D = maxₓ |F₁(x) − F₂(x)|. By default the p-value is the
|
|
290
|
+
* large-sample asymptotic Q(√(n₁n₂/(n₁+n₂))·D) (the `kstwobign` survival
|
|
291
|
+
* function, matching scipy's asymptotic method) — this default is unchanged
|
|
292
|
+
* from before Phase 4. Pass `{ method: 'exact' }` to opt into the exact
|
|
293
|
+
* lattice-path p-value instead (`scipy.stats.ks_2samp(..., method='exact')`).
|
|
294
|
+
* Distinct from the one-sample {@link kolmogorovSmirnovTest}, which compares
|
|
295
|
+
* one sample to a CDF *function*.
|
|
280
296
|
*
|
|
281
297
|
* @param sample1 - first sample (non-empty)
|
|
282
298
|
* @param sample2 - second sample (non-empty)
|
|
299
|
+
* @param opts - `{ method: 'auto' | 'exact' | 'asymp' }` (default 'asymp')
|
|
283
300
|
* @returns `{ statistic: D, pValue }`
|
|
284
301
|
*
|
|
285
302
|
* @example
|
|
286
|
-
* kolmogorovSmirnov2Test([0.1, 0.4, 0.6], [0.3, 0.5, 0.9]) // { statistic, pValue }
|
|
303
|
+
* kolmogorovSmirnov2Test([0.1, 0.4, 0.6], [0.3, 0.5, 0.9]) // { statistic, pValue } (asymptotic)
|
|
304
|
+
* kolmogorovSmirnov2Test(a, b, { method: 'exact' }) // exact lattice-path p-value
|
|
287
305
|
*/
|
|
288
|
-
export declare function kolmogorovSmirnov2Test(sample1: f64[], sample2: f64[]): KSTestResult;
|
|
306
|
+
export declare function kolmogorovSmirnov2Test(sample1: f64[], sample2: f64[], opts?: KS2Options): KSTestResult;
|
|
289
307
|
/** Variance-homogeneity test result. `degreesOfFreedom` is `[d1, d2]` for the
|
|
290
308
|
* F-based Levene test, a single number for the χ²-based Bartlett test. */
|
|
291
309
|
export interface VarianceTestResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hypothesis.d.ts","sourceRoot":"","sources":["../../src/typed/hypothesis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAWH,mBAAmB;AACnB,KAA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