qesuite 1.0.28 → 1.0.30
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +51 -16
- package/dist/index.mjs +50 -15
- package/index.ts +55 -18
- package/package.json +1 -1
- package/versions/1_0_29.md +1 -0
- package/versions/1_0_30.md +1 -0
package/dist/index.d.mts
CHANGED
|
@@ -846,7 +846,7 @@ declare function Sum(data: any[]): number;
|
|
|
846
846
|
* @customfunction
|
|
847
847
|
* @param data An array of numbers. The numbers can be supplied as number types or strings
|
|
848
848
|
*/
|
|
849
|
-
declare function
|
|
849
|
+
declare function Rang(data: any[]): number;
|
|
850
850
|
declare const UnbiasingConstant: {
|
|
851
851
|
/**
|
|
852
852
|
* Calculates the unbiasing constant based on the number N provided.
|
|
@@ -1134,4 +1134,4 @@ declare function GRRByPartChart(data: GRRData): HTMLCanvasElement;
|
|
|
1134
1134
|
declare function GRRPartxOperatorChart(data: GRRData): HTMLCanvasElement;
|
|
1135
1135
|
declare function CompileGRRObject(operators: any, parts: any, measurements: any): GRRData;
|
|
1136
1136
|
|
|
1137
|
-
export { AnovaTableTwoWay, AverageMovingRange, AxisSettings, Beta, CanvasDrawSettings, Capability, Chart, ChartSettings, CompileGRRObject, CreateBoxandWhiskerGraph, CreateCapabilityHistogram, CreateCapabilityPlot, CreateCategoricalBarGraph, CreateContinuousBarGraph, CreateScatterPlot, CreateSplitGraph, CreateStackedChart, CreateSummaryChart, CustomGridline, DataCollection, DataSet, Distributions, ERF, EngFont, FixedPointIteration, G1, G1Graphs, GRR, GRRByPartChart, GRRData, GRRGraphs, GRROperator, GRRPartxOperatorChart, GRRReplication, GageEvaluation, Gamma, GetFunctionValues, GetHistogramDataset, GoodnessOfFit, IndividualDistributionIdentification, IndividualDistributionPlots, IndividualValuePlot, LastObservationsChart, Line, Margin, MarkOutOfControl, MaximumLikelihoodParameters, Mean, Median, MovingRange, MovingRangeChart, NewtonRaphson, ObjectToArray, ParameterizedCDF, Point, QQPlot, QQPlotChart,
|
|
1137
|
+
export { AnovaTableTwoWay, AverageMovingRange, AxisSettings, Beta, CanvasDrawSettings, Capability, Chart, ChartSettings, CompileGRRObject, CreateBoxandWhiskerGraph, CreateCapabilityHistogram, CreateCapabilityPlot, CreateCategoricalBarGraph, CreateContinuousBarGraph, CreateScatterPlot, CreateSplitGraph, CreateStackedChart, CreateSummaryChart, CustomGridline, DataCollection, DataSet, Distributions, ERF, EngFont, FixedPointIteration, G1, G1Graphs, GRR, GRRByPartChart, GRRData, GRRGraphs, GRROperator, GRRPartxOperatorChart, GRRReplication, GageEvaluation, Gamma, GetFunctionValues, GetHistogramDataset, GoodnessOfFit, IndividualDistributionIdentification, IndividualDistributionPlots, IndividualValuePlot, LastObservationsChart, Line, Margin, MarkOutOfControl, MaximumLikelihoodParameters, Mean, Median, MovingRange, MovingRangeChart, NewtonRaphson, ObjectToArray, ParameterizedCDF, Point, QQPlot, QQPlotChart, Rang, RoundTO, SerializeData, Specification, StDev, Sum, UnbiasingConstant, VarianceComponents };
|
package/dist/index.d.ts
CHANGED
|
@@ -846,7 +846,7 @@ declare function Sum(data: any[]): number;
|
|
|
846
846
|
* @customfunction
|
|
847
847
|
* @param data An array of numbers. The numbers can be supplied as number types or strings
|
|
848
848
|
*/
|
|
849
|
-
declare function
|
|
849
|
+
declare function Rang(data: any[]): number;
|
|
850
850
|
declare const UnbiasingConstant: {
|
|
851
851
|
/**
|
|
852
852
|
* Calculates the unbiasing constant based on the number N provided.
|
|
@@ -1134,4 +1134,4 @@ declare function GRRByPartChart(data: GRRData): HTMLCanvasElement;
|
|
|
1134
1134
|
declare function GRRPartxOperatorChart(data: GRRData): HTMLCanvasElement;
|
|
1135
1135
|
declare function CompileGRRObject(operators: any, parts: any, measurements: any): GRRData;
|
|
1136
1136
|
|
|
1137
|
-
export { AnovaTableTwoWay, AverageMovingRange, AxisSettings, Beta, CanvasDrawSettings, Capability, Chart, ChartSettings, CompileGRRObject, CreateBoxandWhiskerGraph, CreateCapabilityHistogram, CreateCapabilityPlot, CreateCategoricalBarGraph, CreateContinuousBarGraph, CreateScatterPlot, CreateSplitGraph, CreateStackedChart, CreateSummaryChart, CustomGridline, DataCollection, DataSet, Distributions, ERF, EngFont, FixedPointIteration, G1, G1Graphs, GRR, GRRByPartChart, GRRData, GRRGraphs, GRROperator, GRRPartxOperatorChart, GRRReplication, GageEvaluation, Gamma, GetFunctionValues, GetHistogramDataset, GoodnessOfFit, IndividualDistributionIdentification, IndividualDistributionPlots, IndividualValuePlot, LastObservationsChart, Line, Margin, MarkOutOfControl, MaximumLikelihoodParameters, Mean, Median, MovingRange, MovingRangeChart, NewtonRaphson, ObjectToArray, ParameterizedCDF, Point, QQPlot, QQPlotChart,
|
|
1137
|
+
export { AnovaTableTwoWay, AverageMovingRange, AxisSettings, Beta, CanvasDrawSettings, Capability, Chart, ChartSettings, CompileGRRObject, CreateBoxandWhiskerGraph, CreateCapabilityHistogram, CreateCapabilityPlot, CreateCategoricalBarGraph, CreateContinuousBarGraph, CreateScatterPlot, CreateSplitGraph, CreateStackedChart, CreateSummaryChart, CustomGridline, DataCollection, DataSet, Distributions, ERF, EngFont, FixedPointIteration, G1, G1Graphs, GRR, GRRByPartChart, GRRData, GRRGraphs, GRROperator, GRRPartxOperatorChart, GRRReplication, GageEvaluation, Gamma, GetFunctionValues, GetHistogramDataset, GoodnessOfFit, IndividualDistributionIdentification, IndividualDistributionPlots, IndividualValuePlot, LastObservationsChart, Line, Margin, MarkOutOfControl, MaximumLikelihoodParameters, Mean, Median, MovingRange, MovingRangeChart, NewtonRaphson, ObjectToArray, ParameterizedCDF, Point, QQPlot, QQPlotChart, Rang, RoundTO, SerializeData, Specification, StDev, Sum, UnbiasingConstant, VarianceComponents };
|
package/dist/index.js
CHANGED
|
@@ -76,7 +76,7 @@ __export(QESuite_exports, {
|
|
|
76
76
|
Point: () => Point,
|
|
77
77
|
QQPlot: () => QQPlot,
|
|
78
78
|
QQPlotChart: () => QQPlotChart,
|
|
79
|
-
|
|
79
|
+
Rang: () => Rang,
|
|
80
80
|
RoundTO: () => RoundTO,
|
|
81
81
|
SerializeData: () => SerializeData,
|
|
82
82
|
Specification: () => Specification,
|
|
@@ -600,6 +600,7 @@ var Capability = {
|
|
|
600
600
|
let lastObservations = LastObservationsChart(data, 25, "Last 25 Observations");
|
|
601
601
|
let capabilityHistogram = CreateCapabilityHistogram(data, spec);
|
|
602
602
|
let capabilityPlot = CreateCapabilityPlot(data, spec);
|
|
603
|
+
console.log(Capability.Analysis(data, spec));
|
|
603
604
|
return {
|
|
604
605
|
charts: {
|
|
605
606
|
IndividualValue: individualValuePlot,
|
|
@@ -1498,7 +1499,7 @@ var Distributions = {
|
|
|
1498
1499
|
Test(data) {
|
|
1499
1500
|
let N = data.length;
|
|
1500
1501
|
let Z = [];
|
|
1501
|
-
let Y = data.sort(function(a, b) {
|
|
1502
|
+
let Y = [...data].sort(function(a, b) {
|
|
1502
1503
|
return a - b;
|
|
1503
1504
|
});
|
|
1504
1505
|
let numSum = 0;
|
|
@@ -1571,9 +1572,9 @@ var Distributions = {
|
|
|
1571
1572
|
},
|
|
1572
1573
|
KolmogorovSmirnov(data) {
|
|
1573
1574
|
let N = data.length;
|
|
1574
|
-
data.sort();
|
|
1575
|
-
let mean = Mean(
|
|
1576
|
-
let std = StDev.S(
|
|
1575
|
+
let sortedData = [...data].sort();
|
|
1576
|
+
let mean = Mean(sortedData);
|
|
1577
|
+
let std = StDev.S(sortedData);
|
|
1577
1578
|
let dMinusArray = [];
|
|
1578
1579
|
let dPlusArray = [];
|
|
1579
1580
|
for (let i = 1; i <= N; i++) {
|
|
@@ -1868,7 +1869,7 @@ var GoodnessOfFit = {
|
|
|
1868
1869
|
*/
|
|
1869
1870
|
AD(data, cdf) {
|
|
1870
1871
|
let N = data.length;
|
|
1871
|
-
let Y = data.sort(function(a, b) {
|
|
1872
|
+
let Y = [...data].sort(function(a, b) {
|
|
1872
1873
|
return a - b;
|
|
1873
1874
|
});
|
|
1874
1875
|
let S = 0;
|
|
@@ -1911,10 +1912,15 @@ var GoodnessOfFit = {
|
|
|
1911
1912
|
Test(data, cdf) {
|
|
1912
1913
|
let CDF;
|
|
1913
1914
|
if (typeof cdf === "string") {
|
|
1914
|
-
|
|
1915
|
+
if (GoodnessOfFit.Distributions[cdf]) {
|
|
1916
|
+
CDF = ParameterizedCDF(data, GoodnessOfFit.Distributions[cdf]);
|
|
1917
|
+
}
|
|
1915
1918
|
} else {
|
|
1916
1919
|
CDF = cdf;
|
|
1917
1920
|
}
|
|
1921
|
+
if (typeof CDF !== "function") {
|
|
1922
|
+
return { AD: void 0, p: void 0 };
|
|
1923
|
+
}
|
|
1918
1924
|
let AD = GoodnessOfFit.AndersonDarling.AD(data, CDF);
|
|
1919
1925
|
let p = GoodnessOfFit.AndersonDarling.p(AD, data.length);
|
|
1920
1926
|
return {
|
|
@@ -2032,8 +2038,8 @@ function IndividualDistributionPlots(data) {
|
|
|
2032
2038
|
gamma3p: QQPlotChart(data, "3-Parameter Gamma"),
|
|
2033
2039
|
largestExtremeValue: QQPlotChart(data, "Largest Extreme Value"),
|
|
2034
2040
|
logistic: QQPlotChart(data, "Logistic"),
|
|
2035
|
-
loglogistic: QQPlotChart(data, "LogLogistic"),
|
|
2036
|
-
lognormal: QQPlotChart(data, "LogNormal"),
|
|
2041
|
+
loglogistic: QQPlotChart(data, "2-Parameter LogLogistic"),
|
|
2042
|
+
lognormal: QQPlotChart(data, "2-Parameter LogNormal"),
|
|
2037
2043
|
smallestExtremeValue: QQPlotChart(data, "Smallest Extreme Value"),
|
|
2038
2044
|
weibull: QQPlotChart(data, "Weibull")
|
|
2039
2045
|
};
|
|
@@ -2044,7 +2050,7 @@ function IndividualDistributionPlots(data) {
|
|
|
2044
2050
|
}
|
|
2045
2051
|
var QQPlot = {
|
|
2046
2052
|
p(data, method = "Hazen") {
|
|
2047
|
-
let orderedData = data.sort();
|
|
2053
|
+
let orderedData = [...data].sort();
|
|
2048
2054
|
let PValues = [];
|
|
2049
2055
|
let N = orderedData.length;
|
|
2050
2056
|
for (let i = 1; i <= N; i++) {
|
|
@@ -2113,10 +2119,18 @@ function MovingRange(data, w = 2) {
|
|
|
2113
2119
|
for (let j = 0; j < w; j++) {
|
|
2114
2120
|
values.push(Number(data[h + j]));
|
|
2115
2121
|
}
|
|
2116
|
-
movingRange.push(
|
|
2122
|
+
movingRange.push(CalculateRange(values));
|
|
2117
2123
|
}
|
|
2118
2124
|
return movingRange;
|
|
2119
2125
|
}
|
|
2126
|
+
function CalculateRange(data) {
|
|
2127
|
+
let dataNumbers = data.map((d) => {
|
|
2128
|
+
return Number(d);
|
|
2129
|
+
});
|
|
2130
|
+
let max = Math.max(...dataNumbers);
|
|
2131
|
+
let min = Math.min(...dataNumbers);
|
|
2132
|
+
return max - min;
|
|
2133
|
+
}
|
|
2120
2134
|
var StDev = {
|
|
2121
2135
|
/**
|
|
2122
2136
|
* Calculates the population standard deviation of the array supplied.
|
|
@@ -2164,7 +2178,7 @@ function Sum(data) {
|
|
|
2164
2178
|
});
|
|
2165
2179
|
return sum;
|
|
2166
2180
|
}
|
|
2167
|
-
function
|
|
2181
|
+
function Rang(data) {
|
|
2168
2182
|
let dataNumbers = data.map((d) => {
|
|
2169
2183
|
return Number(d);
|
|
2170
2184
|
});
|
|
@@ -2502,13 +2516,13 @@ function SetCanvasTextProperties(ctx, font) {
|
|
|
2502
2516
|
ctx.font = `${font.font} ${font.fontSize}`;
|
|
2503
2517
|
ctx.fillStyle = font.fillColor;
|
|
2504
2518
|
}
|
|
2505
|
-
function AddInfoTable(ctx, data, x, y, width, height, title, font) {
|
|
2519
|
+
function AddInfoTable(ctx, data, x, y, width, height, title, lineHeight = 0, font) {
|
|
2506
2520
|
if (!font) {
|
|
2507
2521
|
font = new EngFont();
|
|
2508
2522
|
}
|
|
2509
2523
|
SetCanvasTextProperties(ctx, font);
|
|
2510
2524
|
ctx.beginPath();
|
|
2511
|
-
|
|
2525
|
+
lineHeight = lineHeight ? lineHeight : Number(font.fontSize.replace("px", "")) + 30;
|
|
2512
2526
|
ctx.textAlign = "center";
|
|
2513
2527
|
ctx.fillText(title, x + width / 2, y + Number(font.fontSize.replace("px", "")), width);
|
|
2514
2528
|
ctx.textAlign = "left";
|
|
@@ -3247,7 +3261,28 @@ function QQPlotChart(data, distribution = "Normal") {
|
|
|
3247
3261
|
return (x - params.location) / params.scale;
|
|
3248
3262
|
};
|
|
3249
3263
|
let middleLineChart = new Chart([], "function", "Middle Line", void 0, middleLine);
|
|
3250
|
-
|
|
3264
|
+
let chart = CreateStackedChart([middleLineChart, new Chart([dataset], "scatter")], `${distribution[0].toUpperCase()}${distribution.substring(1)} Probability Plot`, chartSettings);
|
|
3265
|
+
if (distribution.toLowerCase() === "normal" || distribution.toLowerCase().includes("boxcox")) {
|
|
3266
|
+
let AD = GoodnessOfFit.AndersonDarling.Test(data, GoodnessOfFit.Distributions.Normal);
|
|
3267
|
+
let RJ = Distributions.Normal.RyanJoiner.Test(data);
|
|
3268
|
+
let KS = Distributions.Normal.KolmogorovSmirnov(data);
|
|
3269
|
+
let JB = Distributions.Normal.JarqueBera(data);
|
|
3270
|
+
let ctx = chart.getContext("2d");
|
|
3271
|
+
if (ctx) {
|
|
3272
|
+
AddInfoTable(ctx, [{ key: "AD:", value: AD.AD }, { key: "p-value:", value: AD.p }, { key: "", value: "" }, { key: "RJ:", value: RJ.RJ }, { key: "crit.:", value: RJ.critical }, { key: "", value: "" }, { key: "KS:", value: KS.KS }, { key: "p-value:", value: KS.p }, { key: "", value: "" }, { key: "JB:", value: JB.JB }, { key: "p-value:", value: JB.p }], 1075, 150, 175, 100, "", 30);
|
|
3273
|
+
}
|
|
3274
|
+
} else {
|
|
3275
|
+
let dist = distribution.replace("-", "").replace("arameter", "").replace(/\s/g, "");
|
|
3276
|
+
if (dist.includes("2P")) {
|
|
3277
|
+
dist = dist.replace("2P", "").concat("2P");
|
|
3278
|
+
}
|
|
3279
|
+
let AD = GoodnessOfFit.AndersonDarling.Test(data, dist);
|
|
3280
|
+
let ctx = chart.getContext("2d");
|
|
3281
|
+
if (ctx && (AD.AD || AD.AD === Infinity || Number.isNaN(AD.AD)) && (AD.p || AD.p === Infinity || Number.isNaN(AD.p))) {
|
|
3282
|
+
AddInfoTable(ctx, [{ key: "AD:", value: AD.AD }, { key: "p-value:", value: AD.p }], 1075, 150, 175, 100, "", 30);
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
return chart;
|
|
3251
3286
|
}
|
|
3252
3287
|
function QQDistributionModification(p, distribution) {
|
|
3253
3288
|
if (distribution.toLowerCase().includes("weibull")) {
|
|
@@ -4002,7 +4037,7 @@ function SplitObjectArrayByProp(array, prop) {
|
|
|
4002
4037
|
Point,
|
|
4003
4038
|
QQPlot,
|
|
4004
4039
|
QQPlotChart,
|
|
4005
|
-
|
|
4040
|
+
Rang,
|
|
4006
4041
|
RoundTO,
|
|
4007
4042
|
SerializeData,
|
|
4008
4043
|
Specification,
|
package/dist/index.mjs
CHANGED
|
@@ -513,6 +513,7 @@ var Capability = {
|
|
|
513
513
|
let lastObservations = LastObservationsChart(data, 25, "Last 25 Observations");
|
|
514
514
|
let capabilityHistogram = CreateCapabilityHistogram(data, spec);
|
|
515
515
|
let capabilityPlot = CreateCapabilityPlot(data, spec);
|
|
516
|
+
console.log(Capability.Analysis(data, spec));
|
|
516
517
|
return {
|
|
517
518
|
charts: {
|
|
518
519
|
IndividualValue: individualValuePlot,
|
|
@@ -1411,7 +1412,7 @@ var Distributions = {
|
|
|
1411
1412
|
Test(data) {
|
|
1412
1413
|
let N = data.length;
|
|
1413
1414
|
let Z = [];
|
|
1414
|
-
let Y = data.sort(function(a, b) {
|
|
1415
|
+
let Y = [...data].sort(function(a, b) {
|
|
1415
1416
|
return a - b;
|
|
1416
1417
|
});
|
|
1417
1418
|
let numSum = 0;
|
|
@@ -1484,9 +1485,9 @@ var Distributions = {
|
|
|
1484
1485
|
},
|
|
1485
1486
|
KolmogorovSmirnov(data) {
|
|
1486
1487
|
let N = data.length;
|
|
1487
|
-
data.sort();
|
|
1488
|
-
let mean = Mean(
|
|
1489
|
-
let std = StDev.S(
|
|
1488
|
+
let sortedData = [...data].sort();
|
|
1489
|
+
let mean = Mean(sortedData);
|
|
1490
|
+
let std = StDev.S(sortedData);
|
|
1490
1491
|
let dMinusArray = [];
|
|
1491
1492
|
let dPlusArray = [];
|
|
1492
1493
|
for (let i = 1; i <= N; i++) {
|
|
@@ -1781,7 +1782,7 @@ var GoodnessOfFit = {
|
|
|
1781
1782
|
*/
|
|
1782
1783
|
AD(data, cdf) {
|
|
1783
1784
|
let N = data.length;
|
|
1784
|
-
let Y = data.sort(function(a, b) {
|
|
1785
|
+
let Y = [...data].sort(function(a, b) {
|
|
1785
1786
|
return a - b;
|
|
1786
1787
|
});
|
|
1787
1788
|
let S = 0;
|
|
@@ -1824,10 +1825,15 @@ var GoodnessOfFit = {
|
|
|
1824
1825
|
Test(data, cdf) {
|
|
1825
1826
|
let CDF;
|
|
1826
1827
|
if (typeof cdf === "string") {
|
|
1827
|
-
|
|
1828
|
+
if (GoodnessOfFit.Distributions[cdf]) {
|
|
1829
|
+
CDF = ParameterizedCDF(data, GoodnessOfFit.Distributions[cdf]);
|
|
1830
|
+
}
|
|
1828
1831
|
} else {
|
|
1829
1832
|
CDF = cdf;
|
|
1830
1833
|
}
|
|
1834
|
+
if (typeof CDF !== "function") {
|
|
1835
|
+
return { AD: void 0, p: void 0 };
|
|
1836
|
+
}
|
|
1831
1837
|
let AD = GoodnessOfFit.AndersonDarling.AD(data, CDF);
|
|
1832
1838
|
let p = GoodnessOfFit.AndersonDarling.p(AD, data.length);
|
|
1833
1839
|
return {
|
|
@@ -1945,8 +1951,8 @@ function IndividualDistributionPlots(data) {
|
|
|
1945
1951
|
gamma3p: QQPlotChart(data, "3-Parameter Gamma"),
|
|
1946
1952
|
largestExtremeValue: QQPlotChart(data, "Largest Extreme Value"),
|
|
1947
1953
|
logistic: QQPlotChart(data, "Logistic"),
|
|
1948
|
-
loglogistic: QQPlotChart(data, "LogLogistic"),
|
|
1949
|
-
lognormal: QQPlotChart(data, "LogNormal"),
|
|
1954
|
+
loglogistic: QQPlotChart(data, "2-Parameter LogLogistic"),
|
|
1955
|
+
lognormal: QQPlotChart(data, "2-Parameter LogNormal"),
|
|
1950
1956
|
smallestExtremeValue: QQPlotChart(data, "Smallest Extreme Value"),
|
|
1951
1957
|
weibull: QQPlotChart(data, "Weibull")
|
|
1952
1958
|
};
|
|
@@ -1957,7 +1963,7 @@ function IndividualDistributionPlots(data) {
|
|
|
1957
1963
|
}
|
|
1958
1964
|
var QQPlot = {
|
|
1959
1965
|
p(data, method = "Hazen") {
|
|
1960
|
-
let orderedData = data.sort();
|
|
1966
|
+
let orderedData = [...data].sort();
|
|
1961
1967
|
let PValues = [];
|
|
1962
1968
|
let N = orderedData.length;
|
|
1963
1969
|
for (let i = 1; i <= N; i++) {
|
|
@@ -2026,10 +2032,18 @@ function MovingRange(data, w = 2) {
|
|
|
2026
2032
|
for (let j = 0; j < w; j++) {
|
|
2027
2033
|
values.push(Number(data[h + j]));
|
|
2028
2034
|
}
|
|
2029
|
-
movingRange.push(
|
|
2035
|
+
movingRange.push(CalculateRange(values));
|
|
2030
2036
|
}
|
|
2031
2037
|
return movingRange;
|
|
2032
2038
|
}
|
|
2039
|
+
function CalculateRange(data) {
|
|
2040
|
+
let dataNumbers = data.map((d) => {
|
|
2041
|
+
return Number(d);
|
|
2042
|
+
});
|
|
2043
|
+
let max = Math.max(...dataNumbers);
|
|
2044
|
+
let min = Math.min(...dataNumbers);
|
|
2045
|
+
return max - min;
|
|
2046
|
+
}
|
|
2033
2047
|
var StDev = {
|
|
2034
2048
|
/**
|
|
2035
2049
|
* Calculates the population standard deviation of the array supplied.
|
|
@@ -2077,7 +2091,7 @@ function Sum(data) {
|
|
|
2077
2091
|
});
|
|
2078
2092
|
return sum;
|
|
2079
2093
|
}
|
|
2080
|
-
function
|
|
2094
|
+
function Rang(data) {
|
|
2081
2095
|
let dataNumbers = data.map((d) => {
|
|
2082
2096
|
return Number(d);
|
|
2083
2097
|
});
|
|
@@ -2415,13 +2429,13 @@ function SetCanvasTextProperties(ctx, font) {
|
|
|
2415
2429
|
ctx.font = `${font.font} ${font.fontSize}`;
|
|
2416
2430
|
ctx.fillStyle = font.fillColor;
|
|
2417
2431
|
}
|
|
2418
|
-
function AddInfoTable(ctx, data, x, y, width, height, title, font) {
|
|
2432
|
+
function AddInfoTable(ctx, data, x, y, width, height, title, lineHeight = 0, font) {
|
|
2419
2433
|
if (!font) {
|
|
2420
2434
|
font = new EngFont();
|
|
2421
2435
|
}
|
|
2422
2436
|
SetCanvasTextProperties(ctx, font);
|
|
2423
2437
|
ctx.beginPath();
|
|
2424
|
-
|
|
2438
|
+
lineHeight = lineHeight ? lineHeight : Number(font.fontSize.replace("px", "")) + 30;
|
|
2425
2439
|
ctx.textAlign = "center";
|
|
2426
2440
|
ctx.fillText(title, x + width / 2, y + Number(font.fontSize.replace("px", "")), width);
|
|
2427
2441
|
ctx.textAlign = "left";
|
|
@@ -3160,7 +3174,28 @@ function QQPlotChart(data, distribution = "Normal") {
|
|
|
3160
3174
|
return (x - params.location) / params.scale;
|
|
3161
3175
|
};
|
|
3162
3176
|
let middleLineChart = new Chart([], "function", "Middle Line", void 0, middleLine);
|
|
3163
|
-
|
|
3177
|
+
let chart = CreateStackedChart([middleLineChart, new Chart([dataset], "scatter")], `${distribution[0].toUpperCase()}${distribution.substring(1)} Probability Plot`, chartSettings);
|
|
3178
|
+
if (distribution.toLowerCase() === "normal" || distribution.toLowerCase().includes("boxcox")) {
|
|
3179
|
+
let AD = GoodnessOfFit.AndersonDarling.Test(data, GoodnessOfFit.Distributions.Normal);
|
|
3180
|
+
let RJ = Distributions.Normal.RyanJoiner.Test(data);
|
|
3181
|
+
let KS = Distributions.Normal.KolmogorovSmirnov(data);
|
|
3182
|
+
let JB = Distributions.Normal.JarqueBera(data);
|
|
3183
|
+
let ctx = chart.getContext("2d");
|
|
3184
|
+
if (ctx) {
|
|
3185
|
+
AddInfoTable(ctx, [{ key: "AD:", value: AD.AD }, { key: "p-value:", value: AD.p }, { key: "", value: "" }, { key: "RJ:", value: RJ.RJ }, { key: "crit.:", value: RJ.critical }, { key: "", value: "" }, { key: "KS:", value: KS.KS }, { key: "p-value:", value: KS.p }, { key: "", value: "" }, { key: "JB:", value: JB.JB }, { key: "p-value:", value: JB.p }], 1075, 150, 175, 100, "", 30);
|
|
3186
|
+
}
|
|
3187
|
+
} else {
|
|
3188
|
+
let dist = distribution.replace("-", "").replace("arameter", "").replace(/\s/g, "");
|
|
3189
|
+
if (dist.includes("2P")) {
|
|
3190
|
+
dist = dist.replace("2P", "").concat("2P");
|
|
3191
|
+
}
|
|
3192
|
+
let AD = GoodnessOfFit.AndersonDarling.Test(data, dist);
|
|
3193
|
+
let ctx = chart.getContext("2d");
|
|
3194
|
+
if (ctx && (AD.AD || AD.AD === Infinity || Number.isNaN(AD.AD)) && (AD.p || AD.p === Infinity || Number.isNaN(AD.p))) {
|
|
3195
|
+
AddInfoTable(ctx, [{ key: "AD:", value: AD.AD }, { key: "p-value:", value: AD.p }], 1075, 150, 175, 100, "", 30);
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
return chart;
|
|
3164
3199
|
}
|
|
3165
3200
|
function QQDistributionModification(p, distribution) {
|
|
3166
3201
|
if (distribution.toLowerCase().includes("weibull")) {
|
|
@@ -3914,7 +3949,7 @@ export {
|
|
|
3914
3949
|
Point,
|
|
3915
3950
|
QQPlot,
|
|
3916
3951
|
QQPlotChart,
|
|
3917
|
-
|
|
3952
|
+
Rang,
|
|
3918
3953
|
RoundTO,
|
|
3919
3954
|
SerializeData,
|
|
3920
3955
|
Specification,
|
package/index.ts
CHANGED
|
@@ -590,7 +590,7 @@ export const Capability = {
|
|
|
590
590
|
let lastObservations = LastObservationsChart(data, 25, 'Last 25 Observations');
|
|
591
591
|
let capabilityHistogram = CreateCapabilityHistogram(data, spec);
|
|
592
592
|
let capabilityPlot = CreateCapabilityPlot(data, spec);
|
|
593
|
-
|
|
593
|
+
console.log(Capability.Analysis(data, spec))
|
|
594
594
|
return {
|
|
595
595
|
charts: {
|
|
596
596
|
IndividualValue: individualValuePlot,
|
|
@@ -780,6 +780,7 @@ export function CreateCapabilityPlot(data: number[], specification: Specificatio
|
|
|
780
780
|
value: capability.Cpk
|
|
781
781
|
}
|
|
782
782
|
]
|
|
783
|
+
|
|
783
784
|
AddInfoTable(ctx, withinInfo, 20, chartSettings.margins.top, chartSettings.width/4, chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom, "Within");
|
|
784
785
|
|
|
785
786
|
// Add Overall Information
|
|
@@ -1575,7 +1576,7 @@ export const Distributions = {
|
|
|
1575
1576
|
let N = data.length;
|
|
1576
1577
|
|
|
1577
1578
|
let Z: number[] = [];
|
|
1578
|
-
let Y = data.sort(function (a, b){return a-b});
|
|
1579
|
+
let Y = [...data].sort(function (a, b){return a-b});
|
|
1579
1580
|
let numSum = 0;
|
|
1580
1581
|
let denSum = 0;
|
|
1581
1582
|
let mean = Mean(data);
|
|
@@ -1651,9 +1652,9 @@ export const Distributions = {
|
|
|
1651
1652
|
},
|
|
1652
1653
|
KolmogorovSmirnov(data){
|
|
1653
1654
|
let N = data.length;
|
|
1654
|
-
data.sort();
|
|
1655
|
-
let mean = Mean(
|
|
1656
|
-
let std = StDev.S(
|
|
1655
|
+
let sortedData = [...data].sort();
|
|
1656
|
+
let mean = Mean(sortedData);
|
|
1657
|
+
let std = StDev.S(sortedData);
|
|
1657
1658
|
let dMinusArray: number[] = [];
|
|
1658
1659
|
let dPlusArray: number[] = [];
|
|
1659
1660
|
for(let i = 1; i <= N; i++){
|
|
@@ -1890,6 +1891,7 @@ export function MaximumLikelihoodParameters(data: number[], distribution: string
|
|
|
1890
1891
|
|
|
1891
1892
|
export function ParameterizedCDF(data: number[], distribution: string){
|
|
1892
1893
|
let params = MaximumLikelihoodParameters(data, distribution);
|
|
1894
|
+
|
|
1893
1895
|
// Exponential Distributions
|
|
1894
1896
|
if(distribution.toLowerCase().includes("exponential")){
|
|
1895
1897
|
if(distribution.includes("2")){
|
|
@@ -1938,7 +1940,7 @@ export const GoodnessOfFit = {
|
|
|
1938
1940
|
AD(data: number[], cdf: Function){
|
|
1939
1941
|
let N = data.length;
|
|
1940
1942
|
|
|
1941
|
-
let Y = data.sort(function(a, b){return a - b});
|
|
1943
|
+
let Y = [...data].sort(function(a, b){return a - b});
|
|
1942
1944
|
|
|
1943
1945
|
let S = 0;
|
|
1944
1946
|
|
|
@@ -1983,13 +1985,17 @@ export const GoodnessOfFit = {
|
|
|
1983
1985
|
Test(data: number[], cdf: Function | String){
|
|
1984
1986
|
let CDF: any;
|
|
1985
1987
|
if(typeof cdf === "string"){
|
|
1986
|
-
|
|
1988
|
+
if(GoodnessOfFit.Distributions[cdf]){
|
|
1989
|
+
CDF = ParameterizedCDF(data, GoodnessOfFit.Distributions[cdf])
|
|
1990
|
+
}
|
|
1987
1991
|
}else{
|
|
1988
1992
|
CDF = cdf
|
|
1989
1993
|
}
|
|
1994
|
+
|
|
1995
|
+
if(typeof CDF!== "function"){return {AD: undefined, p: undefined}}
|
|
1990
1996
|
let AD = GoodnessOfFit.AndersonDarling.AD(data, CDF);
|
|
1991
1997
|
let p = GoodnessOfFit.AndersonDarling.p(AD, data.length);
|
|
1992
|
-
|
|
1998
|
+
|
|
1993
1999
|
return {
|
|
1994
2000
|
AD: AD,
|
|
1995
2001
|
p: p
|
|
@@ -2211,8 +2217,8 @@ export function IndividualDistributionPlots(data: number[]){
|
|
|
2211
2217
|
gamma3p: QQPlotChart(data, '3-Parameter Gamma'),
|
|
2212
2218
|
largestExtremeValue: QQPlotChart(data, 'Largest Extreme Value'),
|
|
2213
2219
|
logistic: QQPlotChart(data, 'Logistic'),
|
|
2214
|
-
loglogistic: QQPlotChart(data, 'LogLogistic'),
|
|
2215
|
-
lognormal: QQPlotChart(data, 'LogNormal'),
|
|
2220
|
+
loglogistic: QQPlotChart(data, '2-Parameter LogLogistic'),
|
|
2221
|
+
lognormal: QQPlotChart(data, '2-Parameter LogNormal'),
|
|
2216
2222
|
smallestExtremeValue: QQPlotChart(data, 'Smallest Extreme Value'),
|
|
2217
2223
|
weibull: QQPlotChart(data, 'Weibull')
|
|
2218
2224
|
}
|
|
@@ -2225,7 +2231,7 @@ export function IndividualDistributionPlots(data: number[]){
|
|
|
2225
2231
|
|
|
2226
2232
|
export const QQPlot = {
|
|
2227
2233
|
p(data: number[], method: string = 'Hazen'){
|
|
2228
|
-
let orderedData = data.sort();
|
|
2234
|
+
let orderedData = [...data].sort();
|
|
2229
2235
|
let PValues: number[] = [];
|
|
2230
2236
|
let N = orderedData.length
|
|
2231
2237
|
for(let i = 1; i <= N; i++){
|
|
@@ -2331,12 +2337,17 @@ export function MovingRange(data: any[], w: number = 2){
|
|
|
2331
2337
|
values.push(Number(data[h + j]));
|
|
2332
2338
|
}
|
|
2333
2339
|
|
|
2334
|
-
movingRange.push(
|
|
2340
|
+
movingRange.push(CalculateRange(values))
|
|
2335
2341
|
}
|
|
2336
2342
|
|
|
2337
2343
|
return movingRange;
|
|
2338
2344
|
}
|
|
2339
|
-
|
|
2345
|
+
function CalculateRange(data: any[]) {
|
|
2346
|
+
let dataNumbers = data.map(d => {return Number(d)});
|
|
2347
|
+
let max = Math.max(...dataNumbers);
|
|
2348
|
+
let min = Math.min(...dataNumbers);
|
|
2349
|
+
return max - min
|
|
2350
|
+
}
|
|
2340
2351
|
export const StDev = {
|
|
2341
2352
|
/**
|
|
2342
2353
|
* Calculates the population standard deviation of the array supplied.
|
|
@@ -2400,7 +2411,7 @@ export function Sum(data: any[]){
|
|
|
2400
2411
|
* @customfunction
|
|
2401
2412
|
* @param data An array of numbers. The numbers can be supplied as number types or strings
|
|
2402
2413
|
*/
|
|
2403
|
-
export function
|
|
2414
|
+
export function Rang(data: any[]) {
|
|
2404
2415
|
let dataNumbers = data.map(d => {return Number(d)});
|
|
2405
2416
|
let max = Math.max(...dataNumbers);
|
|
2406
2417
|
let min = Math.min(...dataNumbers);
|
|
@@ -2801,12 +2812,12 @@ function SetCanvasTextProperties(ctx: CanvasRenderingContext2D, font: EngFont){
|
|
|
2801
2812
|
ctx.fillStyle = font.fillColor;
|
|
2802
2813
|
}
|
|
2803
2814
|
|
|
2804
|
-
function AddInfoTable(ctx: CanvasRenderingContext2D, data: {key: string, value: any}[], x: number, y: number, width: number, height: number, title: string, font?: EngFont){
|
|
2815
|
+
function AddInfoTable(ctx: CanvasRenderingContext2D, data: {key: string, value: any}[], x: number, y: number, width: number, height: number, title: string, lineHeight: number = 0, font?: EngFont){
|
|
2805
2816
|
if(!font){font = new EngFont()}
|
|
2806
2817
|
SetCanvasTextProperties(ctx, font);
|
|
2807
2818
|
|
|
2808
2819
|
ctx.beginPath();
|
|
2809
|
-
|
|
2820
|
+
lineHeight = lineHeight ? lineHeight : Number(font.fontSize.replace("px", "")) + 30;
|
|
2810
2821
|
// Set Title to text align center
|
|
2811
2822
|
ctx.textAlign = 'center'
|
|
2812
2823
|
ctx.fillText(title, x + width/2, y + Number(font.fontSize.replace("px", "")), width);
|
|
@@ -3739,8 +3750,34 @@ export function QQPlotChart(data: number[], distribution: string = 'Normal'){
|
|
|
3739
3750
|
}
|
|
3740
3751
|
|
|
3741
3752
|
let middleLineChart = new Chart([], 'function', 'Middle Line', undefined, middleLine);
|
|
3753
|
+
|
|
3754
|
+
let chart = CreateStackedChart([middleLineChart, new Chart([dataset], 'scatter')], `${distribution[0].toUpperCase()}${distribution.substring(1)} Probability Plot`, chartSettings);
|
|
3755
|
+
|
|
3756
|
+
if (distribution.toLowerCase() === "normal" || distribution.toLowerCase().includes("boxcox")) {
|
|
3757
|
+
let AD = GoodnessOfFit.AndersonDarling.Test(data, GoodnessOfFit.Distributions.Normal);
|
|
3758
|
+
let RJ = Distributions.Normal.RyanJoiner.Test(data);
|
|
3759
|
+
let KS = Distributions.Normal.KolmogorovSmirnov(data);
|
|
3760
|
+
let JB = Distributions.Normal.JarqueBera(data);
|
|
3761
|
+
let ctx = chart.getContext("2d");
|
|
3762
|
+
if(ctx){
|
|
3763
|
+
AddInfoTable(ctx, [{ key: "AD:", value: AD.AD }, { key: "p-value:", value: AD.p }, { key: "", value: '' }, { key: "RJ:", value: RJ.RJ }, { key: "crit.:", value: RJ.critical }, { key: "", value: "" }, { key: "KS:", value: KS.KS }, { key: "p-value:", value: KS.p }, { key: "", value: "" }, { key: "JB:", value: JB.JB }, { key: "p-value:", value: JB.p }], 1075, 150, 175, 100, "", 30);
|
|
3764
|
+
}
|
|
3765
|
+
}else{
|
|
3766
|
+
let dist = distribution.replace("-", "").replace("arameter", "").replace(/\s/g, "");
|
|
3767
|
+
if(dist.includes("2P")){
|
|
3768
|
+
dist = dist.replace("2P", "").concat("2P")
|
|
3769
|
+
}
|
|
3742
3770
|
|
|
3743
|
-
|
|
3771
|
+
let AD = GoodnessOfFit.AndersonDarling.Test(data, dist);
|
|
3772
|
+
|
|
3773
|
+
let ctx = chart.getContext("2d");
|
|
3774
|
+
|
|
3775
|
+
if(ctx && (AD.AD || AD.AD === Infinity || Number.isNaN(AD.AD)) && (AD.p || AD.p === Infinity || Number.isNaN(AD.p))){
|
|
3776
|
+
AddInfoTable(ctx, [{ key: "AD:", value: AD.AD }, { key: "p-value:", value: AD.p }], 1075, 150, 175, 100, "", 30);
|
|
3777
|
+
}
|
|
3778
|
+
|
|
3779
|
+
}
|
|
3780
|
+
return chart;
|
|
3744
3781
|
}
|
|
3745
3782
|
|
|
3746
3783
|
function QQDistributionModification(p: number, distribution: string){
|
|
@@ -4591,4 +4628,4 @@ function SplitObjectArrayByProp(array: any[], prop: string){
|
|
|
4591
4628
|
}
|
|
4592
4629
|
// End Measurement Systems Analysis
|
|
4593
4630
|
/** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
4594
|
-
*/
|
|
4631
|
+
*/
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Added Anderson-Darling goodness-of-fit results QQPlots when they are generated.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Build of version 1_0_29. See for details
|