eslint
This commit is contained in:
parent
d85cd58acd
commit
597c6efc9b
91 changed files with 2224 additions and 1400 deletions
|
|
@ -488,7 +488,7 @@ export function dccModel(
|
|||
const T = data[0].length;
|
||||
|
||||
// Initialize parameters [alpha, beta]
|
||||
let params = [0.01, 0.95];
|
||||
const params = [0.01, 0.95];
|
||||
|
||||
// Standardize data (assume unit variance for simplicity)
|
||||
const standardizedData = data.map(series => {
|
||||
|
|
@ -918,7 +918,7 @@ function shuffleArray<T>(array: T[]): T[] {
|
|||
* Helper function to calculate the average of an array of numbers
|
||||
*/
|
||||
function average(arr: number[]): number {
|
||||
if (arr.length === 0) return 0;
|
||||
if (arr.length === 0) {return 0;}
|
||||
return arr.reduce((a, b) => a + b, 0) / arr.length;
|
||||
}
|
||||
|
||||
|
|
@ -963,8 +963,8 @@ function erf(x: number): number {
|
|||
|
||||
function betaIncomplete(a: number, b: number, x: number): number {
|
||||
// Better approximation of incomplete beta function
|
||||
if (x === 0) return 0;
|
||||
if (x === 1) return 1;
|
||||
if (x === 0) {return 0;}
|
||||
if (x === 1) {return 1;}
|
||||
|
||||
// Use continued fraction approximation (Lentz's algorithm)
|
||||
const fpmin = 1e-30;
|
||||
|
|
@ -984,7 +984,7 @@ function betaIncomplete(a: number, b: number, x: number): number {
|
|||
function betaContinuedFraction(a: number, b: number, x: number): number {
|
||||
let c = 1;
|
||||
let d = 1 - ((a + b) * x) / (a + 1);
|
||||
if (Math.abs(d) < fpmin) d = fpmin;
|
||||
if (Math.abs(d) < fpmin) {d = fpmin;}
|
||||
d = 1 / d;
|
||||
let h = d;
|
||||
|
||||
|
|
@ -992,22 +992,22 @@ function betaIncomplete(a: number, b: number, x: number): number {
|
|||
const m2 = 2 * m;
|
||||
const aa = (m * (b - m) * x) / ((a + m2 - 1) * (a + m2));
|
||||
d = 1 + aa * d;
|
||||
if (Math.abs(d) < fpmin) d = fpmin;
|
||||
if (Math.abs(d) < fpmin) {d = fpmin;}
|
||||
c = 1 + aa / c;
|
||||
if (Math.abs(c) < fpmin) c = fpmin;
|
||||
if (Math.abs(c) < fpmin) {c = fpmin;}
|
||||
d = 1 / d;
|
||||
h *= d * c;
|
||||
|
||||
const bb = (-(a + m) * (a + b + m) * x) / ((a + m2) * (a + m2 + 1));
|
||||
d = 1 + bb * d;
|
||||
if (Math.abs(d) < fpmin) d = fpmin;
|
||||
if (Math.abs(d) < fpmin) {d = fpmin;}
|
||||
c = 1 + bb / c;
|
||||
if (Math.abs(c) < fpmin) c = fpmin;
|
||||
if (Math.abs(c) < fpmin) {c = fpmin;}
|
||||
d = 1 / d;
|
||||
const del = d * c;
|
||||
h *= del;
|
||||
|
||||
if (Math.abs(del - 1) < eps) break;
|
||||
if (Math.abs(del - 1) < eps) {break;}
|
||||
}
|
||||
|
||||
return h;
|
||||
|
|
@ -1055,11 +1055,11 @@ function eigenDecomposition(matrix: number[][]): {
|
|||
const newLambda = Av.reduce((sum, val, i) => sum + val * v[i], 0);
|
||||
const norm = Math.sqrt(Av.reduce((sum, val) => sum + val * val, 0));
|
||||
|
||||
if (norm === 0) break;
|
||||
if (norm === 0) {break;}
|
||||
|
||||
v = Av.map(val => val / norm);
|
||||
|
||||
if (Math.abs(newLambda - lambda) < 1e-10) break;
|
||||
if (Math.abs(newLambda - lambda) < 1e-10) {break;}
|
||||
lambda = newLambda;
|
||||
}
|
||||
|
||||
|
|
@ -1215,8 +1215,8 @@ function arModel(y: number[], lag: number): { rss: number } {
|
|||
|
||||
function fCDF(f: number, df1: number, df2: number): number {
|
||||
// Approximation for F distribution CDF
|
||||
if (f <= 0) return 0;
|
||||
if (f === Infinity) return 1;
|
||||
if (f <= 0) {return 0;}
|
||||
if (f === Infinity) {return 1;}
|
||||
|
||||
const x = df2 / (df2 + df1 * f);
|
||||
return 1 - betaIncomplete(df2 / 2, df1 / 2, x);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue