qesuite 1.0.7 → 1.0.9

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 CHANGED
@@ -668,6 +668,8 @@ declare const Distributions: {
668
668
  };
669
669
  };
670
670
  };
671
+ declare function MLE(data: number[], distribution: string): any;
672
+ declare function ParameterizedCDF(data: number[], distribution: string): (x: number) => any;
671
673
  declare const GoodnessOfFit: {
672
674
  AndersonDarling: {
673
675
  /**
@@ -687,11 +689,12 @@ declare const GoodnessOfFit: {
687
689
  * @param data The data to evaluate.
688
690
  * @param cdf The cumulative distribution function to evaluate the data against.
689
691
  */
690
- Test(data: number[], cdf: Function): {
692
+ Test(data: number[], cdf: Function | String): {
691
693
  AD: number;
692
694
  p: any;
693
695
  };
694
696
  };
697
+ Distributions: string[];
695
698
  KolmogorovSmirnov: {
696
699
  /**
697
700
  * Returns the KolmogorovSmirnov Critical Value for goodness of fit testing based on the specified sample size and the specified confidence.
@@ -1120,5 +1123,6 @@ declare function GRR_Graphs(data: any, tolerance: number, name?: string): {
1120
1123
  };
1121
1124
  declare function GRR_ByPartChart(data: GRR_Data): HTMLCanvasElement;
1122
1125
  declare function GRR_PartxOperatorChart(data: GRR_Data): HTMLCanvasElement;
1126
+ declare function CompileGRRObject(operators: any, parts: any, measurements: any): GRR_Data;
1123
1127
 
1124
- export { AnovaTableTwoWay, AverageMovingRange, Beta, CanvasDrawSettings, Capability, CreateBoxandWhiskerGraph, CreateCapabilityHistogram, CreateCategoricalBarGraph, CreateContinuousBarGraph, CreateScatterPlot, CreateSplitGraph, CreateStackedChart, CreateSummaryChart, Distributions, ERF, EngFont, FixedPointIteration, G1, G1_Graphs, GRR, GRR_ByPartChart, GRR_Data, GRR_Graphs, GRR_Operator, GRR_PartxOperatorChart, GRR_Replication, GageEvaluation, Gamma, GetFunctionValues, GetHistogramDataset, GoodnessOfFit, IndividualDistributionIdentification, IndividualDistributionPlots, IndividualValuePlot, LastObservationsChart, Margin, MarkOutOfControl, Mean, Median, MovingRange, MovingRangeChart, NewtonRaphson, ObjectToArray, Point, QEAxisSettings, QEChart, QEChartSettings, QECustomGridline, QEDataCollection, QEDataSet, QELine, QESpecification, QQPlot, QQPlotChart, Range, RoundTO, SerializeData, SixPack, StDev, Sum, UnbiasingConstant, VarianceComponents };
1128
+ export { AnovaTableTwoWay, AverageMovingRange, Beta, CanvasDrawSettings, Capability, CompileGRRObject, CreateBoxandWhiskerGraph, CreateCapabilityHistogram, CreateCategoricalBarGraph, CreateContinuousBarGraph, CreateScatterPlot, CreateSplitGraph, CreateStackedChart, CreateSummaryChart, Distributions, ERF, EngFont, FixedPointIteration, G1, G1_Graphs, GRR, GRR_ByPartChart, GRR_Data, GRR_Graphs, GRR_Operator, GRR_PartxOperatorChart, GRR_Replication, GageEvaluation, Gamma, GetFunctionValues, GetHistogramDataset, GoodnessOfFit, IndividualDistributionIdentification, IndividualDistributionPlots, IndividualValuePlot, LastObservationsChart, MLE, Margin, MarkOutOfControl, Mean, Median, MovingRange, MovingRangeChart, NewtonRaphson, ObjectToArray, ParameterizedCDF, Point, QEAxisSettings, QEChart, QEChartSettings, QECustomGridline, QEDataCollection, QEDataSet, QELine, QESpecification, QQPlot, QQPlotChart, Range, RoundTO, SerializeData, SixPack, StDev, Sum, UnbiasingConstant, VarianceComponents };
package/dist/index.d.ts CHANGED
@@ -668,6 +668,8 @@ declare const Distributions: {
668
668
  };
669
669
  };
670
670
  };
671
+ declare function MLE(data: number[], distribution: string): any;
672
+ declare function ParameterizedCDF(data: number[], distribution: string): (x: number) => any;
671
673
  declare const GoodnessOfFit: {
672
674
  AndersonDarling: {
673
675
  /**
@@ -687,11 +689,12 @@ declare const GoodnessOfFit: {
687
689
  * @param data The data to evaluate.
688
690
  * @param cdf The cumulative distribution function to evaluate the data against.
689
691
  */
690
- Test(data: number[], cdf: Function): {
692
+ Test(data: number[], cdf: Function | String): {
691
693
  AD: number;
692
694
  p: any;
693
695
  };
694
696
  };
697
+ Distributions: string[];
695
698
  KolmogorovSmirnov: {
696
699
  /**
697
700
  * Returns the KolmogorovSmirnov Critical Value for goodness of fit testing based on the specified sample size and the specified confidence.
@@ -1120,5 +1123,6 @@ declare function GRR_Graphs(data: any, tolerance: number, name?: string): {
1120
1123
  };
1121
1124
  declare function GRR_ByPartChart(data: GRR_Data): HTMLCanvasElement;
1122
1125
  declare function GRR_PartxOperatorChart(data: GRR_Data): HTMLCanvasElement;
1126
+ declare function CompileGRRObject(operators: any, parts: any, measurements: any): GRR_Data;
1123
1127
 
1124
- export { AnovaTableTwoWay, AverageMovingRange, Beta, CanvasDrawSettings, Capability, CreateBoxandWhiskerGraph, CreateCapabilityHistogram, CreateCategoricalBarGraph, CreateContinuousBarGraph, CreateScatterPlot, CreateSplitGraph, CreateStackedChart, CreateSummaryChart, Distributions, ERF, EngFont, FixedPointIteration, G1, G1_Graphs, GRR, GRR_ByPartChart, GRR_Data, GRR_Graphs, GRR_Operator, GRR_PartxOperatorChart, GRR_Replication, GageEvaluation, Gamma, GetFunctionValues, GetHistogramDataset, GoodnessOfFit, IndividualDistributionIdentification, IndividualDistributionPlots, IndividualValuePlot, LastObservationsChart, Margin, MarkOutOfControl, Mean, Median, MovingRange, MovingRangeChart, NewtonRaphson, ObjectToArray, Point, QEAxisSettings, QEChart, QEChartSettings, QECustomGridline, QEDataCollection, QEDataSet, QELine, QESpecification, QQPlot, QQPlotChart, Range, RoundTO, SerializeData, SixPack, StDev, Sum, UnbiasingConstant, VarianceComponents };
1128
+ export { AnovaTableTwoWay, AverageMovingRange, Beta, CanvasDrawSettings, Capability, CompileGRRObject, CreateBoxandWhiskerGraph, CreateCapabilityHistogram, CreateCategoricalBarGraph, CreateContinuousBarGraph, CreateScatterPlot, CreateSplitGraph, CreateStackedChart, CreateSummaryChart, Distributions, ERF, EngFont, FixedPointIteration, G1, G1_Graphs, GRR, GRR_ByPartChart, GRR_Data, GRR_Graphs, GRR_Operator, GRR_PartxOperatorChart, GRR_Replication, GageEvaluation, Gamma, GetFunctionValues, GetHistogramDataset, GoodnessOfFit, IndividualDistributionIdentification, IndividualDistributionPlots, IndividualValuePlot, LastObservationsChart, MLE, Margin, MarkOutOfControl, Mean, Median, MovingRange, MovingRangeChart, NewtonRaphson, ObjectToArray, ParameterizedCDF, Point, QEAxisSettings, QEChart, QEChartSettings, QECustomGridline, QEDataCollection, QEDataSet, QELine, QESpecification, QQPlot, QQPlotChart, Range, RoundTO, SerializeData, SixPack, StDev, Sum, UnbiasingConstant, VarianceComponents };
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ __export(QESuite_exports, {
24
24
  Beta: () => Beta,
25
25
  CanvasDrawSettings: () => CanvasDrawSettings,
26
26
  Capability: () => Capability,
27
+ CompileGRRObject: () => CompileGRRObject,
27
28
  CreateBoxandWhiskerGraph: () => CreateBoxandWhiskerGraph,
28
29
  CreateCapabilityHistogram: () => CreateCapabilityHistogram,
29
30
  CreateCategoricalBarGraph: () => CreateCategoricalBarGraph,
@@ -54,6 +55,7 @@ __export(QESuite_exports, {
54
55
  IndividualDistributionPlots: () => IndividualDistributionPlots,
55
56
  IndividualValuePlot: () => IndividualValuePlot,
56
57
  LastObservationsChart: () => LastObservationsChart,
58
+ MLE: () => MLE,
57
59
  Margin: () => Margin,
58
60
  MarkOutOfControl: () => MarkOutOfControl,
59
61
  Mean: () => Mean,
@@ -62,6 +64,7 @@ __export(QESuite_exports, {
62
64
  MovingRangeChart: () => MovingRangeChart,
63
65
  NewtonRaphson: () => NewtonRaphson,
64
66
  ObjectToArray: () => ObjectToArray,
67
+ ParameterizedCDF: () => ParameterizedCDF,
65
68
  Point: () => Point,
66
69
  QEAxisSettings: () => QEAxisSettings,
67
70
  QEChart: () => QEChart,
@@ -490,6 +493,9 @@ function ObjectToArray(object) {
490
493
  return returnArray;
491
494
  }
492
495
  function RoundTO(number, digits) {
496
+ if (number === 0) {
497
+ return;
498
+ }
493
499
  let str = number.toString();
494
500
  let decimalIndex = str.indexOf(".");
495
501
  let returner = Number(str.substring(0, decimalIndex + digits + 1));
@@ -1624,6 +1630,63 @@ var Distributions = {
1624
1630
  }
1625
1631
  }
1626
1632
  };
1633
+ function MLE(data, distribution) {
1634
+ if (distribution === "Normal" || distribution.toLowerCase().includes("extreme") || distribution === "Logistic") {
1635
+ return Distributions[distribution].MLE(data);
1636
+ }
1637
+ if (distribution === "Exponential") {
1638
+ return Distributions.Exponential.MLE.oneParameter(data);
1639
+ }
1640
+ if (distribution.toLowerCase().includes("2")) {
1641
+ return Distributions[distribution.substring(3)].MLE.twoParamerter(data);
1642
+ }
1643
+ if (distribution.toLowerCase().includes("3")) {
1644
+ return Distributions[distribution.substring(3)].MLE.threeParamerter(data);
1645
+ }
1646
+ return void 0;
1647
+ }
1648
+ function ParameterizedCDF(data, distribution) {
1649
+ let params = MLE(data, distribution);
1650
+ if (distribution.toLowerCase().includes("exponential")) {
1651
+ if (distribution.includes("2")) {
1652
+ return function cdf(x) {
1653
+ return Distributions.Exponential.cdf(x, params.scale, params.threshold);
1654
+ };
1655
+ }
1656
+ return function cdf(x) {
1657
+ return Distributions.Exponential.cdf(x, params.scale);
1658
+ };
1659
+ }
1660
+ if (distribution === "Normal" || distribution.toLowerCase().includes("extreme") || distribution === "Logistic") {
1661
+ return function cdf(x) {
1662
+ return Distributions[distribution].cdf(x, params.location, params.scale);
1663
+ };
1664
+ }
1665
+ if (distribution === "2P LogLogistic" || distribution === "2P LogNormal") {
1666
+ let dist = distribution.substring(3);
1667
+ return function cdf(x) {
1668
+ return Distributions[dist].cdf(x, params.location, params.scale);
1669
+ };
1670
+ }
1671
+ if (distribution.includes("3")) {
1672
+ let dist = distribution.substring(distribution.indexOf(" ") + 1);
1673
+ if (dist === "LogLogistic") {
1674
+ return function cdf(x) {
1675
+ return Distributions.LogLogistic.cdf(x, params.location, params.scale, params.threshold);
1676
+ };
1677
+ }
1678
+ if (dist === "Weibull") {
1679
+ return function cdf(x) {
1680
+ return Distributions.Weibull.cdf(x, params.scale, params.shape, params.than);
1681
+ };
1682
+ }
1683
+ }
1684
+ if (distribution === "Weibull") {
1685
+ return function cdf(x) {
1686
+ return Distributions.Weibull.cdf(x, params.scale, params.shape);
1687
+ };
1688
+ }
1689
+ }
1627
1690
  var GoodnessOfFit = {
1628
1691
  AndersonDarling: {
1629
1692
  /**
@@ -1674,7 +1737,13 @@ var GoodnessOfFit = {
1674
1737
  * @param cdf The cumulative distribution function to evaluate the data against.
1675
1738
  */
1676
1739
  Test(data, cdf) {
1677
- let AD = GoodnessOfFit.AndersonDarling.AD(data, cdf);
1740
+ let CDF;
1741
+ if (typeof cdf === "string") {
1742
+ CDF = ParameterizedCDF(data, cdf);
1743
+ } else {
1744
+ CDF = cdf;
1745
+ }
1746
+ let AD = GoodnessOfFit.AndersonDarling.AD(data, CDF);
1678
1747
  let p = GoodnessOfFit.AndersonDarling.p(AD, data.length);
1679
1748
  return {
1680
1749
  AD,
@@ -1682,6 +1751,18 @@ var GoodnessOfFit = {
1682
1751
  };
1683
1752
  }
1684
1753
  },
1754
+ Distributions: [
1755
+ "Exponential",
1756
+ "2P Exponential",
1757
+ "LargestExtremeValue",
1758
+ "Logistic",
1759
+ "2P LogLogistic",
1760
+ "2P LogNormal",
1761
+ "Normal",
1762
+ "SmallestExtremeValue",
1763
+ "Weibull",
1764
+ "3P Weibull"
1765
+ ],
1685
1766
  KolmogorovSmirnov: {
1686
1767
  /**
1687
1768
  * Returns the KolmogorovSmirnov Critical Value for goodness of fit testing based on the specified sample size and the specified confidence.
@@ -3607,6 +3688,55 @@ function GRR_PartxOperatorChart(data) {
3607
3688
  chartSettings.hasLegend = true;
3608
3689
  return CreateScatterPlot(dataSets, "Part * Operator Interaction", chartSettings);
3609
3690
  }
3691
+ function CompileGRRObject(operators, parts, measurements) {
3692
+ let arrayOfSmallerObjects = [];
3693
+ if (!(operators.length === parts.length && operators.length === measurements.length)) {
3694
+ return;
3695
+ }
3696
+ operators.forEach((o, i) => {
3697
+ arrayOfSmallerObjects.push({ operator: o, part: parts[i], measurement: measurements[i] });
3698
+ });
3699
+ let sortedByOperators = SplitObjectArrayByProp(arrayOfSmallerObjects, "operator");
3700
+ let thenSortedByParts = [];
3701
+ sortedByOperators.forEach((s) => {
3702
+ let entriesByPart = SplitObjectArrayByProp(s.entries, "part");
3703
+ let obj = {
3704
+ operator: s.selector,
3705
+ entriesByPart
3706
+ };
3707
+ thenSortedByParts.push(obj);
3708
+ });
3709
+ let grrData = new GRR_Data([]);
3710
+ thenSortedByParts.forEach((t) => {
3711
+ let numberOfReps = t.entriesByPart[0].entries.length;
3712
+ let grrOp = new GRR_Operator([], t.operator);
3713
+ for (let i = 0; i < numberOfReps; i++) {
3714
+ let newRep = new GRR_Replication([]);
3715
+ t.entriesByPart.forEach((e) => {
3716
+ newRep.parts.push(e.entries[i].measurement);
3717
+ });
3718
+ grrOp.replications.push(newRep);
3719
+ }
3720
+ grrData.operators.push(grrOp);
3721
+ });
3722
+ return grrData;
3723
+ }
3724
+ function SplitObjectArrayByProp(array, prop) {
3725
+ let newArray = [];
3726
+ array.forEach((a) => {
3727
+ let propValue = a[prop];
3728
+ let newObj = newArray.find((entry) => entry.selector === propValue);
3729
+ if (newObj) {
3730
+ newObj.entries.push(a);
3731
+ } else {
3732
+ newArray.push({
3733
+ selector: propValue,
3734
+ entries: [a]
3735
+ });
3736
+ }
3737
+ });
3738
+ return newArray;
3739
+ }
3610
3740
  // Annotate the CommonJS export names for ESM import in node:
3611
3741
  0 && (module.exports = {
3612
3742
  AnovaTableTwoWay,
@@ -3614,6 +3744,7 @@ function GRR_PartxOperatorChart(data) {
3614
3744
  Beta,
3615
3745
  CanvasDrawSettings,
3616
3746
  Capability,
3747
+ CompileGRRObject,
3617
3748
  CreateBoxandWhiskerGraph,
3618
3749
  CreateCapabilityHistogram,
3619
3750
  CreateCategoricalBarGraph,
@@ -3644,6 +3775,7 @@ function GRR_PartxOperatorChart(data) {
3644
3775
  IndividualDistributionPlots,
3645
3776
  IndividualValuePlot,
3646
3777
  LastObservationsChart,
3778
+ MLE,
3647
3779
  Margin,
3648
3780
  MarkOutOfControl,
3649
3781
  Mean,
@@ -3652,6 +3784,7 @@ function GRR_PartxOperatorChart(data) {
3652
3784
  MovingRangeChart,
3653
3785
  NewtonRaphson,
3654
3786
  ObjectToArray,
3787
+ ParameterizedCDF,
3655
3788
  Point,
3656
3789
  QEAxisSettings,
3657
3790
  QEChart,
package/dist/index.mjs CHANGED
@@ -406,6 +406,9 @@ function ObjectToArray(object) {
406
406
  return returnArray;
407
407
  }
408
408
  function RoundTO(number, digits) {
409
+ if (number === 0) {
410
+ return;
411
+ }
409
412
  let str = number.toString();
410
413
  let decimalIndex = str.indexOf(".");
411
414
  let returner = Number(str.substring(0, decimalIndex + digits + 1));
@@ -1540,6 +1543,63 @@ var Distributions = {
1540
1543
  }
1541
1544
  }
1542
1545
  };
1546
+ function MLE(data, distribution) {
1547
+ if (distribution === "Normal" || distribution.toLowerCase().includes("extreme") || distribution === "Logistic") {
1548
+ return Distributions[distribution].MLE(data);
1549
+ }
1550
+ if (distribution === "Exponential") {
1551
+ return Distributions.Exponential.MLE.oneParameter(data);
1552
+ }
1553
+ if (distribution.toLowerCase().includes("2")) {
1554
+ return Distributions[distribution.substring(3)].MLE.twoParamerter(data);
1555
+ }
1556
+ if (distribution.toLowerCase().includes("3")) {
1557
+ return Distributions[distribution.substring(3)].MLE.threeParamerter(data);
1558
+ }
1559
+ return void 0;
1560
+ }
1561
+ function ParameterizedCDF(data, distribution) {
1562
+ let params = MLE(data, distribution);
1563
+ if (distribution.toLowerCase().includes("exponential")) {
1564
+ if (distribution.includes("2")) {
1565
+ return function cdf(x) {
1566
+ return Distributions.Exponential.cdf(x, params.scale, params.threshold);
1567
+ };
1568
+ }
1569
+ return function cdf(x) {
1570
+ return Distributions.Exponential.cdf(x, params.scale);
1571
+ };
1572
+ }
1573
+ if (distribution === "Normal" || distribution.toLowerCase().includes("extreme") || distribution === "Logistic") {
1574
+ return function cdf(x) {
1575
+ return Distributions[distribution].cdf(x, params.location, params.scale);
1576
+ };
1577
+ }
1578
+ if (distribution === "2P LogLogistic" || distribution === "2P LogNormal") {
1579
+ let dist = distribution.substring(3);
1580
+ return function cdf(x) {
1581
+ return Distributions[dist].cdf(x, params.location, params.scale);
1582
+ };
1583
+ }
1584
+ if (distribution.includes("3")) {
1585
+ let dist = distribution.substring(distribution.indexOf(" ") + 1);
1586
+ if (dist === "LogLogistic") {
1587
+ return function cdf(x) {
1588
+ return Distributions.LogLogistic.cdf(x, params.location, params.scale, params.threshold);
1589
+ };
1590
+ }
1591
+ if (dist === "Weibull") {
1592
+ return function cdf(x) {
1593
+ return Distributions.Weibull.cdf(x, params.scale, params.shape, params.than);
1594
+ };
1595
+ }
1596
+ }
1597
+ if (distribution === "Weibull") {
1598
+ return function cdf(x) {
1599
+ return Distributions.Weibull.cdf(x, params.scale, params.shape);
1600
+ };
1601
+ }
1602
+ }
1543
1603
  var GoodnessOfFit = {
1544
1604
  AndersonDarling: {
1545
1605
  /**
@@ -1590,7 +1650,13 @@ var GoodnessOfFit = {
1590
1650
  * @param cdf The cumulative distribution function to evaluate the data against.
1591
1651
  */
1592
1652
  Test(data, cdf) {
1593
- let AD = GoodnessOfFit.AndersonDarling.AD(data, cdf);
1653
+ let CDF;
1654
+ if (typeof cdf === "string") {
1655
+ CDF = ParameterizedCDF(data, cdf);
1656
+ } else {
1657
+ CDF = cdf;
1658
+ }
1659
+ let AD = GoodnessOfFit.AndersonDarling.AD(data, CDF);
1594
1660
  let p = GoodnessOfFit.AndersonDarling.p(AD, data.length);
1595
1661
  return {
1596
1662
  AD,
@@ -1598,6 +1664,18 @@ var GoodnessOfFit = {
1598
1664
  };
1599
1665
  }
1600
1666
  },
1667
+ Distributions: [
1668
+ "Exponential",
1669
+ "2P Exponential",
1670
+ "LargestExtremeValue",
1671
+ "Logistic",
1672
+ "2P LogLogistic",
1673
+ "2P LogNormal",
1674
+ "Normal",
1675
+ "SmallestExtremeValue",
1676
+ "Weibull",
1677
+ "3P Weibull"
1678
+ ],
1601
1679
  KolmogorovSmirnov: {
1602
1680
  /**
1603
1681
  * Returns the KolmogorovSmirnov Critical Value for goodness of fit testing based on the specified sample size and the specified confidence.
@@ -3523,12 +3601,62 @@ function GRR_PartxOperatorChart(data) {
3523
3601
  chartSettings.hasLegend = true;
3524
3602
  return CreateScatterPlot(dataSets, "Part * Operator Interaction", chartSettings);
3525
3603
  }
3604
+ function CompileGRRObject(operators, parts, measurements) {
3605
+ let arrayOfSmallerObjects = [];
3606
+ if (!(operators.length === parts.length && operators.length === measurements.length)) {
3607
+ return;
3608
+ }
3609
+ operators.forEach((o, i) => {
3610
+ arrayOfSmallerObjects.push({ operator: o, part: parts[i], measurement: measurements[i] });
3611
+ });
3612
+ let sortedByOperators = SplitObjectArrayByProp(arrayOfSmallerObjects, "operator");
3613
+ let thenSortedByParts = [];
3614
+ sortedByOperators.forEach((s) => {
3615
+ let entriesByPart = SplitObjectArrayByProp(s.entries, "part");
3616
+ let obj = {
3617
+ operator: s.selector,
3618
+ entriesByPart
3619
+ };
3620
+ thenSortedByParts.push(obj);
3621
+ });
3622
+ let grrData = new GRR_Data([]);
3623
+ thenSortedByParts.forEach((t) => {
3624
+ let numberOfReps = t.entriesByPart[0].entries.length;
3625
+ let grrOp = new GRR_Operator([], t.operator);
3626
+ for (let i = 0; i < numberOfReps; i++) {
3627
+ let newRep = new GRR_Replication([]);
3628
+ t.entriesByPart.forEach((e) => {
3629
+ newRep.parts.push(e.entries[i].measurement);
3630
+ });
3631
+ grrOp.replications.push(newRep);
3632
+ }
3633
+ grrData.operators.push(grrOp);
3634
+ });
3635
+ return grrData;
3636
+ }
3637
+ function SplitObjectArrayByProp(array, prop) {
3638
+ let newArray = [];
3639
+ array.forEach((a) => {
3640
+ let propValue = a[prop];
3641
+ let newObj = newArray.find((entry) => entry.selector === propValue);
3642
+ if (newObj) {
3643
+ newObj.entries.push(a);
3644
+ } else {
3645
+ newArray.push({
3646
+ selector: propValue,
3647
+ entries: [a]
3648
+ });
3649
+ }
3650
+ });
3651
+ return newArray;
3652
+ }
3526
3653
  export {
3527
3654
  AnovaTableTwoWay,
3528
3655
  AverageMovingRange,
3529
3656
  Beta,
3530
3657
  CanvasDrawSettings,
3531
3658
  Capability,
3659
+ CompileGRRObject,
3532
3660
  CreateBoxandWhiskerGraph,
3533
3661
  CreateCapabilityHistogram,
3534
3662
  CreateCategoricalBarGraph,
@@ -3559,6 +3687,7 @@ export {
3559
3687
  IndividualDistributionPlots,
3560
3688
  IndividualValuePlot,
3561
3689
  LastObservationsChart,
3690
+ MLE,
3562
3691
  Margin,
3563
3692
  MarkOutOfControl,
3564
3693
  Mean,
@@ -3567,6 +3696,7 @@ export {
3567
3696
  MovingRangeChart,
3568
3697
  NewtonRaphson,
3569
3698
  ObjectToArray,
3699
+ ParameterizedCDF,
3570
3700
  Point,
3571
3701
  QEAxisSettings,
3572
3702
  QEChart,
package/index.ts CHANGED
@@ -468,6 +468,7 @@ export function ObjectToArray(object: any){
468
468
  }
469
469
 
470
470
  export function RoundTO(number: number, digits: number){
471
+ if(number === 0){return}
471
472
  let str = number.toString();
472
473
  let decimalIndex = str.indexOf('.');
473
474
  let returner = Number(str.substring(0, decimalIndex + digits + 1));
@@ -1682,6 +1683,63 @@ export const Distributions = {
1682
1683
  }
1683
1684
  }
1684
1685
 
1686
+ export function MLE(data: number[], distribution: string){
1687
+ if(distribution === "Normal" || distribution.toLowerCase().includes("extreme") || distribution === "Logistic"){
1688
+ return Distributions[distribution].MLE(data);
1689
+ }
1690
+ if(distribution === "Exponential"){
1691
+ return Distributions.Exponential.MLE.oneParameter(data);
1692
+ }
1693
+ if(distribution.toLowerCase().includes('2')){
1694
+ return Distributions[distribution.substring(3)].MLE.twoParamerter(data);
1695
+ }
1696
+ if(distribution.toLowerCase().includes('3')){
1697
+ return Distributions[distribution.substring(3)].MLE.threeParamerter(data);
1698
+ }
1699
+ return undefined
1700
+ }
1701
+
1702
+ export function ParameterizedCDF(data: number[], distribution: string){
1703
+ let params = MLE(data, distribution);
1704
+
1705
+ // Exponential Distributions
1706
+ if(distribution.toLowerCase().includes("exponential")){
1707
+ if(distribution.includes("2")){
1708
+ return function cdf(x: number){return Distributions.Exponential.cdf(x, params.scale, params.threshold)}
1709
+ }
1710
+ return function cdf(x: number){return Distributions.Exponential.cdf(x, params.scale)}
1711
+ }
1712
+
1713
+ // Location, Scale distributions
1714
+ if(distribution === "Normal" || distribution.toLowerCase().includes("extreme") || distribution === "Logistic"){
1715
+ return function cdf(x: number){return Distributions[distribution].cdf(x, params.location, params.scale)};
1716
+ }
1717
+
1718
+ if(distribution === "2P LogLogistic" || distribution === "2P LogNormal"){
1719
+ let dist = distribution.substring(3);
1720
+ return function cdf(x: number){return Distributions[dist].cdf(x, params.location, params.scale)};
1721
+ }
1722
+
1723
+ // 3 Parameters
1724
+ if(distribution.includes("3")){
1725
+ let dist = distribution.substring(distribution.indexOf(" ") + 1);
1726
+ // Location, Scale, Threshold
1727
+ if(dist === "LogLogistic"){
1728
+ return function cdf(x: number){return Distributions.LogLogistic.cdf(x, params.location, params.scale, params.threshold)}
1729
+ }
1730
+
1731
+ // Scale, Shape, Threshold
1732
+ if(dist === "Weibull"){
1733
+ return function cdf(x: number){return Distributions.Weibull.cdf(x, params.scale, params.shape, params.than)}
1734
+ }
1735
+ }
1736
+
1737
+ // Scale, Shape
1738
+ if(distribution === "Weibull"){
1739
+ return function cdf(x: number){return Distributions.Weibull.cdf(x, params.scale, params.shape)}
1740
+ }
1741
+ }
1742
+
1685
1743
  export const GoodnessOfFit = {
1686
1744
  AndersonDarling: {
1687
1745
  /**
@@ -1705,7 +1763,7 @@ export const GoodnessOfFit = {
1705
1763
  let AD_TS = -N - S;
1706
1764
 
1707
1765
  return AD_TS
1708
- },
1766
+ },
1709
1767
  /**
1710
1768
  * Evaluates the p-value of the Anderson-Darling goodness of fit test based on the specified Anderson-Darling test statistic and sample size.
1711
1769
  * @param AD The Anderson-Darling Test Statistic derived from performing the Anderson-Darling Goodness of Fit Test
@@ -1734,8 +1792,14 @@ export const GoodnessOfFit = {
1734
1792
  * @param data The data to evaluate.
1735
1793
  * @param cdf The cumulative distribution function to evaluate the data against.
1736
1794
  */
1737
- Test(data: number[], cdf: Function){
1738
- let AD = GoodnessOfFit.AndersonDarling.AD(data, cdf);
1795
+ Test(data: number[], cdf: Function | String){
1796
+ let CDF: any;
1797
+ if(typeof cdf === "string"){
1798
+ CDF = ParameterizedCDF(data, cdf)
1799
+ }else{
1800
+ CDF = cdf
1801
+ }
1802
+ let AD = GoodnessOfFit.AndersonDarling.AD(data, CDF);
1739
1803
  let p = GoodnessOfFit.AndersonDarling.p(AD, data.length);
1740
1804
 
1741
1805
  return {
@@ -1743,8 +1807,20 @@ export const GoodnessOfFit = {
1743
1807
  p: p
1744
1808
  }
1745
1809
 
1746
- }
1810
+ },
1747
1811
  },
1812
+ Distributions: [
1813
+ "Exponential",
1814
+ "2P Exponential",
1815
+ "LargestExtremeValue",
1816
+ "Logistic",
1817
+ "2P LogLogistic",
1818
+ "2P LogNormal",
1819
+ "Normal",
1820
+ "SmallestExtremeValue",
1821
+ "Weibull",
1822
+ "3P Weibull"
1823
+ ],
1748
1824
  KolmogorovSmirnov: {
1749
1825
  /**
1750
1826
  * Returns the KolmogorovSmirnov Critical Value for goodness of fit testing based on the specified sample size and the specified confidence.
@@ -4098,6 +4174,61 @@ export function GRR_PartxOperatorChart(data: GRR_Data){
4098
4174
  return CreateScatterPlot(dataSets ,'Part * Operator Interaction', chartSettings)
4099
4175
  }
4100
4176
 
4177
+ export function CompileGRRObject(operators, parts, measurements){
4178
+ let arrayOfSmallerObjects: any[] = [];
4179
+ if(!(operators.length === parts.length && operators.length === measurements.length)){return}
4180
+
4181
+ operators.forEach((o, i) => {
4182
+ arrayOfSmallerObjects.push({operator: o, part: parts[i], measurement: measurements[i]});
4183
+ })
4184
+
4185
+ let sortedByOperators = SplitObjectArrayByProp(arrayOfSmallerObjects, "operator")
4186
+
4187
+ let thenSortedByParts: any[] = [];
4188
+
4189
+ sortedByOperators.forEach(s => {
4190
+ let entriesByPart = SplitObjectArrayByProp(s.entries, "part");
4191
+ let obj = {
4192
+ operator: s.selector,
4193
+ entriesByPart: entriesByPart
4194
+ }
4195
+ thenSortedByParts.push(obj)
4196
+ })
4197
+
4198
+ let grrData = new GRR_Data([]);
4199
+
4200
+ thenSortedByParts.forEach(t => {
4201
+ let numberOfReps = t.entriesByPart[0].entries.length;
4202
+
4203
+ let grrOp = new GRR_Operator([], t.operator);
4204
+ for(let i = 0; i < numberOfReps; i++){
4205
+ let newRep = new GRR_Replication([]);
4206
+ t.entriesByPart.forEach(e => {
4207
+ newRep.parts.push(e.entries[i].measurement);
4208
+ })
4209
+ grrOp.replications.push(newRep);
4210
+ }
4211
+ grrData.operators.push(grrOp);
4212
+ })
4213
+ return grrData
4214
+ }
4215
+
4216
+ function SplitObjectArrayByProp(array: any[], prop: string){
4217
+ let newArray: any[] = [];
4218
+ array.forEach(a => {
4219
+ let propValue = a[prop];
4220
+ let newObj = newArray.find(entry => entry.selector === propValue);
4221
+ if(newObj){
4222
+ newObj.entries.push(a);
4223
+ }else{
4224
+ newArray.push({
4225
+ selector: propValue,
4226
+ entries: [a]
4227
+ })
4228
+ }
4229
+ })
4230
+ return newArray;
4231
+ }
4101
4232
  // End Measurement Systems Analysis
4102
4233
  /** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4103
4234
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qesuite",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Performs advanced statistical analysis of data. Specifically designed for engineering statistical analysis",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -0,0 +1,6 @@
1
+ Added functions to MSA Module to convert arrays Operator, Part, Measurement to GRR_Data object.
2
+
3
+ - CompileGRRObject
4
+ - SplitObjectArrayByProp
5
+
6
+ Fixed bug that prevented graphs from generating with user defined upper/lower axis bounds.
@@ -0,0 +1,10 @@
1
+ Added two new functions to Distributions Module
2
+
3
+ - MLE
4
+ - ParameterizedCDF
5
+
6
+ Added ability for GoodnessOfFit.AndersonDarling.Test to receive distribution as a string and perform analysis.
7
+
8
+ Added GoodnessOfFit.Distributions const array to easily access supported distributions
9
+
10
+ Added export for CompileGRRObject function