qesuite 1.0.65 → 1.0.67

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
@@ -503,7 +503,8 @@ declare const Beta: {
503
503
  * @param a The first shape parameter; x^(a-1).
504
504
  * @param b The second shape parameter; (1 - x)^(b-1).
505
505
  */
506
- inc(x: number, a: number, b: number): number;
506
+ inc(X: number, A: number, B: number): number;
507
+ incomplete(x: any, a: any, b: any): any;
507
508
  /**
508
509
  * Evaluates the regularized incomplete beta function of x for the beta function with specified shape parameters a and b.
509
510
  * @customfunction
@@ -512,6 +513,7 @@ declare const Beta: {
512
513
  * @param b The second shape parameter; (1 - x)^(b-1).
513
514
  */
514
515
  incr(x: number, a: number, b: number): number;
516
+ invInc(p: any, a: any, b: any): any;
515
517
  };
516
518
  declare const ERF: {
517
519
  /**
@@ -589,7 +591,7 @@ declare const Distributions: {
589
591
  * @param a The first shape parameter, x^(a-1).
590
592
  * @param b The second shape parameter; (1 - x)^(b-1).
591
593
  */
592
- cdf(x: number, a: number, b: number): number;
594
+ cdf(x: number, a: number, b: number): any;
593
595
  /**
594
596
  * Probability Density Function. Calculates the probability of random variable x occuring from the beta distribution with the specified shape parameters a and b.
595
597
  * @param x The value to evaluate.
@@ -662,7 +664,7 @@ declare const Distributions: {
662
664
  * @param df2 Denominator degrees of freedom
663
665
  * @returns the Right-Tailed P-Value of the F Distribution
664
666
  */
665
- cdf(x: number, df1: number, df2: number): number;
667
+ cdf(x: number, df1: number, df2: number): any;
666
668
  /**
667
669
  * Calculates the right-tailed p-value of the supplied F distribution.
668
670
  * @param f F value to evaluate
package/dist/index.d.ts CHANGED
@@ -503,7 +503,8 @@ declare const Beta: {
503
503
  * @param a The first shape parameter; x^(a-1).
504
504
  * @param b The second shape parameter; (1 - x)^(b-1).
505
505
  */
506
- inc(x: number, a: number, b: number): number;
506
+ inc(X: number, A: number, B: number): number;
507
+ incomplete(x: any, a: any, b: any): any;
507
508
  /**
508
509
  * Evaluates the regularized incomplete beta function of x for the beta function with specified shape parameters a and b.
509
510
  * @customfunction
@@ -512,6 +513,7 @@ declare const Beta: {
512
513
  * @param b The second shape parameter; (1 - x)^(b-1).
513
514
  */
514
515
  incr(x: number, a: number, b: number): number;
516
+ invInc(p: any, a: any, b: any): any;
515
517
  };
516
518
  declare const ERF: {
517
519
  /**
@@ -589,7 +591,7 @@ declare const Distributions: {
589
591
  * @param a The first shape parameter, x^(a-1).
590
592
  * @param b The second shape parameter; (1 - x)^(b-1).
591
593
  */
592
- cdf(x: number, a: number, b: number): number;
594
+ cdf(x: number, a: number, b: number): any;
593
595
  /**
594
596
  * Probability Density Function. Calculates the probability of random variable x occuring from the beta distribution with the specified shape parameters a and b.
595
597
  * @param x The value to evaluate.
@@ -662,7 +664,7 @@ declare const Distributions: {
662
664
  * @param df2 Denominator degrees of freedom
663
665
  * @returns the Right-Tailed P-Value of the F Distribution
664
666
  */
665
- cdf(x: number, df1: number, df2: number): number;
667
+ cdf(x: number, df1: number, df2: number): any;
666
668
  /**
667
669
  * Calculates the right-tailed p-value of the supplied F distribution.
668
670
  * @param f F value to evaluate
package/dist/index.js CHANGED
@@ -1078,7 +1078,6 @@ var Capability = {
1078
1078
  */
1079
1079
  Cp(data, spec, subgroupSize = 1, method, w, UnbiasingConstant2 = true) {
1080
1080
  let standarddeviation = StDev.W(data, subgroupSize, method, w, UnbiasingConstant2);
1081
- console.log({ StDevW: standarddeviation });
1082
1081
  if (!Number.isNaN(spec.USL) && !Number.isNaN(spec.LSL)) {
1083
1082
  return Number((spec.USL - spec.LSL) / (6 * standarddeviation));
1084
1083
  } else {
@@ -1802,10 +1801,34 @@ var Beta = {
1802
1801
  * @param a The first shape parameter; x^(a-1).
1803
1802
  * @param b The second shape parameter; (1 - x)^(b-1).
1804
1803
  */
1805
- inc(x, a, b) {
1804
+ inc(X, A, B) {
1805
+ var A0 = 0;
1806
+ var B0 = 1;
1807
+ var A1 = 1;
1808
+ var B1 = 1;
1809
+ var M9 = 0;
1810
+ var A2 = 0;
1811
+ var C9;
1812
+ while (Math.abs((A1 - A2) / A1) > 1e-5) {
1813
+ A2 = A1;
1814
+ C9 = -(A + M9) * (A + B + M9) * X / (A + 2 * M9) / (A + 2 * M9 + 1);
1815
+ A0 = A1 + C9 * A0;
1816
+ B0 = B1 + C9 * B0;
1817
+ M9 = M9 + 1;
1818
+ C9 = M9 * (B - M9) * X / (A + 2 * M9 - 1) / (A + 2 * M9);
1819
+ A1 = A0 + C9 * A1;
1820
+ B1 = B0 + C9 * B1;
1821
+ A0 = A0 / B1;
1822
+ B0 = B0 / B1;
1823
+ A1 = A1 / B1;
1824
+ B1 = 1;
1825
+ }
1826
+ return A1 / A;
1827
+ },
1828
+ incomplete(x, a, b) {
1806
1829
  var bt = x === 0 || x === 1 ? 0 : Math.exp(Gamma.ln(a + b) - Gamma.ln(a) - Gamma.ln(b) + a * Math.log(x) + b * Math.log(1 - x));
1807
1830
  if (x < 0 || x > 1)
1808
- return NaN;
1831
+ return false;
1809
1832
  if (x < (a + 1) / (a + b + 2))
1810
1833
  return bt * Beta.cf(x, a, b) / a;
1811
1834
  return 1 - bt * Beta.cf(1 - x, b, a) / b;
@@ -1819,6 +1842,54 @@ var Beta = {
1819
1842
  */
1820
1843
  incr(x, a, b) {
1821
1844
  return Beta.inc(x, a, b) / Beta.fn(a, b);
1845
+ },
1846
+ invInc(p, a, b) {
1847
+ var EPS = 1e-8;
1848
+ var a1 = a - 1;
1849
+ var b1 = b - 1;
1850
+ var j = 0;
1851
+ var lna, lnb, pp, t, u, err, x, al, h, w, afac;
1852
+ if (p <= 0)
1853
+ return 0;
1854
+ if (p >= 1)
1855
+ return 1;
1856
+ if (a >= 1 && b >= 1) {
1857
+ pp = p < 0.5 ? p : 1 - p;
1858
+ t = Math.sqrt(-2 * Math.log(pp));
1859
+ x = (2.30753 + t * 0.27061) / (1 + t * (0.99229 + t * 0.04481)) - t;
1860
+ if (p < 0.5)
1861
+ x = -x;
1862
+ al = (x * x - 3) / 6;
1863
+ h = 2 / (1 / (2 * a - 1) + 1 / (2 * b - 1));
1864
+ w = x * Math.sqrt(al + h) / h - (1 / (2 * b - 1) - 1 / (2 * a - 1)) * (al + 5 / 6 - 2 / (3 * h));
1865
+ x = a / (a + b * Math.exp(2 * w));
1866
+ } else {
1867
+ lna = Math.log(a / (a + b));
1868
+ lnb = Math.log(b / (a + b));
1869
+ t = Math.exp(a * lna) / a;
1870
+ u = Math.exp(b * lnb) / b;
1871
+ w = t + u;
1872
+ if (p < t / w)
1873
+ x = Math.pow(a * w * p, 1 / a);
1874
+ else
1875
+ x = 1 - Math.pow(b * w * (1 - p), 1 / b);
1876
+ }
1877
+ afac = -Gamma.ln(a) - Gamma.ln(b) + Gamma.ln(a + b);
1878
+ for (; j < 10; j++) {
1879
+ if (x === 0 || x === 1)
1880
+ return x;
1881
+ err = Beta.incomplete(x, a, b) - p;
1882
+ t = Math.exp(a1 * Math.log(x) + b1 * Math.log(1 - x) + afac);
1883
+ u = err / t;
1884
+ x -= t = u / (1 - 0.5 * Math.min(1, u * (a1 / x - b1 / (1 - x))));
1885
+ if (x <= 0)
1886
+ x = 0.5 * (x + t);
1887
+ if (x >= 1)
1888
+ x = 0.5 * (x + t + 1);
1889
+ if (Math.abs(t) < EPS * x && j > 0)
1890
+ break;
1891
+ }
1892
+ return x;
1822
1893
  }
1823
1894
  };
1824
1895
  var ERF = {
@@ -1983,7 +2054,17 @@ var Distributions = {
1983
2054
  * @param b The second shape parameter; (1 - x)^(b-1).
1984
2055
  */
1985
2056
  cdf(x, a, b) {
1986
- return Beta.incr(x, a, b);
2057
+ var S;
2058
+ var BT;
2059
+ var Bcdf;
2060
+ S = a + b;
2061
+ BT = Math.exp(Gamma.ln(S) - Gamma.ln(b) - Gamma.ln(a) + a * Math.log(x) + b * Math.log(1 - x));
2062
+ if (x < (a + 1) / (S + 2)) {
2063
+ Bcdf = BT * Beta.inc(x, a, b);
2064
+ } else {
2065
+ Bcdf = 1 - BT * Beta.inc(1 - x, b, a);
2066
+ }
2067
+ return Bcdf;
1987
2068
  },
1988
2069
  /**
1989
2070
  * Probability Density Function. Calculates the probability of random variable x occuring from the beta distribution with the specified shape parameters a and b.
@@ -3852,8 +3933,8 @@ var Distributions = {
3852
3933
  * @returns the Right-Tailed P-Value of the F Distribution
3853
3934
  */
3854
3935
  cdf(x, df1, df2) {
3855
- let subX = df1 * x / (df1 * x + df2);
3856
- let p = Beta.incr(subX, df1 / 2, df2 / 2);
3936
+ let z = x / (x + df2 / df1);
3937
+ let p = Distributions.Beta.cdf(z, df1 / 2, df2 / 2);
3857
3938
  if (p > 1) {
3858
3939
  p = 1;
3859
3940
  }
@@ -4771,7 +4852,7 @@ var Distributions = {
4771
4852
  if (p == 0.5) {
4772
4853
  return 0;
4773
4854
  }
4774
- let x = Distributions.Beta.inv(2 * Math.min(p, 1 - p), 0.5 * df, 0.5);
4855
+ var x = Beta.invInc(2 * Math.min(p, 1 - p), 0.5 * df, 0.5);
4775
4856
  x = Math.sqrt(df * (1 - x) / x);
4776
4857
  return p > 0.5 ? x : -x;
4777
4858
  }
@@ -5304,9 +5385,7 @@ var ANOVA = {
5304
5385
  let pooledSTD = StDev.Pooled(pooledData);
5305
5386
  let alphaADJ = (1 - Math.pow(1 - alpha, 1 / rCount)) / 2;
5306
5387
  let hAlpha = Math.abs(Distributions.T.inv(alphaADJ, grandArray.length - rCount));
5307
- console.log({ alphaADJ, ln: grandArray.length, rCount });
5308
5388
  let scaleDF = Math.sqrt((rCount - 1) / (rCount * tCount));
5309
- console.log({ grandMean, pooledSTD, hAlpha, scaleDF });
5310
5389
  let UDL = grandMean + pooledSTD * hAlpha * scaleDF;
5311
5390
  let LDL = grandMean - pooledSTD * hAlpha * scaleDF;
5312
5391
  let chartSettings = new ChartSettings();
@@ -7572,7 +7651,7 @@ var EquivalenceTesting = {
7572
7651
  let mean = Mean(dta);
7573
7652
  let se = StandardError(dta);
7574
7653
  let LSL = multiply ? lowerSpecification * target : lowerSpecification;
7575
- let USL = multiply ? upperSpecification * target : lowerSpecification;
7654
+ let USL = multiply ? upperSpecification * target : upperSpecification;
7576
7655
  let diff = mean - target;
7577
7656
  let CI_Low = Math.min((LSL + USL) / 2, diff - Distributions.T.inv(1 - confidenceLevel, dta.length - 1) * se);
7578
7657
  let CI_High = Math.max((LSL + USL) / 2, diff + Distributions.T.inv(1 - confidenceLevel, dta.length - 1) * se);
@@ -7899,7 +7978,7 @@ var NonparametricTesting = {
7899
7978
  let avgOverallRank = Mean(combinedRanks);
7900
7979
  let N = combinedData.length;
7901
7980
  let zValues = avgRanks.map((Rj, j) => {
7902
- return (Rj - avgOverallRank) / Math.sqrt((N + 1) * (N / data[j].length - 1) / 12);
7981
+ return (Rj - avgOverallRank) / Math.sqrt((N + 1) * (N / extractedData[j].length - 1) / 12);
7903
7982
  });
7904
7983
  let tieSets = CompileTies(combinedData);
7905
7984
  let adjustH = tieSets.length > 0;
@@ -11951,7 +12030,6 @@ function GageLinearityAndBias(parts, referenceValues, responses, processVariatio
11951
12030
  let \u03C3B2 = \u03C3R2 / Math.sqrt(m);
11952
12031
  let t2 = avgBias3 / \u03C3B2;
11953
12032
  let p2 = Distributions.T.cdf(-Math.abs(t2), df2) + (1 - Distributions.T.cdf(Math.abs(t2), df2));
11954
- console.log({ t: t2, df: df2, \u03C3B: \u03C3B2, \u03C3R: \u03C3R2, m, rBar: rBar2, d2: d22 });
11955
12033
  partBiasObjects.push({
11956
12034
  ReferenceValue: ref,
11957
12035
  Bias: avgBias3,
package/dist/index.mjs CHANGED
@@ -952,7 +952,6 @@ var Capability = {
952
952
  */
953
953
  Cp(data, spec, subgroupSize = 1, method, w, UnbiasingConstant2 = true) {
954
954
  let standarddeviation = StDev.W(data, subgroupSize, method, w, UnbiasingConstant2);
955
- console.log({ StDevW: standarddeviation });
956
955
  if (!Number.isNaN(spec.USL) && !Number.isNaN(spec.LSL)) {
957
956
  return Number((spec.USL - spec.LSL) / (6 * standarddeviation));
958
957
  } else {
@@ -1676,10 +1675,34 @@ var Beta = {
1676
1675
  * @param a The first shape parameter; x^(a-1).
1677
1676
  * @param b The second shape parameter; (1 - x)^(b-1).
1678
1677
  */
1679
- inc(x, a, b) {
1678
+ inc(X, A, B) {
1679
+ var A0 = 0;
1680
+ var B0 = 1;
1681
+ var A1 = 1;
1682
+ var B1 = 1;
1683
+ var M9 = 0;
1684
+ var A2 = 0;
1685
+ var C9;
1686
+ while (Math.abs((A1 - A2) / A1) > 1e-5) {
1687
+ A2 = A1;
1688
+ C9 = -(A + M9) * (A + B + M9) * X / (A + 2 * M9) / (A + 2 * M9 + 1);
1689
+ A0 = A1 + C9 * A0;
1690
+ B0 = B1 + C9 * B0;
1691
+ M9 = M9 + 1;
1692
+ C9 = M9 * (B - M9) * X / (A + 2 * M9 - 1) / (A + 2 * M9);
1693
+ A1 = A0 + C9 * A1;
1694
+ B1 = B0 + C9 * B1;
1695
+ A0 = A0 / B1;
1696
+ B0 = B0 / B1;
1697
+ A1 = A1 / B1;
1698
+ B1 = 1;
1699
+ }
1700
+ return A1 / A;
1701
+ },
1702
+ incomplete(x, a, b) {
1680
1703
  var bt = x === 0 || x === 1 ? 0 : Math.exp(Gamma.ln(a + b) - Gamma.ln(a) - Gamma.ln(b) + a * Math.log(x) + b * Math.log(1 - x));
1681
1704
  if (x < 0 || x > 1)
1682
- return NaN;
1705
+ return false;
1683
1706
  if (x < (a + 1) / (a + b + 2))
1684
1707
  return bt * Beta.cf(x, a, b) / a;
1685
1708
  return 1 - bt * Beta.cf(1 - x, b, a) / b;
@@ -1693,6 +1716,54 @@ var Beta = {
1693
1716
  */
1694
1717
  incr(x, a, b) {
1695
1718
  return Beta.inc(x, a, b) / Beta.fn(a, b);
1719
+ },
1720
+ invInc(p, a, b) {
1721
+ var EPS = 1e-8;
1722
+ var a1 = a - 1;
1723
+ var b1 = b - 1;
1724
+ var j = 0;
1725
+ var lna, lnb, pp, t, u, err, x, al, h, w, afac;
1726
+ if (p <= 0)
1727
+ return 0;
1728
+ if (p >= 1)
1729
+ return 1;
1730
+ if (a >= 1 && b >= 1) {
1731
+ pp = p < 0.5 ? p : 1 - p;
1732
+ t = Math.sqrt(-2 * Math.log(pp));
1733
+ x = (2.30753 + t * 0.27061) / (1 + t * (0.99229 + t * 0.04481)) - t;
1734
+ if (p < 0.5)
1735
+ x = -x;
1736
+ al = (x * x - 3) / 6;
1737
+ h = 2 / (1 / (2 * a - 1) + 1 / (2 * b - 1));
1738
+ w = x * Math.sqrt(al + h) / h - (1 / (2 * b - 1) - 1 / (2 * a - 1)) * (al + 5 / 6 - 2 / (3 * h));
1739
+ x = a / (a + b * Math.exp(2 * w));
1740
+ } else {
1741
+ lna = Math.log(a / (a + b));
1742
+ lnb = Math.log(b / (a + b));
1743
+ t = Math.exp(a * lna) / a;
1744
+ u = Math.exp(b * lnb) / b;
1745
+ w = t + u;
1746
+ if (p < t / w)
1747
+ x = Math.pow(a * w * p, 1 / a);
1748
+ else
1749
+ x = 1 - Math.pow(b * w * (1 - p), 1 / b);
1750
+ }
1751
+ afac = -Gamma.ln(a) - Gamma.ln(b) + Gamma.ln(a + b);
1752
+ for (; j < 10; j++) {
1753
+ if (x === 0 || x === 1)
1754
+ return x;
1755
+ err = Beta.incomplete(x, a, b) - p;
1756
+ t = Math.exp(a1 * Math.log(x) + b1 * Math.log(1 - x) + afac);
1757
+ u = err / t;
1758
+ x -= t = u / (1 - 0.5 * Math.min(1, u * (a1 / x - b1 / (1 - x))));
1759
+ if (x <= 0)
1760
+ x = 0.5 * (x + t);
1761
+ if (x >= 1)
1762
+ x = 0.5 * (x + t + 1);
1763
+ if (Math.abs(t) < EPS * x && j > 0)
1764
+ break;
1765
+ }
1766
+ return x;
1696
1767
  }
1697
1768
  };
1698
1769
  var ERF = {
@@ -1857,7 +1928,17 @@ var Distributions = {
1857
1928
  * @param b The second shape parameter; (1 - x)^(b-1).
1858
1929
  */
1859
1930
  cdf(x, a, b) {
1860
- return Beta.incr(x, a, b);
1931
+ var S;
1932
+ var BT;
1933
+ var Bcdf;
1934
+ S = a + b;
1935
+ BT = Math.exp(Gamma.ln(S) - Gamma.ln(b) - Gamma.ln(a) + a * Math.log(x) + b * Math.log(1 - x));
1936
+ if (x < (a + 1) / (S + 2)) {
1937
+ Bcdf = BT * Beta.inc(x, a, b);
1938
+ } else {
1939
+ Bcdf = 1 - BT * Beta.inc(1 - x, b, a);
1940
+ }
1941
+ return Bcdf;
1861
1942
  },
1862
1943
  /**
1863
1944
  * Probability Density Function. Calculates the probability of random variable x occuring from the beta distribution with the specified shape parameters a and b.
@@ -3726,8 +3807,8 @@ var Distributions = {
3726
3807
  * @returns the Right-Tailed P-Value of the F Distribution
3727
3808
  */
3728
3809
  cdf(x, df1, df2) {
3729
- let subX = df1 * x / (df1 * x + df2);
3730
- let p = Beta.incr(subX, df1 / 2, df2 / 2);
3810
+ let z = x / (x + df2 / df1);
3811
+ let p = Distributions.Beta.cdf(z, df1 / 2, df2 / 2);
3731
3812
  if (p > 1) {
3732
3813
  p = 1;
3733
3814
  }
@@ -4645,7 +4726,7 @@ var Distributions = {
4645
4726
  if (p == 0.5) {
4646
4727
  return 0;
4647
4728
  }
4648
- let x = Distributions.Beta.inv(2 * Math.min(p, 1 - p), 0.5 * df, 0.5);
4729
+ var x = Beta.invInc(2 * Math.min(p, 1 - p), 0.5 * df, 0.5);
4649
4730
  x = Math.sqrt(df * (1 - x) / x);
4650
4731
  return p > 0.5 ? x : -x;
4651
4732
  }
@@ -5178,9 +5259,7 @@ var ANOVA = {
5178
5259
  let pooledSTD = StDev.Pooled(pooledData);
5179
5260
  let alphaADJ = (1 - Math.pow(1 - alpha, 1 / rCount)) / 2;
5180
5261
  let hAlpha = Math.abs(Distributions.T.inv(alphaADJ, grandArray.length - rCount));
5181
- console.log({ alphaADJ, ln: grandArray.length, rCount });
5182
5262
  let scaleDF = Math.sqrt((rCount - 1) / (rCount * tCount));
5183
- console.log({ grandMean, pooledSTD, hAlpha, scaleDF });
5184
5263
  let UDL = grandMean + pooledSTD * hAlpha * scaleDF;
5185
5264
  let LDL = grandMean - pooledSTD * hAlpha * scaleDF;
5186
5265
  let chartSettings = new ChartSettings();
@@ -7446,7 +7525,7 @@ var EquivalenceTesting = {
7446
7525
  let mean = Mean(dta);
7447
7526
  let se = StandardError(dta);
7448
7527
  let LSL = multiply ? lowerSpecification * target : lowerSpecification;
7449
- let USL = multiply ? upperSpecification * target : lowerSpecification;
7528
+ let USL = multiply ? upperSpecification * target : upperSpecification;
7450
7529
  let diff = mean - target;
7451
7530
  let CI_Low = Math.min((LSL + USL) / 2, diff - Distributions.T.inv(1 - confidenceLevel, dta.length - 1) * se);
7452
7531
  let CI_High = Math.max((LSL + USL) / 2, diff + Distributions.T.inv(1 - confidenceLevel, dta.length - 1) * se);
@@ -7773,7 +7852,7 @@ var NonparametricTesting = {
7773
7852
  let avgOverallRank = Mean(combinedRanks);
7774
7853
  let N = combinedData.length;
7775
7854
  let zValues = avgRanks.map((Rj, j) => {
7776
- return (Rj - avgOverallRank) / Math.sqrt((N + 1) * (N / data[j].length - 1) / 12);
7855
+ return (Rj - avgOverallRank) / Math.sqrt((N + 1) * (N / extractedData[j].length - 1) / 12);
7777
7856
  });
7778
7857
  let tieSets = CompileTies(combinedData);
7779
7858
  let adjustH = tieSets.length > 0;
@@ -11825,7 +11904,6 @@ function GageLinearityAndBias(parts, referenceValues, responses, processVariatio
11825
11904
  let \u03C3B2 = \u03C3R2 / Math.sqrt(m);
11826
11905
  let t2 = avgBias3 / \u03C3B2;
11827
11906
  let p2 = Distributions.T.cdf(-Math.abs(t2), df2) + (1 - Distributions.T.cdf(Math.abs(t2), df2));
11828
- console.log({ t: t2, df: df2, \u03C3B: \u03C3B2, \u03C3R: \u03C3R2, m, rBar: rBar2, d2: d22 });
11829
11907
  partBiasObjects.push({
11830
11908
  ReferenceValue: ref,
11831
11909
  Bias: avgBias3,
package/index.ts CHANGED
@@ -1080,7 +1080,6 @@ CI:{
1080
1080
  */
1081
1081
  Cp(data: number[], spec: Specification, subgroupSize: number = 1, method?: string, w?: number, UnbiasingConstant: boolean = true){
1082
1082
  let standarddeviation = StDev.W(data, subgroupSize, method, w, UnbiasingConstant);
1083
- console.log({StDevW: standarddeviation})
1084
1083
  if(!Number.isNaN(spec.USL) && !Number.isNaN(spec.LSL)){
1085
1084
  return Number((spec.USL - spec.LSL) / (6 * standarddeviation));
1086
1085
  }else{
@@ -1899,28 +1898,39 @@ export const Beta = {
1899
1898
  * @param a The first shape parameter; x^(a-1).
1900
1899
  * @param b The second shape parameter; (1 - x)^(b-1).
1901
1900
  */
1902
- inc(x: number, a: number, b: number){
1903
- // let sum = 0;
1904
-
1905
- // for(let n = 0; n < 1000; n++){
1906
- // let ploc = PlochhammerSymbol(1-b, n);
1907
- // let den = Probability.Factorialize(n) * (a + n);
1908
- // let xn = Math.pow(x, n);
1909
- // let term_n = ploc / den * xn;
1910
- // if(Math.abs(term_n) < 1e-9 && n > 100){
1911
- // n = 1001
1912
- // }
1913
- // sum += term_n;
1914
- // }
1915
- // return Math.pow(x, a) * sum;
1916
-
1901
+ inc(X: number, A: number, B: number){
1902
+ var A0=0;
1903
+ var B0=1;
1904
+ var A1=1;
1905
+ var B1=1;
1906
+ var M9=0;
1907
+ var A2=0;
1908
+ var C9;
1909
+ while (Math.abs((A1-A2)/A1)>.00001) {
1910
+ A2=A1;
1911
+ C9=-(A+M9)*(A+B+M9)*X/(A+2*M9)/(A+2*M9+1);
1912
+ A0=A1+C9*A0;
1913
+ B0=B1+C9*B0;
1914
+ M9=M9+1;
1915
+ C9=M9*(B-M9)*X/(A+2*M9-1)/(A+2*M9);
1916
+ A1=A0+C9*A1;
1917
+ B1=B0+C9*B1;
1918
+ A0=A0/B1;
1919
+ B0=B0/B1;
1920
+ A1=A1/B1;
1921
+ B1=1;
1922
+ }
1923
+ return A1/A
1924
+
1925
+ },
1926
+ incomplete(x, a, b): any{
1917
1927
  // Factors in front of the continued fraction.
1918
1928
  var bt = (x === 0 || x === 1) ? 0 :
1919
1929
  Math.exp(Gamma.ln(a + b) - Gamma.ln(a) -
1920
- Gamma.ln(b) + a * Math.log(x) + b *
1930
+ Gamma.ln(b) + a * Math.log(x) + b *
1921
1931
  Math.log(1 - x));
1922
1932
  if (x < 0 || x > 1)
1923
- return NaN;
1933
+ return false;
1924
1934
  if (x < (a + 1) / (a + b + 2))
1925
1935
  // Use continued fraction directly.
1926
1936
  return bt * Beta.cf(x, a, b) / a;
@@ -1936,7 +1946,56 @@ export const Beta = {
1936
1946
  */
1937
1947
  incr(x: number, a: number, b: number){
1938
1948
  return Beta.inc(x, a, b)/Beta.fn(a, b)
1939
- }
1949
+ },
1950
+ invInc(p, a, b){
1951
+ var EPS = 1e-8;
1952
+ var a1 = a - 1;
1953
+ var b1 = b - 1;
1954
+ var j = 0;
1955
+ var lna, lnb, pp, t, u, err, x, al, h, w, afac;
1956
+ if (p <= 0)
1957
+ return 0;
1958
+ if (p >= 1)
1959
+ return 1;
1960
+ if (a >= 1 && b >= 1) {
1961
+ pp = (p < 0.5) ? p : 1 - p;
1962
+ t = Math.sqrt(-2 * Math.log(pp));
1963
+ x = (2.30753 + t * 0.27061) / (1 + t* (0.99229 + t * 0.04481)) - t;
1964
+ if (p < 0.5)
1965
+ x = -x;
1966
+ al = (x * x - 3) / 6;
1967
+ h = 2 / (1 / (2 * a - 1) + 1 / (2 * b - 1));
1968
+ w = (x * Math.sqrt(al + h) / h) - (1 / (2 * b - 1) - 1 / (2 * a - 1)) *
1969
+ (al + 5 / 6 - 2 / (3 * h));
1970
+ x = a / (a + b * Math.exp(2 * w));
1971
+ } else {
1972
+ lna = Math.log(a / (a + b));
1973
+ lnb = Math.log(b / (a + b));
1974
+ t = Math.exp(a * lna) / a;
1975
+ u = Math.exp(b * lnb) / b;
1976
+ w = t + u;
1977
+ if (p < t / w)
1978
+ x = Math.pow(a * w * p, 1 / a);
1979
+ else
1980
+ x = 1 - Math.pow(b * w * (1 - p), 1 / b);
1981
+ }
1982
+ afac = -Gamma.ln(a) - Gamma.ln(b) + Gamma.ln(a + b);
1983
+ for(; j < 10; j++) {
1984
+ if (x === 0 || x === 1)
1985
+ return x;
1986
+ err = Beta.incomplete(x, a, b) - p;
1987
+ t = Math.exp(a1 * Math.log(x) + b1 * Math.log(1 - x) + afac);
1988
+ u = err / t;
1989
+ x -= (t = u / (1 - 0.5 * Math.min(1, u * (a1 / x - b1 / (1 - x)))));
1990
+ if (x <= 0)
1991
+ x = 0.5 * (x + t);
1992
+ if (x >= 1)
1993
+ x = 0.5 * (x + t + 1);
1994
+ if (Math.abs(t) < EPS * x && j > 0)
1995
+ break;
1996
+ }
1997
+ return x;
1998
+ }
1940
1999
  }
1941
2000
 
1942
2001
  export const ERF = {
@@ -2136,7 +2195,18 @@ export const Distributions = {
2136
2195
  * @param b The second shape parameter; (1 - x)^(b-1).
2137
2196
  */
2138
2197
  cdf(x: number, a: number, b: number){
2139
- return Beta.incr(x, a, b);
2198
+ var S;
2199
+ var BT;
2200
+ var Bcdf;
2201
+
2202
+ S = a + b;
2203
+ BT = Math.exp(Gamma.ln(S) - Gamma.ln(b) - Gamma.ln(a) + a * Math.log(x) + b * Math.log(1 - x));
2204
+ if (x < (a + 1)/(S + 2)) {
2205
+ Bcdf = BT * Beta.inc(x, a, b)
2206
+ } else {
2207
+ Bcdf = 1 - BT * Beta.inc(1 - x, b, a)
2208
+ }
2209
+ return Bcdf
2140
2210
  },
2141
2211
  /**
2142
2212
  * Probability Density Function. Calculates the probability of random variable x occuring from the beta distribution with the specified shape parameters a and b.
@@ -4011,8 +4081,8 @@ export const Distributions = {
4011
4081
  * @returns the Right-Tailed P-Value of the F Distribution
4012
4082
  */
4013
4083
  cdf(x: number, df1: number, df2: number){
4014
- let subX = (df1 * x)/(df1 * x + df2);
4015
- let p = Beta.incr(subX, df1/2, df2/2);
4084
+ let z = x / (x + df2/df1)
4085
+ let p = Distributions.Beta.cdf(z, df1/2, df2/2)
4016
4086
  if(p > 1){p = 1}
4017
4087
  if(p < 0){p = 0}
4018
4088
  return p
@@ -4943,9 +5013,9 @@ export const Distributions = {
4943
5013
  // if(t){
4944
5014
  // return t
4945
5015
  // }
4946
- let x = Distributions.Beta.inv(2*Math.min(p, 1-p), 0.5*df, 0.5);
4947
- x = Math.sqrt(df*(1-x)/x);
4948
- return p > 0.5 ? x : -x;
5016
+ var x = Beta.invInc(2 * Math.min(p, 1 - p), 0.5 * df, 0.5);
5017
+ x = Math.sqrt(df * (1 - x) / x);
5018
+ return (p > 0.5) ? x : -x;
4949
5019
  },
4950
5020
  // invTable(p: number, df: number){
4951
5021
  // // let table = tTable
@@ -5583,10 +5653,9 @@ export const ANOVA = {
5583
5653
  let pooledSTD = StDev.Pooled(pooledData);
5584
5654
  let alphaADJ = (1 - Math.pow(1-alpha,1/rCount))/2;
5585
5655
  let hAlpha = Math.abs(Distributions.T.inv(alphaADJ, grandArray.length - rCount))
5586
- console.log({alphaADJ, ln: grandArray.length, rCount})
5656
+
5587
5657
  let scaleDF = Math.sqrt((rCount-1)/(rCount*tCount));
5588
5658
 
5589
- console.log({grandMean, pooledSTD, hAlpha, scaleDF})
5590
5659
  let UDL = grandMean + pooledSTD*hAlpha*scaleDF
5591
5660
  let LDL = grandMean - pooledSTD*hAlpha*scaleDF
5592
5661
 
@@ -6829,10 +6898,10 @@ export const ANOVA = {
6829
6898
  refMeanIndex += fx_i * prod
6830
6899
  })
6831
6900
  let refMean = refMeans[refMeanIndex]
6832
-
6901
+
6833
6902
  SumSq += Math.pow(levelMean - refMeans[refMeanIndex], 2);
6834
6903
  })
6835
-
6904
+
6836
6905
  ANOVA[fi].SS = abc * SumSq;
6837
6906
  ANOVA[fi].MS = ANOVA[fi].SS/ANOVA[fi].DF
6838
6907
  })
@@ -6841,6 +6910,7 @@ export const ANOVA = {
6841
6910
  factors.forEach((factor, factor_i) => {
6842
6911
  if(factor_i != factors.length - 1){
6843
6912
  ANOVA[factor_i].F = ANOVA[factor_i].MS / ANOVA[factor_i + 1].MS
6913
+
6844
6914
  ANOVA[factor_i].p = Distributions.F.RightTail(ANOVA[factor_i].F, ANOVA[factor_i].DF, ANOVA[factor_i + 1].DF)
6845
6915
  }
6846
6916
  })
@@ -7944,11 +8014,11 @@ export const EquivalenceTesting = {
7944
8014
  let mean = Mean(dta)
7945
8015
  let se = StandardError(dta)
7946
8016
  let LSL = multiply ? lowerSpecification * target : lowerSpecification
7947
- let USL = multiply ? upperSpecification * target : lowerSpecification
8017
+ let USL = multiply ? upperSpecification * target : upperSpecification
7948
8018
  let diff = mean - target;
7949
8019
 
7950
8020
  let CI_Low = Math.min((LSL + USL)/2, diff - Distributions.T.inv(1 - confidenceLevel, dta.length - 1)*se);
7951
- let CI_High = Math.max((LSL + USL)/2, diff + Distributions.T.inv(1 - confidenceLevel, dta.length - 1)*se)
8021
+ let CI_High = Math.max((LSL + USL)/2, diff + Distributions.T.inv(1 - confidenceLevel, dta.length - 1)*se);
7952
8022
 
7953
8023
  let equivChart = EquivalenceCharts.Equivalence({name: `Mean(${name ?? "Sample"})`, value: mean}, {name: "Target", value: target}, LSL, USL, CI_Low, CI_High, confidenceLevel);
7954
8024
  let histograms = EquivalenceCharts.Histogram([data])
@@ -8321,12 +8391,13 @@ export const NonparametricTesting = {
8321
8391
  let avgOverallRank = Mean(combinedRanks);
8322
8392
 
8323
8393
  let N = combinedData.length;
8324
- let zValues = avgRanks.map((Rj, j) => {return (Rj - avgOverallRank)/Math.sqrt(((N + 1)*(N/data[j].length - 1))/12)})
8325
-
8394
+ let zValues = avgRanks.map((Rj, j) => {return (Rj - avgOverallRank)/Math.sqrt(((N + 1)*(N/extractedData[j].length - 1))/12)})
8395
+
8326
8396
  let tieSets = CompileTies(combinedData)
8327
8397
  let adjustH = tieSets.length > 0
8328
8398
  let H = 12 * Sum(avgRanks.map((Rj, j) => {return data[j].length * Math.pow(Rj - avgOverallRank, 2)}))/(N *(N + 1));
8329
8399
  let H_not = 0 + H;
8400
+
8330
8401
  if(adjustH){
8331
8402
  // H = H/(1 - Sum(tieSets.map((t: any) => {return Math.pow(t.length, 3) - t.length}))/(Math.pow(N,3) - N));
8332
8403
  H = (12 / (N * (N + 1))) * (Sum(ranks.map(r => {return Math.pow(Sum(r),2)/r.length}))) - 3 *(N + 1);
@@ -12840,7 +12911,7 @@ export function GageLinearityAndBias(parts: any[], referenceValues: number[], re
12840
12911
  let σB = σR / Math.sqrt(m);
12841
12912
  let t = avgBias / σB
12842
12913
  let p = Distributions.T.cdf(-Math.abs(t), df) + (1 - Distributions.T.cdf(Math.abs(t), df))
12843
- console.log({t, df, σB, σR, m, rBar, d2});
12914
+
12844
12915
  partBiasObjects.push({
12845
12916
  ReferenceValue: ref,
12846
12917
  Bias: avgBias,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qesuite",
3
- "version": "1.0.65",
3
+ "version": "1.0.67",
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
+ - Updated T.Inv()