@danielsimonjr/mathts-functions 0.68.3 → 0.68.4
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.
|
@@ -9,7 +9,7 @@ interface SimplifyOptions {
|
|
|
9
9
|
}
|
|
10
10
|
interface SymbolicEqualDependencies {
|
|
11
11
|
parse: (expr: string) => MathNode;
|
|
12
|
-
simplify: (node: MathNode,
|
|
12
|
+
simplify: (node: MathNode, scope: Map<string, unknown>, options: SimplifyOptions) => MathNode;
|
|
13
13
|
typed: TypedFunction;
|
|
14
14
|
OperatorNode: OperatorNodeConstructor;
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbolicEqual.d.ts","sourceRoot":"","sources":["../../src/algebra/symbolicEqual.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAO/D,UAAU,uBAAuB;IAC/B,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;CAC1D;AAED,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,UAAU,yBAAyB;IACjC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC;IAClC,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"symbolicEqual.d.ts","sourceRoot":"","sources":["../../src/algebra/symbolicEqual.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAO/D,UAAU,uBAAuB;IAC/B,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;CAC1D;AAED,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,UAAU,yBAAyB;IACjC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC;IAClC,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,KAAK,QAAQ,CAAC;IAC9F,KAAK,EAAE,aAAa,CAAC;IACrB,YAAY,EAAE,uBAAuB,CAAC;CACvC;AAKD,eAAO,MAAM,mBAAmB,yFA0D/B,CAAC"}
|
|
@@ -27,4 +27,11 @@ export declare const laplaceQuantile: (p: number, mu?: number, b?: number) => nu
|
|
|
27
27
|
export declare const logisticPDF: (x: number, mu?: number, s?: number) => number;
|
|
28
28
|
export declare const logisticCDF: (x: number, mu?: number, s?: number) => number;
|
|
29
29
|
export declare const logisticQuantile: (p: number, mu?: number, s?: number) => number;
|
|
30
|
+
/**
|
|
31
|
+
* Two-sided p-value of a Student-t statistic `t` with `df` degrees of freedom,
|
|
32
|
+
* computed DIRECTLY in the tail as the regularized incomplete beta
|
|
33
|
+
* `I_{df/(df+t²)}(df/2, 1/2)`. `2·(1 − studentTCDF(|t|, df))` rounds a far
|
|
34
|
+
* tail to 0, and a steep regression's slope test IS that tail.
|
|
35
|
+
*/
|
|
36
|
+
export declare function studentTTwoSidedP(t: number, df: number): number;
|
|
30
37
|
//# sourceMappingURL=distribution-functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution-functions.d.ts","sourceRoot":"","sources":["../src/distribution-functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"distribution-functions.d.ts","sourceRoot":"","sources":["../src/distribution-functions.ts"],"names":[],"mappings":"AAoBA,2DAA2D;AAC3D,eAAO,MAAM,cAAc,MAAO,MAAM,kCAAsB,MAC/B,CAAC;AAEhC,+DAA+D;AAC/D,eAAO,MAAM,WAAW,MAAO,MAAM,MAAM,MAAM,KAAG,MAA6B,CAAC;AAClF,eAAO,MAAM,gBAAgB,MAAO,MAAM,MAAM,MAAM,KAAG,MAAkC,CAAC;AAE5F,qEAAqE;AACrE,eAAO,MAAM,aAAa,MAAO,MAAM,MAAM,MAAM,KAAG,MAA+B,CAAC;AACtF,eAAO,MAAM,kBAAkB,MAAO,MAAM,MAAM,MAAM,KAAG,MAAoC,CAAC;AAEhG,wEAAwE;AACxE,eAAO,MAAM,IAAI,MAAO,MAAM,MAAM,MAAM,MAAM,MAAM,KAAG,MAAgC,CAAC;AAC1F,eAAO,MAAM,SAAS,MAAO,MAAM,MAAM,MAAM,MAAM,MAAM,KAAG,MAAqC,CAAC;AAEpG,oDAAoD;AACpD,eAAO,MAAM,QAAQ,MAAO,MAAM,SAAS,MAAM,oBAAa,MAAoC,CAAC;AACnG,eAAO,MAAM,aAAa,MAAO,MAAM,SAAS,MAAM,oBAAa,MAClC,CAAC;AAElC,0DAA0D;AAC1D,eAAO,MAAM,OAAO,MAAO,MAAM,KAAK,MAAM,KAAK,MAAM,KAAG,MAA4B,CAAC;AACvF,eAAO,MAAM,YAAY,MAAO,MAAM,KAAK,MAAM,KAAK,MAAM,KAAG,MAAiC,CAAC;AAIjG,4EAA4E;AAC5E,eAAO,MAAM,SAAS,MAAO,MAAM,kCAAsB,MACF,CAAC;AACxD,eAAO,MAAM,SAAS,MAAO,MAAM,kCAAsB,MACZ,CAAC;AAC9C,eAAO,MAAM,cAAc,MAAO,MAAM,kCAAsB,MAClB,CAAC;AAE7C,oFAAoF;AACpF,eAAO,MAAM,UAAU,MAAO,MAAM,8BAAkB,MACX,CAAC;AAC5C,eAAO,MAAM,UAAU,MAAO,MAAM,8BAAkB,MACqB,CAAC;AAC5E,eAAO,MAAM,eAAe,MAAO,MAAM,8BAAkB,MACQ,CAAC;AAEpE,gEAAgE;AAChE,eAAO,MAAM,WAAW,MAAO,MAAM,8BAAkB,MAGtD,CAAC;AACF,eAAO,MAAM,WAAW,MAAO,MAAM,8BAAkB,MAA2C,CAAC;AACnG,eAAO,MAAM,gBAAgB,MAAO,MAAM,8BAAkB,MAC5B,CAAC;AAEjC;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAM/D"}
|
package/dist/index.js
CHANGED
|
@@ -18401,6 +18401,13 @@ var logisticPDF = (x, mu = 0, s = 1) => {
|
|
|
18401
18401
|
};
|
|
18402
18402
|
var logisticCDF = (x, mu = 0, s = 1) => 1 / (1 + Math.exp(-(x - mu) / s));
|
|
18403
18403
|
var logisticQuantile = (p, mu = 0, s = 1) => mu + s * Math.log(p / (1 - p));
|
|
18404
|
+
function studentTTwoSidedP(t, df) {
|
|
18405
|
+
if (!(df > 0)) return NaN;
|
|
18406
|
+
if (Number.isNaN(t)) return NaN;
|
|
18407
|
+
if (!Number.isFinite(t)) return 0;
|
|
18408
|
+
if (t === 0) return 1;
|
|
18409
|
+
return betaincScalar(df / 2, 0.5, df / (df + t * t));
|
|
18410
|
+
}
|
|
18404
18411
|
|
|
18405
18412
|
// src/stats/inference-extra.ts
|
|
18406
18413
|
function chi2Contingency(table, opts = {}) {
|
|
@@ -42290,7 +42297,7 @@ var createSymbolicEqual = /* @__PURE__ */ factory(
|
|
|
42290
42297
|
({ parse: _parse2, simplify: simplify2, typed: typed3, OperatorNode }) => {
|
|
42291
42298
|
function _symbolicEqual(e1, e2, options = {}) {
|
|
42292
42299
|
const diff2 = new OperatorNode("-", "subtract", [e1, e2]);
|
|
42293
|
-
const simplified = simplify2(diff2,
|
|
42300
|
+
const simplified = simplify2(diff2, /* @__PURE__ */ new Map(), options);
|
|
42294
42301
|
return isConstantNode(simplified) && !simplified.value;
|
|
42295
42302
|
}
|
|
42296
42303
|
return typed3(name248, {
|
|
@@ -48753,6 +48760,15 @@ function matVec(a, v) {
|
|
|
48753
48760
|
return a.map((row2) => row2.reduce((sum3, val, j) => sum3 + val * v[j], 0));
|
|
48754
48761
|
}
|
|
48755
48762
|
function invert(a) {
|
|
48763
|
+
const scale4 = a.map((row2, i) => Math.sqrt(Math.abs(row2[i])));
|
|
48764
|
+
if (scale4.some((s) => !(s > 0) || !Number.isFinite(s))) {
|
|
48765
|
+
throw new Error("ols: X^T X is singular (predictors are collinear)");
|
|
48766
|
+
}
|
|
48767
|
+
const equilibrated = a.map((row2, i) => row2.map((v, j) => v / (scale4[i] * scale4[j])));
|
|
48768
|
+
const inv3 = invertUnscaled(equilibrated);
|
|
48769
|
+
return inv3.map((row2, i) => row2.map((v, j) => v / (scale4[i] * scale4[j])));
|
|
48770
|
+
}
|
|
48771
|
+
function invertUnscaled(a) {
|
|
48756
48772
|
const n = a.length;
|
|
48757
48773
|
const M = a.map((row2, i) => [...row2, ...Array.from({ length: n }, (_, j) => i === j ? 1 : 0)]);
|
|
48758
48774
|
for (let col = 0; col < n; col++) {
|
|
@@ -48764,7 +48780,7 @@ function invert(a) {
|
|
|
48764
48780
|
pivotRow = row2;
|
|
48765
48781
|
}
|
|
48766
48782
|
}
|
|
48767
|
-
if (maxVal < 1e-
|
|
48783
|
+
if (maxVal < 1e-12) throw new Error("ols: X^T X is singular (predictors are collinear)");
|
|
48768
48784
|
if (pivotRow !== col) [M[col], M[pivotRow]] = [M[pivotRow], M[col]];
|
|
48769
48785
|
const pivot = M[col][col];
|
|
48770
48786
|
for (let j = 0; j < 2 * n; j++) M[col][j] /= pivot;
|
|
@@ -48801,7 +48817,7 @@ function ols(X, y, opts) {
|
|
|
48801
48817
|
const sigma2 = rss / dfResid;
|
|
48802
48818
|
const stderr = XtXinv.map((row2, j) => Math.sqrt(sigma2 * row2[j]));
|
|
48803
48819
|
const tValues = coefficients.map((b, j) => b / stderr[j]);
|
|
48804
|
-
const pValues = tValues.map((t) =>
|
|
48820
|
+
const pValues = tValues.map((t) => studentTTwoSidedP(t, dfResid));
|
|
48805
48821
|
const r2 = tss === 0 ? 1 : 1 - rss / tss;
|
|
48806
48822
|
const adjR2 = 1 - (1 - r2) * (n - 1) / dfResid;
|
|
48807
48823
|
const fStat = p > 1 ? (tss - rss) / (p - 1) / (rss / dfResid) : NaN;
|
|
@@ -48953,7 +48969,7 @@ function linearRegression(x, y) {
|
|
|
48953
48969
|
const df = n - 2;
|
|
48954
48970
|
const stdErr = Math.sqrt((syy - slope * sxy) / df / sxx);
|
|
48955
48971
|
const t = slope / stdErr;
|
|
48956
|
-
const pValue =
|
|
48972
|
+
const pValue = studentTTwoSidedP(t, df);
|
|
48957
48973
|
return { slope, intercept, rValue, rSquared: rValue * rValue, pValue, stdErr };
|
|
48958
48974
|
}
|
|
48959
48975
|
|
package/dist/ml/ols.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ols.d.ts","sourceRoot":"","sources":["../../src/ml/ols.ts"],"names":[],"mappings":"AAUA,yBAAyB;AACzB,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wEAAwE;AACxE,MAAM,WAAW,SAAS;IACxB,0DAA0D;IAC1D,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"ols.d.ts","sourceRoot":"","sources":["../../src/ml/ols.ts"],"names":[],"mappings":"AAUA,yBAAyB;AACzB,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wEAAwE;AACxE,MAAM,WAAW,SAAS;IACxB,0DAA0D;IAC1D,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAsFD;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,CAmC5E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/mathts-functions",
|
|
3
|
-
"version": "0.68.
|
|
3
|
+
"version": "0.68.4",
|
|
4
4
|
"description": "Mathematical functions for MathTS - arithmetic, algebra, trigonometry, statistics, and more",
|
|
5
5
|
"author": "Daniel Simon Jr.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"build:prod": "tsup src/index.ts --format esm --clean --minify --treeshake && tsc -p tsconfig.dts.json && node scripts/copy-wasm.mjs"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@danielsimonjr/mathts-core": "^0.18.
|
|
37
|
+
"@danielsimonjr/mathts-core": "^0.18.1",
|
|
38
38
|
"@danielsimonjr/mathts-expression": "^0.10.2",
|
|
39
39
|
"@danielsimonjr/mathts-gpu": "^0.2.1",
|
|
40
40
|
"@danielsimonjr/mathts-matrix": "^0.7.8",
|