qesuite 1.0.27 → 1.0.29

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
@@ -165,7 +165,7 @@ declare class GRRReplication {
165
165
  getPartCount(): number;
166
166
  }
167
167
  declare function ObjectToArray(object: any): any[];
168
- declare function RoundTO(number: number, digits: number): number;
168
+ declare function RoundTO(number: number, digits: number): string | number;
169
169
  /** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
170
170
  */
171
171
  declare const Capability: {
package/dist/index.d.ts CHANGED
@@ -165,7 +165,7 @@ declare class GRRReplication {
165
165
  getPartCount(): number;
166
166
  }
167
167
  declare function ObjectToArray(object: any): any[];
168
- declare function RoundTO(number: number, digits: number): number;
168
+ declare function RoundTO(number: number, digits: number): string | number;
169
169
  /** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
170
170
  */
171
171
  declare const Capability: {
package/dist/index.js CHANGED
@@ -497,7 +497,11 @@ function ObjectToArray(object) {
497
497
  }
498
498
  function RoundTO(number, digits) {
499
499
  if (number === 0) {
500
- return;
500
+ let str2 = number.toString();
501
+ for (let i2 = 0; i2 < digits; i2++) {
502
+ str2.concat("0");
503
+ }
504
+ return str2;
501
505
  }
502
506
  let str = number.toString();
503
507
  let decimalIndex = str.indexOf(".");
@@ -727,11 +731,13 @@ function CreateCapabilityHistogram(data, specification) {
727
731
  function CreateCapabilityPlot(data, specification) {
728
732
  let capability = Capability.Analysis(data, specification);
729
733
  let chartSettings = new ChartSettings();
734
+ chartSettings.width = 1300;
730
735
  let canvas = CreateCanvas(chartSettings.width, chartSettings.height);
731
736
  let ctx = canvas.getContext("2d");
732
737
  if (!ctx) {
733
738
  return canvas;
734
739
  }
740
+ ctx.strokeRect(0, 0, chartSettings.width, chartSettings.height);
735
741
  AddChartTitle(ctx, chartSettings, "Capability Plot");
736
742
  let withinInfo = [
737
743
  {
@@ -747,7 +753,7 @@ function CreateCapabilityPlot(data, specification) {
747
753
  value: capability.Cpk
748
754
  }
749
755
  ];
750
- AddInfoTable(ctx, withinInfo, 0, chartSettings.margins.top, chartSettings.width / 4, chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom, "Within");
756
+ AddInfoTable(ctx, withinInfo, 20, chartSettings.margins.top, chartSettings.width / 4, chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom, "Within");
751
757
  let overallInfo = [
752
758
  {
753
759
  key: "StDev",
@@ -762,7 +768,7 @@ function CreateCapabilityPlot(data, specification) {
762
768
  value: capability.Ppk
763
769
  }
764
770
  ];
765
- AddInfoTable(ctx, overallInfo, 3 * chartSettings.width / 4, chartSettings.margins.top, chartSettings.width / 3, chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom, "Overall");
771
+ AddInfoTable(ctx, overallInfo, 3 * chartSettings.width / 4, chartSettings.margins.top, chartSettings.width / 4, chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom, "Overall");
766
772
  const mean = Mean(data);
767
773
  AddLinePlot(ctx, specification.LSL, specification.USL, mean, [mean - 3 * overallInfo[0].value, mean + 3 * overallInfo[0].value], chartSettings.width / 4, chartSettings.margins.top, chartSettings.width / 2, (chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom) / 3 - 10, "Overall");
768
774
  AddLinePlot(ctx, specification.LSL, specification.USL, mean, [mean - 3 * withinInfo[0].value, mean + 3 * withinInfo[0].value], chartSettings.width / 4, chartSettings.margins.top + 40 + (chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom) / 3, chartSettings.width / 2, (chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom) / 3 - 10, "Within");
package/dist/index.mjs CHANGED
@@ -410,7 +410,11 @@ function ObjectToArray(object) {
410
410
  }
411
411
  function RoundTO(number, digits) {
412
412
  if (number === 0) {
413
- return;
413
+ let str2 = number.toString();
414
+ for (let i2 = 0; i2 < digits; i2++) {
415
+ str2.concat("0");
416
+ }
417
+ return str2;
414
418
  }
415
419
  let str = number.toString();
416
420
  let decimalIndex = str.indexOf(".");
@@ -640,11 +644,13 @@ function CreateCapabilityHistogram(data, specification) {
640
644
  function CreateCapabilityPlot(data, specification) {
641
645
  let capability = Capability.Analysis(data, specification);
642
646
  let chartSettings = new ChartSettings();
647
+ chartSettings.width = 1300;
643
648
  let canvas = CreateCanvas(chartSettings.width, chartSettings.height);
644
649
  let ctx = canvas.getContext("2d");
645
650
  if (!ctx) {
646
651
  return canvas;
647
652
  }
653
+ ctx.strokeRect(0, 0, chartSettings.width, chartSettings.height);
648
654
  AddChartTitle(ctx, chartSettings, "Capability Plot");
649
655
  let withinInfo = [
650
656
  {
@@ -660,7 +666,7 @@ function CreateCapabilityPlot(data, specification) {
660
666
  value: capability.Cpk
661
667
  }
662
668
  ];
663
- AddInfoTable(ctx, withinInfo, 0, chartSettings.margins.top, chartSettings.width / 4, chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom, "Within");
669
+ AddInfoTable(ctx, withinInfo, 20, chartSettings.margins.top, chartSettings.width / 4, chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom, "Within");
664
670
  let overallInfo = [
665
671
  {
666
672
  key: "StDev",
@@ -675,7 +681,7 @@ function CreateCapabilityPlot(data, specification) {
675
681
  value: capability.Ppk
676
682
  }
677
683
  ];
678
- AddInfoTable(ctx, overallInfo, 3 * chartSettings.width / 4, chartSettings.margins.top, chartSettings.width / 3, chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom, "Overall");
684
+ AddInfoTable(ctx, overallInfo, 3 * chartSettings.width / 4, chartSettings.margins.top, chartSettings.width / 4, chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom, "Overall");
679
685
  const mean = Mean(data);
680
686
  AddLinePlot(ctx, specification.LSL, specification.USL, mean, [mean - 3 * overallInfo[0].value, mean + 3 * overallInfo[0].value], chartSettings.width / 4, chartSettings.margins.top, chartSettings.width / 2, (chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom) / 3 - 10, "Overall");
681
687
  AddLinePlot(ctx, specification.LSL, specification.USL, mean, [mean - 3 * withinInfo[0].value, mean + 3 * withinInfo[0].value], chartSettings.width / 4, chartSettings.margins.top + 40 + (chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom) / 3, chartSettings.width / 2, (chartSettings.height - chartSettings.margins.top - chartSettings.margins.bottom) / 3 - 10, "Within");
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(data);
1656
- let std = StDev.S(data);
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
- CDF = ParameterizedCDF(data, cdf)
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(Range(values))
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 Range(data: any[]) {
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
- let lineHeight = Number(font.fontSize.replace("px", "")) + 30
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
- return CreateStackedChart([middleLineChart, new Chart([dataset], 'scatter')], `${distribution[0].toUpperCase()}${distribution.substring(1)} Probability Plot`, chartSettings)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qesuite",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
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 @@
1
+ Rebuild of 1.0.27; see 1_0_27.md for details
@@ -0,0 +1 @@
1
+ Added Anderson-Darling goodness-of-fit results QQPlots when they are generated.