qesuite 1.0.13 → 1.0.15
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/index.d.mts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +109 -16
- package/dist/index.mjs +109 -16
- package/index.ts +118 -4
- package/package.json +1 -1
- package/versions/1_0_14.md +1 -0
- package/versions/1_0_15.md +15 -0
package/dist/index.d.mts
CHANGED
|
@@ -329,6 +329,10 @@ declare const Distributions: {
|
|
|
329
329
|
*/
|
|
330
330
|
pdf(x: number, a: number, b: number): number;
|
|
331
331
|
};
|
|
332
|
+
ChiSq: {
|
|
333
|
+
cdf(x: number, df: number): number;
|
|
334
|
+
RightTail(x: number, df: number): number;
|
|
335
|
+
};
|
|
332
336
|
Exponential: {
|
|
333
337
|
/**
|
|
334
338
|
* Cumulative Distribution Function. Calculates the probability of a random variable with a value less than or equal to x occuring from the exponential distribution with the specified scale parameter and optional threshold parameter.
|
|
@@ -588,6 +592,23 @@ declare const Distributions: {
|
|
|
588
592
|
* @param scale [OPTIONAL] (σ): The scale parameter of the specified distribution. The scale parameter of the normal distribution is equivalent to the Standard Deviation.
|
|
589
593
|
*/
|
|
590
594
|
pdf(x: number, location?: number, scale?: number): number;
|
|
595
|
+
RyanJoiner: {
|
|
596
|
+
Test(data: number[]): {
|
|
597
|
+
RJ: number;
|
|
598
|
+
critical: number;
|
|
599
|
+
};
|
|
600
|
+
Critical(data: number[]): number;
|
|
601
|
+
};
|
|
602
|
+
JarqueBera(data: number[]): {
|
|
603
|
+
JB: number;
|
|
604
|
+
};
|
|
605
|
+
Chebyshev(data: number[], spec: Specification): number;
|
|
606
|
+
Skewness(data: any): number;
|
|
607
|
+
Kurtosis(data: any): number;
|
|
608
|
+
KolmogorovSmirnov(data: any): {
|
|
609
|
+
KS: number;
|
|
610
|
+
p: any;
|
|
611
|
+
};
|
|
591
612
|
};
|
|
592
613
|
T: {
|
|
593
614
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -329,6 +329,10 @@ declare const Distributions: {
|
|
|
329
329
|
*/
|
|
330
330
|
pdf(x: number, a: number, b: number): number;
|
|
331
331
|
};
|
|
332
|
+
ChiSq: {
|
|
333
|
+
cdf(x: number, df: number): number;
|
|
334
|
+
RightTail(x: number, df: number): number;
|
|
335
|
+
};
|
|
332
336
|
Exponential: {
|
|
333
337
|
/**
|
|
334
338
|
* Cumulative Distribution Function. Calculates the probability of a random variable with a value less than or equal to x occuring from the exponential distribution with the specified scale parameter and optional threshold parameter.
|
|
@@ -588,6 +592,23 @@ declare const Distributions: {
|
|
|
588
592
|
* @param scale [OPTIONAL] (σ): The scale parameter of the specified distribution. The scale parameter of the normal distribution is equivalent to the Standard Deviation.
|
|
589
593
|
*/
|
|
590
594
|
pdf(x: number, location?: number, scale?: number): number;
|
|
595
|
+
RyanJoiner: {
|
|
596
|
+
Test(data: number[]): {
|
|
597
|
+
RJ: number;
|
|
598
|
+
critical: number;
|
|
599
|
+
};
|
|
600
|
+
Critical(data: number[]): number;
|
|
601
|
+
};
|
|
602
|
+
JarqueBera(data: number[]): {
|
|
603
|
+
JB: number;
|
|
604
|
+
};
|
|
605
|
+
Chebyshev(data: number[], spec: Specification): number;
|
|
606
|
+
Skewness(data: any): number;
|
|
607
|
+
Kurtosis(data: any): number;
|
|
608
|
+
KolmogorovSmirnov(data: any): {
|
|
609
|
+
KS: number;
|
|
610
|
+
p: any;
|
|
611
|
+
};
|
|
591
612
|
};
|
|
592
613
|
T: {
|
|
593
614
|
/**
|
package/dist/index.js
CHANGED
|
@@ -975,6 +975,17 @@ var Distributions = {
|
|
|
975
975
|
return Math.pow(x, a - 1) * Math.pow(1 - x, b - 1) / Beta.fn(a, b);
|
|
976
976
|
}
|
|
977
977
|
},
|
|
978
|
+
ChiSq: {
|
|
979
|
+
cdf(x, df) {
|
|
980
|
+
if (df === 2) {
|
|
981
|
+
return 1 - Math.exp(-x / 2);
|
|
982
|
+
}
|
|
983
|
+
return NaN;
|
|
984
|
+
},
|
|
985
|
+
RightTail(x, df) {
|
|
986
|
+
return 1 - Distributions.ChiSq.cdf(x, df);
|
|
987
|
+
}
|
|
988
|
+
},
|
|
978
989
|
Exponential: {
|
|
979
990
|
/**
|
|
980
991
|
* Cumulative Distribution Function. Calculates the probability of a random variable with a value less than or equal to x occuring from the exponential distribution with the specified scale parameter and optional threshold parameter.
|
|
@@ -1469,6 +1480,100 @@ var Distributions = {
|
|
|
1469
1480
|
*/
|
|
1470
1481
|
pdf(x, location = 0, scale = 1) {
|
|
1471
1482
|
return 1 / (scale * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((x - location) / scale, 2));
|
|
1483
|
+
},
|
|
1484
|
+
RyanJoiner: {
|
|
1485
|
+
Test(data) {
|
|
1486
|
+
let N = data.length;
|
|
1487
|
+
let Z = [];
|
|
1488
|
+
let Y = data.sort(function(a, b) {
|
|
1489
|
+
return a - b;
|
|
1490
|
+
});
|
|
1491
|
+
let numSum = 0;
|
|
1492
|
+
let denSum = 0;
|
|
1493
|
+
let mean = Mean(data);
|
|
1494
|
+
let variance = Math.pow(StDev.S(data), 2);
|
|
1495
|
+
for (let i = 0; i < N; i++) {
|
|
1496
|
+
Z[i] = Distributions.Normal.inv((i + 1 - 0.375) / (N + 0.25));
|
|
1497
|
+
numSum += Z[i] * (Y[i] - mean);
|
|
1498
|
+
denSum += Math.pow(Z[i], 2);
|
|
1499
|
+
}
|
|
1500
|
+
let RJ = numSum / Math.sqrt(variance * (N - 1) * denSum);
|
|
1501
|
+
return {
|
|
1502
|
+
RJ,
|
|
1503
|
+
critical: Distributions.Normal.RyanJoiner.Critical(data)
|
|
1504
|
+
};
|
|
1505
|
+
},
|
|
1506
|
+
Critical(data) {
|
|
1507
|
+
let N = data.length;
|
|
1508
|
+
return 1.0063 - 0.6118 / N + 1.3505 / Math.pow(N, 2) - 0.1288 / Math.pow(N, 0.5);
|
|
1509
|
+
}
|
|
1510
|
+
},
|
|
1511
|
+
JarqueBera(data) {
|
|
1512
|
+
let N = data.length;
|
|
1513
|
+
let S = Distributions.Normal.Skewness(data);
|
|
1514
|
+
let K = Distributions.Normal.Kurtosis(data);
|
|
1515
|
+
let JB = N / 6 * (Math.pow(S, 2) + 0.25 * Math.pow(K, 2));
|
|
1516
|
+
return {
|
|
1517
|
+
JB
|
|
1518
|
+
// p: Distributions.ChiSq.RightTail(JB, 2)
|
|
1519
|
+
};
|
|
1520
|
+
},
|
|
1521
|
+
Chebyshev(data, spec) {
|
|
1522
|
+
let mean = Mean(data);
|
|
1523
|
+
let standard_deviation = StDev.S(data);
|
|
1524
|
+
let AbsUSL = spec.USL - mean;
|
|
1525
|
+
let AbsLSL = mean - spec.LSL;
|
|
1526
|
+
let min;
|
|
1527
|
+
if (AbsUSL < AbsLSL) {
|
|
1528
|
+
min = AbsUSL;
|
|
1529
|
+
} else {
|
|
1530
|
+
min = AbsLSL;
|
|
1531
|
+
}
|
|
1532
|
+
return min / (10 * standard_deviation);
|
|
1533
|
+
},
|
|
1534
|
+
Skewness(data) {
|
|
1535
|
+
let N = data.length;
|
|
1536
|
+
let mean = Mean(data);
|
|
1537
|
+
let numsum = 0;
|
|
1538
|
+
let densum = 0;
|
|
1539
|
+
for (let i = 0; i < N; i++) {
|
|
1540
|
+
let inner = data[i] - mean;
|
|
1541
|
+
numsum += Math.pow(inner, 3);
|
|
1542
|
+
}
|
|
1543
|
+
let num = numsum * N;
|
|
1544
|
+
let den = (N - 2) * (N - 1) * Math.pow(StDev.S(data), 3);
|
|
1545
|
+
return num / den;
|
|
1546
|
+
},
|
|
1547
|
+
Kurtosis(data) {
|
|
1548
|
+
let N = data.length;
|
|
1549
|
+
let mean = Mean(data);
|
|
1550
|
+
let numsum = 0;
|
|
1551
|
+
let densum = 0;
|
|
1552
|
+
for (let i = 0; i < N; i++) {
|
|
1553
|
+
let inner = data[i] - mean;
|
|
1554
|
+
numsum += Math.pow(inner, 4);
|
|
1555
|
+
}
|
|
1556
|
+
let num = numsum * N * (N + 1) / ((N - 1) * (N - 2) * (N - 3) * Math.pow(StDev.S(data), 4)) - 3 * Math.pow(N - 1, 2) / ((N - 2) * (N - 3));
|
|
1557
|
+
return num;
|
|
1558
|
+
},
|
|
1559
|
+
KolmogorovSmirnov(data) {
|
|
1560
|
+
let N = data.length;
|
|
1561
|
+
data.sort();
|
|
1562
|
+
let mean = Mean(data);
|
|
1563
|
+
let std = StDev.S(data);
|
|
1564
|
+
let dMinusArray = [];
|
|
1565
|
+
let dPlusArray = [];
|
|
1566
|
+
for (let i = 1; i <= N; i++) {
|
|
1567
|
+
let Z_i = this.cdf(data[i - 1], mean, std);
|
|
1568
|
+
dPlusArray.push(i / N - Z_i);
|
|
1569
|
+
dMinusArray.push(Z_i - (i - 1) / N);
|
|
1570
|
+
}
|
|
1571
|
+
let KS = Math.max(Math.max(...dMinusArray), Math.max(...dPlusArray));
|
|
1572
|
+
let p = GoodnessOfFit.AndersonDarling.p(KS, N);
|
|
1573
|
+
return {
|
|
1574
|
+
KS,
|
|
1575
|
+
p
|
|
1576
|
+
};
|
|
1472
1577
|
}
|
|
1473
1578
|
},
|
|
1474
1579
|
T: {
|
|
@@ -2172,20 +2277,6 @@ function CreateCanvas(width, height) {
|
|
|
2172
2277
|
canvas.width = width;
|
|
2173
2278
|
return canvas;
|
|
2174
2279
|
}
|
|
2175
|
-
function AddSolidBackground(canvas, color) {
|
|
2176
|
-
let newCanvas = CreateCanvas(canvas.width + 100, canvas.height);
|
|
2177
|
-
let newCtx = newCanvas.getContext("2d");
|
|
2178
|
-
if (newCtx) {
|
|
2179
|
-
newCtx.beginPath();
|
|
2180
|
-
newCtx.fillStyle = color;
|
|
2181
|
-
newCtx.fillRect(0, 0, newCanvas.height + 100, newCanvas.width + 100);
|
|
2182
|
-
newCtx.closePath();
|
|
2183
|
-
newCtx.beginPath();
|
|
2184
|
-
newCtx.drawImage(canvas, 50, 0);
|
|
2185
|
-
newCtx.closePath();
|
|
2186
|
-
}
|
|
2187
|
-
return newCanvas;
|
|
2188
|
-
}
|
|
2189
2280
|
function AddPlotArea(ctx, chartSettings) {
|
|
2190
2281
|
let width = chartSettings.width - chartSettings.margins.left - chartSettings.margins.right;
|
|
2191
2282
|
let height = chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom;
|
|
@@ -2951,7 +3042,10 @@ function CreateSummaryChart(charts, title) {
|
|
|
2951
3042
|
if (!ctx) {
|
|
2952
3043
|
return canvas;
|
|
2953
3044
|
}
|
|
3045
|
+
ctx.fillStyle = "white";
|
|
3046
|
+
ctx.fillRect(0, 0, width + padding, height + 250);
|
|
2954
3047
|
let fontsize = 96;
|
|
3048
|
+
ctx.fillStyle = "black";
|
|
2955
3049
|
ctx.font = `${fontsize}px calibri`;
|
|
2956
3050
|
ctx.textAlign = "center";
|
|
2957
3051
|
let lines = getLines(ctx, title, width);
|
|
@@ -2971,8 +3065,7 @@ function CreateSummaryChart(charts, title) {
|
|
|
2971
3065
|
ctx.drawImage(charts[2 * i + 1], width / 2 + padding, y, width / 2, height / rowCount - padding);
|
|
2972
3066
|
}
|
|
2973
3067
|
}
|
|
2974
|
-
|
|
2975
|
-
return newCanvas;
|
|
3068
|
+
return canvas;
|
|
2976
3069
|
}
|
|
2977
3070
|
function getLines(ctx, text, maxWidth) {
|
|
2978
3071
|
var words = text.split(" ");
|
package/dist/index.mjs
CHANGED
|
@@ -888,6 +888,17 @@ var Distributions = {
|
|
|
888
888
|
return Math.pow(x, a - 1) * Math.pow(1 - x, b - 1) / Beta.fn(a, b);
|
|
889
889
|
}
|
|
890
890
|
},
|
|
891
|
+
ChiSq: {
|
|
892
|
+
cdf(x, df) {
|
|
893
|
+
if (df === 2) {
|
|
894
|
+
return 1 - Math.exp(-x / 2);
|
|
895
|
+
}
|
|
896
|
+
return NaN;
|
|
897
|
+
},
|
|
898
|
+
RightTail(x, df) {
|
|
899
|
+
return 1 - Distributions.ChiSq.cdf(x, df);
|
|
900
|
+
}
|
|
901
|
+
},
|
|
891
902
|
Exponential: {
|
|
892
903
|
/**
|
|
893
904
|
* Cumulative Distribution Function. Calculates the probability of a random variable with a value less than or equal to x occuring from the exponential distribution with the specified scale parameter and optional threshold parameter.
|
|
@@ -1382,6 +1393,100 @@ var Distributions = {
|
|
|
1382
1393
|
*/
|
|
1383
1394
|
pdf(x, location = 0, scale = 1) {
|
|
1384
1395
|
return 1 / (scale * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((x - location) / scale, 2));
|
|
1396
|
+
},
|
|
1397
|
+
RyanJoiner: {
|
|
1398
|
+
Test(data) {
|
|
1399
|
+
let N = data.length;
|
|
1400
|
+
let Z = [];
|
|
1401
|
+
let Y = data.sort(function(a, b) {
|
|
1402
|
+
return a - b;
|
|
1403
|
+
});
|
|
1404
|
+
let numSum = 0;
|
|
1405
|
+
let denSum = 0;
|
|
1406
|
+
let mean = Mean(data);
|
|
1407
|
+
let variance = Math.pow(StDev.S(data), 2);
|
|
1408
|
+
for (let i = 0; i < N; i++) {
|
|
1409
|
+
Z[i] = Distributions.Normal.inv((i + 1 - 0.375) / (N + 0.25));
|
|
1410
|
+
numSum += Z[i] * (Y[i] - mean);
|
|
1411
|
+
denSum += Math.pow(Z[i], 2);
|
|
1412
|
+
}
|
|
1413
|
+
let RJ = numSum / Math.sqrt(variance * (N - 1) * denSum);
|
|
1414
|
+
return {
|
|
1415
|
+
RJ,
|
|
1416
|
+
critical: Distributions.Normal.RyanJoiner.Critical(data)
|
|
1417
|
+
};
|
|
1418
|
+
},
|
|
1419
|
+
Critical(data) {
|
|
1420
|
+
let N = data.length;
|
|
1421
|
+
return 1.0063 - 0.6118 / N + 1.3505 / Math.pow(N, 2) - 0.1288 / Math.pow(N, 0.5);
|
|
1422
|
+
}
|
|
1423
|
+
},
|
|
1424
|
+
JarqueBera(data) {
|
|
1425
|
+
let N = data.length;
|
|
1426
|
+
let S = Distributions.Normal.Skewness(data);
|
|
1427
|
+
let K = Distributions.Normal.Kurtosis(data);
|
|
1428
|
+
let JB = N / 6 * (Math.pow(S, 2) + 0.25 * Math.pow(K, 2));
|
|
1429
|
+
return {
|
|
1430
|
+
JB
|
|
1431
|
+
// p: Distributions.ChiSq.RightTail(JB, 2)
|
|
1432
|
+
};
|
|
1433
|
+
},
|
|
1434
|
+
Chebyshev(data, spec) {
|
|
1435
|
+
let mean = Mean(data);
|
|
1436
|
+
let standard_deviation = StDev.S(data);
|
|
1437
|
+
let AbsUSL = spec.USL - mean;
|
|
1438
|
+
let AbsLSL = mean - spec.LSL;
|
|
1439
|
+
let min;
|
|
1440
|
+
if (AbsUSL < AbsLSL) {
|
|
1441
|
+
min = AbsUSL;
|
|
1442
|
+
} else {
|
|
1443
|
+
min = AbsLSL;
|
|
1444
|
+
}
|
|
1445
|
+
return min / (10 * standard_deviation);
|
|
1446
|
+
},
|
|
1447
|
+
Skewness(data) {
|
|
1448
|
+
let N = data.length;
|
|
1449
|
+
let mean = Mean(data);
|
|
1450
|
+
let numsum = 0;
|
|
1451
|
+
let densum = 0;
|
|
1452
|
+
for (let i = 0; i < N; i++) {
|
|
1453
|
+
let inner = data[i] - mean;
|
|
1454
|
+
numsum += Math.pow(inner, 3);
|
|
1455
|
+
}
|
|
1456
|
+
let num = numsum * N;
|
|
1457
|
+
let den = (N - 2) * (N - 1) * Math.pow(StDev.S(data), 3);
|
|
1458
|
+
return num / den;
|
|
1459
|
+
},
|
|
1460
|
+
Kurtosis(data) {
|
|
1461
|
+
let N = data.length;
|
|
1462
|
+
let mean = Mean(data);
|
|
1463
|
+
let numsum = 0;
|
|
1464
|
+
let densum = 0;
|
|
1465
|
+
for (let i = 0; i < N; i++) {
|
|
1466
|
+
let inner = data[i] - mean;
|
|
1467
|
+
numsum += Math.pow(inner, 4);
|
|
1468
|
+
}
|
|
1469
|
+
let num = numsum * N * (N + 1) / ((N - 1) * (N - 2) * (N - 3) * Math.pow(StDev.S(data), 4)) - 3 * Math.pow(N - 1, 2) / ((N - 2) * (N - 3));
|
|
1470
|
+
return num;
|
|
1471
|
+
},
|
|
1472
|
+
KolmogorovSmirnov(data) {
|
|
1473
|
+
let N = data.length;
|
|
1474
|
+
data.sort();
|
|
1475
|
+
let mean = Mean(data);
|
|
1476
|
+
let std = StDev.S(data);
|
|
1477
|
+
let dMinusArray = [];
|
|
1478
|
+
let dPlusArray = [];
|
|
1479
|
+
for (let i = 1; i <= N; i++) {
|
|
1480
|
+
let Z_i = this.cdf(data[i - 1], mean, std);
|
|
1481
|
+
dPlusArray.push(i / N - Z_i);
|
|
1482
|
+
dMinusArray.push(Z_i - (i - 1) / N);
|
|
1483
|
+
}
|
|
1484
|
+
let KS = Math.max(Math.max(...dMinusArray), Math.max(...dPlusArray));
|
|
1485
|
+
let p = GoodnessOfFit.AndersonDarling.p(KS, N);
|
|
1486
|
+
return {
|
|
1487
|
+
KS,
|
|
1488
|
+
p
|
|
1489
|
+
};
|
|
1385
1490
|
}
|
|
1386
1491
|
},
|
|
1387
1492
|
T: {
|
|
@@ -2085,20 +2190,6 @@ function CreateCanvas(width, height) {
|
|
|
2085
2190
|
canvas.width = width;
|
|
2086
2191
|
return canvas;
|
|
2087
2192
|
}
|
|
2088
|
-
function AddSolidBackground(canvas, color) {
|
|
2089
|
-
let newCanvas = CreateCanvas(canvas.width + 100, canvas.height);
|
|
2090
|
-
let newCtx = newCanvas.getContext("2d");
|
|
2091
|
-
if (newCtx) {
|
|
2092
|
-
newCtx.beginPath();
|
|
2093
|
-
newCtx.fillStyle = color;
|
|
2094
|
-
newCtx.fillRect(0, 0, newCanvas.height + 100, newCanvas.width + 100);
|
|
2095
|
-
newCtx.closePath();
|
|
2096
|
-
newCtx.beginPath();
|
|
2097
|
-
newCtx.drawImage(canvas, 50, 0);
|
|
2098
|
-
newCtx.closePath();
|
|
2099
|
-
}
|
|
2100
|
-
return newCanvas;
|
|
2101
|
-
}
|
|
2102
2193
|
function AddPlotArea(ctx, chartSettings) {
|
|
2103
2194
|
let width = chartSettings.width - chartSettings.margins.left - chartSettings.margins.right;
|
|
2104
2195
|
let height = chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom;
|
|
@@ -2864,7 +2955,10 @@ function CreateSummaryChart(charts, title) {
|
|
|
2864
2955
|
if (!ctx) {
|
|
2865
2956
|
return canvas;
|
|
2866
2957
|
}
|
|
2958
|
+
ctx.fillStyle = "white";
|
|
2959
|
+
ctx.fillRect(0, 0, width + padding, height + 250);
|
|
2867
2960
|
let fontsize = 96;
|
|
2961
|
+
ctx.fillStyle = "black";
|
|
2868
2962
|
ctx.font = `${fontsize}px calibri`;
|
|
2869
2963
|
ctx.textAlign = "center";
|
|
2870
2964
|
let lines = getLines(ctx, title, width);
|
|
@@ -2884,8 +2978,7 @@ function CreateSummaryChart(charts, title) {
|
|
|
2884
2978
|
ctx.drawImage(charts[2 * i + 1], width / 2 + padding, y, width / 2, height / rowCount - padding);
|
|
2885
2979
|
}
|
|
2886
2980
|
}
|
|
2887
|
-
|
|
2888
|
-
return newCanvas;
|
|
2981
|
+
return canvas;
|
|
2889
2982
|
}
|
|
2890
2983
|
function getLines(ctx, text, maxWidth) {
|
|
2891
2984
|
var words = text.split(" ");
|
package/index.ts
CHANGED
|
@@ -1054,7 +1054,18 @@ export const Distributions = {
|
|
|
1054
1054
|
pdf(x: number, a: number, b: number){
|
|
1055
1055
|
return (Math.pow(x, a - 1) * Math.pow(1 - x, b - 1))/Beta.fn(a, b);
|
|
1056
1056
|
}
|
|
1057
|
-
},
|
|
1057
|
+
},
|
|
1058
|
+
ChiSq: {
|
|
1059
|
+
cdf(x: number, df: number){
|
|
1060
|
+
if(df === 2){
|
|
1061
|
+
return 1 - Math.exp(-x/2);
|
|
1062
|
+
}
|
|
1063
|
+
return NaN
|
|
1064
|
+
},
|
|
1065
|
+
RightTail(x: number, df: number){
|
|
1066
|
+
return 1 - Distributions.ChiSq.cdf(x, df);
|
|
1067
|
+
}
|
|
1068
|
+
},
|
|
1058
1069
|
Exponential: {
|
|
1059
1070
|
/**
|
|
1060
1071
|
* Cumulative Distribution Function. Calculates the probability of a random variable with a value less than or equal to x occuring from the exponential distribution with the specified scale parameter and optional threshold parameter.
|
|
@@ -1546,8 +1557,107 @@ export const Distributions = {
|
|
|
1546
1557
|
*/
|
|
1547
1558
|
pdf(x: number, location: number = 0, scale: number = 1) {
|
|
1548
1559
|
return (1 / (scale * Math.sqrt(2 * Math.PI))) * Math.exp(-.5 * Math.pow((x - location) / scale, 2))
|
|
1560
|
+
},
|
|
1561
|
+
RyanJoiner: {
|
|
1562
|
+
Test(data: number[]){
|
|
1563
|
+
let N = data.length;
|
|
1564
|
+
|
|
1565
|
+
let Z: number[] = [];
|
|
1566
|
+
let Y = data.sort(function (a, b){return a-b});
|
|
1567
|
+
let numSum = 0;
|
|
1568
|
+
let denSum = 0;
|
|
1569
|
+
let mean = Mean(data);
|
|
1570
|
+
let variance = Math.pow(StDev.S(data), 2);
|
|
1571
|
+
|
|
1572
|
+
for(let i = 0; i < N; i++){
|
|
1573
|
+
Z[i] = Distributions.Normal.inv((i + 1 - 0.375)/ (N + 0.25))
|
|
1574
|
+
numSum += Z[i]*(Y[i]-mean);
|
|
1575
|
+
denSum += Math.pow(Z[i], 2);
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
let RJ = numSum/Math.sqrt(variance*(N-1)*denSum);
|
|
1579
|
+
return {
|
|
1580
|
+
RJ: RJ,
|
|
1581
|
+
critical: Distributions.Normal.RyanJoiner.Critical(data)
|
|
1582
|
+
}
|
|
1583
|
+
},
|
|
1584
|
+
Critical(data: number[]){
|
|
1585
|
+
let N = data.length;
|
|
1586
|
+
return 1.0063-(0.6118/N)+(1.3505/Math.pow(N, 2))-(.1288/Math.pow(N, .5))
|
|
1587
|
+
}
|
|
1588
|
+
},
|
|
1589
|
+
JarqueBera(data: number[]){
|
|
1590
|
+
let N = data.length;
|
|
1591
|
+
let S = Distributions.Normal.Skewness(data);
|
|
1592
|
+
let K = Distributions.Normal.Kurtosis(data);
|
|
1593
|
+
|
|
1594
|
+
let JB = (N/6)*(Math.pow(S, 2) + .25 * Math.pow(K, 2));
|
|
1595
|
+
return {
|
|
1596
|
+
JB: JB,
|
|
1597
|
+
// p: Distributions.ChiSq.RightTail(JB, 2)
|
|
1598
|
+
}
|
|
1599
|
+
},
|
|
1600
|
+
Chebyshev(data: number[], spec: Specification){
|
|
1601
|
+
let mean = Mean(data);
|
|
1602
|
+
let standard_deviation =StDev.S(data);
|
|
1603
|
+
let AbsUSL = spec.USL - mean;
|
|
1604
|
+
let AbsLSL = mean - spec.LSL;
|
|
1605
|
+
let min;
|
|
1606
|
+
if(AbsUSL < AbsLSL){
|
|
1607
|
+
min = AbsUSL;
|
|
1608
|
+
}else{
|
|
1609
|
+
min = AbsLSL;
|
|
1610
|
+
}
|
|
1611
|
+
return min/(10*standard_deviation);
|
|
1612
|
+
},
|
|
1613
|
+
Skewness(data){
|
|
1614
|
+
// SRC: https://www.omnicalculator.com/statistics/skewness#what-are-skewness-and-kurtosis
|
|
1615
|
+
let N = data.length;
|
|
1616
|
+
let mean = Mean(data);
|
|
1617
|
+
let numsum = 0;
|
|
1618
|
+
let densum = 0;
|
|
1619
|
+
for(let i = 0; i < N; i++){
|
|
1620
|
+
let inner = data[i] - mean;
|
|
1621
|
+
numsum += Math.pow(inner, 3);
|
|
1622
|
+
}
|
|
1623
|
+
let num = numsum * N;
|
|
1624
|
+
let den = (N - 2) * (N - 1) * Math.pow(StDev.S(data),3)
|
|
1625
|
+
return num/den;
|
|
1626
|
+
},
|
|
1627
|
+
Kurtosis(data){
|
|
1628
|
+
// SRC: https://www.omnicalculator.com/statistics/skewness#what-are-skewness-and-kurtosis
|
|
1629
|
+
let N = data.length;
|
|
1630
|
+
let mean = Mean(data);
|
|
1631
|
+
let numsum = 0;
|
|
1632
|
+
let densum = 0;
|
|
1633
|
+
for (let i = 0; i < N; i++) {
|
|
1634
|
+
let inner = data[i] - mean;
|
|
1635
|
+
numsum += Math.pow(inner, 4);
|
|
1636
|
+
}
|
|
1637
|
+
let num = numsum * N * (N + 1) / ((N - 1) * (N - 2) * (N - 3) * Math.pow(StDev.S(data), 4)) - 3 * Math.pow(N - 1, 2) / ((N-2) * (N-3));
|
|
1638
|
+
return num;
|
|
1639
|
+
},
|
|
1640
|
+
KolmogorovSmirnov(data){
|
|
1641
|
+
let N = data.length;
|
|
1642
|
+
data.sort();
|
|
1643
|
+
let mean = Mean(data);
|
|
1644
|
+
let std = StDev.S(data);
|
|
1645
|
+
let dMinusArray: number[] = [];
|
|
1646
|
+
let dPlusArray: number[] = [];
|
|
1647
|
+
for(let i = 1; i <= N; i++){
|
|
1648
|
+
let Z_i = this.cdf(data[i-1], mean, std)
|
|
1649
|
+
dPlusArray.push((i/N)-Z_i);
|
|
1650
|
+
dMinusArray.push(Z_i-(i-1)/N);
|
|
1651
|
+
|
|
1652
|
+
}
|
|
1653
|
+
let KS = Math.max(Math.max(...dMinusArray),Math.max(...dPlusArray));
|
|
1654
|
+
let p = GoodnessOfFit.AndersonDarling.p(KS, N);
|
|
1655
|
+
return {
|
|
1656
|
+
KS: KS,
|
|
1657
|
+
p: p
|
|
1658
|
+
};
|
|
1549
1659
|
}
|
|
1550
|
-
|
|
1660
|
+
},
|
|
1551
1661
|
T: {
|
|
1552
1662
|
/**
|
|
1553
1663
|
* Cumulative Distribution Function. Calculates the probability of a random variable with a value less than or equal to x occuring from the T distribution with the specified degrees of freedom. (LEFT TAILED T-TEST)
|
|
@@ -3375,8 +3485,13 @@ export function CreateSummaryChart(charts: HTMLCanvasElement[], title: string){
|
|
|
3375
3485
|
let ctx = canvas.getContext('2d');
|
|
3376
3486
|
|
|
3377
3487
|
if(!ctx){return canvas}
|
|
3488
|
+
// Add Solid White Background
|
|
3489
|
+
ctx.fillStyle = "white"
|
|
3490
|
+
ctx.fillRect(0, 0, width + padding, height + 250);
|
|
3491
|
+
|
|
3378
3492
|
|
|
3379
3493
|
let fontsize = 96;
|
|
3494
|
+
ctx.fillStyle = "black"
|
|
3380
3495
|
ctx.font = `${fontsize}px calibri`;
|
|
3381
3496
|
ctx.textAlign ='center';
|
|
3382
3497
|
let lines: string[] = getLines(ctx, title, width);
|
|
@@ -3399,8 +3514,7 @@ export function CreateSummaryChart(charts: HTMLCanvasElement[], title: string){
|
|
|
3399
3514
|
}
|
|
3400
3515
|
}
|
|
3401
3516
|
|
|
3402
|
-
|
|
3403
|
-
return newCanvas;
|
|
3517
|
+
return canvas;
|
|
3404
3518
|
}
|
|
3405
3519
|
|
|
3406
3520
|
function getLines(ctx: any, text: string, maxWidth: number) {
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Removed AddSolidBackground from summary chart and replaced with a ctx.fillRect() call
|