From e129f397c28baf4db0490b6d86ecbefa6b527597 Mon Sep 17 00:00:00 2001 From: jingyuexing <1941755817@qq.com> Date: Sat, 23 Mar 2019 03:50:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- statistics/T.targert.ts | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 statistics/T.targert.ts diff --git a/statistics/T.targert.ts b/statistics/T.targert.ts deleted file mode 100644 index 84a1533..0000000 --- a/statistics/T.targert.ts +++ /dev/null @@ -1,10 +0,0 @@ -class a{ - a:number=0; - c:number=0; - constructor(){ - this.a; - } - b(){ - this.c; - } -} \ No newline at end of file From 273919d605c7f4885d87b0ce94b5acd107658f0d Mon Sep 17 00:00:00 2001 From: jingyuexing <1941755817@qq.com> Date: Sat, 30 Mar 2019 19:06:49 +0800 Subject: [PATCH 2/2] fix some Error --- @type/vector.d.ts | 2 +- dist/statistics/Covariance.js | 31 ++++++++--------- dist/statistics/Covariance.js.map | 2 +- dist/statistics/Gaussian_distribution.js | 14 ++++++++ dist/statistics/Gaussian_distribution.js.map | 1 + dist/statistics/LeastSquare.js | 2 +- dist/statistics/LeastSquare.js.map | 2 +- dist/statistics/Matrix.js | 35 ++++++++++++++++++-- dist/statistics/Matrix.js.map | 2 +- dist/statistics/Standard_Deviation.js | 9 +++++ dist/statistics/Standard_Deviation.js.map | 1 + dist/statistics/Summation.js | 5 +++ dist/statistics/Summation.js.map | 2 +- dist/statistics/expetation.js | 21 ++++++++++++ dist/statistics/expetation.js.map | 1 + dist/statistics/factorial.js | 25 +++++--------- dist/statistics/factorial.js.map | 2 +- dist/statistics/gcd.js | 16 +++++++++ dist/statistics/gcd.js.map | 1 + dist/statistics/harmonic.js | 16 +++++++++ dist/statistics/harmonic.js.map | 1 + dist/statistics/index.js | 18 ++++++++-- dist/statistics/index.js.map | 2 +- dist/statistics/powerFactorial.js | 8 +++++ dist/statistics/powerFactorial.js.map | 1 + dist/statistics/product.js | 2 ++ dist/statistics/product.js.map | 2 +- dist/statistics/rank.js | 28 +++++++++++++++- dist/statistics/rank.js.map | 2 +- dist/statistics/sigmoid.js | 2 +- dist/statistics/sigmoid.js.map | 2 +- dist/statistics/subFactorial.js | 8 +++++ dist/statistics/subFactorial.js.map | 1 + dist/statistics/tree.js | 2 -- dist/statistics/tree.js.map | 2 +- dist/statistics/vector.js | 4 +-- dist/statistics/vector.js.map | 2 +- dist/statistics/weigth_variance.js | 30 +++++++++++++++++ dist/statistics/weigth_variance.js.map | 1 + package.json | 1 + statistics/Gaussian_distribution.ts | 4 +-- statistics/LeastSquare.ts | 2 +- statistics/Summation.ts | 2 +- statistics/factorial.ts | 14 +++----- statistics/harmonic.ts | 13 ++++++++ statistics/index.ts | 5 +-- statistics/powerFactorial.ts | 6 ++++ statistics/product.ts | 4 +-- statistics/sigmoid.ts | 2 +- statistics/subFactorial.ts | 5 +++ statistics/tree.ts | 6 +--- 51 files changed, 290 insertions(+), 82 deletions(-) create mode 100644 dist/statistics/Gaussian_distribution.js create mode 100644 dist/statistics/Gaussian_distribution.js.map create mode 100644 dist/statistics/Standard_Deviation.js create mode 100644 dist/statistics/Standard_Deviation.js.map create mode 100644 dist/statistics/expetation.js create mode 100644 dist/statistics/expetation.js.map create mode 100644 dist/statistics/gcd.js create mode 100644 dist/statistics/gcd.js.map create mode 100644 dist/statistics/harmonic.js create mode 100644 dist/statistics/harmonic.js.map create mode 100644 dist/statistics/powerFactorial.js create mode 100644 dist/statistics/powerFactorial.js.map create mode 100644 dist/statistics/subFactorial.js create mode 100644 dist/statistics/subFactorial.js.map create mode 100644 dist/statistics/weigth_variance.js create mode 100644 dist/statistics/weigth_variance.js.map create mode 100644 statistics/harmonic.ts create mode 100644 statistics/powerFactorial.ts create mode 100644 statistics/subFactorial.ts diff --git a/@type/vector.d.ts b/@type/vector.d.ts index 96c1698..7198b21 100644 --- a/@type/vector.d.ts +++ b/@type/vector.d.ts @@ -30,7 +30,7 @@ interface Vector{ * @param {vector|Array} dada [和向量比较的向量或数据] * @return {boolean} [结果] */ - isVertical(dada:Vector|Array):boolean + vertical(dada:Vector|Array):boolean /** * 求两个向量的余弦,返回值为余弦值 * [angle 向量夹角] diff --git a/dist/statistics/Covariance.js b/dist/statistics/Covariance.js index f07c419..dab5744 100644 --- a/dist/statistics/Covariance.js +++ b/dist/statistics/Covariance.js @@ -4,24 +4,21 @@ Object.defineProperty(exports, "__esModule", { value: true }); * 协方差 */ var Mean_1 = require("./Mean"); -var Covariance = /** @class */ (function () { - function Covariance(_a, _b) { - var value_a = _a.slice(0); - var value_b = _b.slice(0); - if (value_a.length == value_b.length) { - var mean = Mean_1.Mean(value_a.slice()); - var mean_b = Mean_1.Mean(value_b.slice()); - var total = 0; - for (var i = 0; i <= value_a.length; i++) { - total += (value_a[i] - mean) * (value_b[i] - mean_b); - } - return total / value_a.length; - } - else { - throw Error("两个集合不均等!"); +function Covariance(_a, _b) { + var value_a = _a.slice(0); + var value_b = _b.slice(0); + if (value_a.length == value_b.length) { + var mean = Mean_1.Mean(value_a.slice()); + var mean_b = Mean_1.Mean(value_b.slice()); + var total = 0; + for (var i = 0; i <= value_a.length; i++) { + total += (value_a[i] - mean) * (value_b[i] - mean_b); } + return total / value_a.length; + } + else { + throw Error("两个集合不均等!"); } - return Covariance; -}()); +} exports.Cov = Covariance; //# sourceMappingURL=Covariance.js.map \ No newline at end of file diff --git a/dist/statistics/Covariance.js.map b/dist/statistics/Covariance.js.map index fdffa2e..b03e0b4 100644 --- a/dist/statistics/Covariance.js.map +++ b/dist/statistics/Covariance.js.map @@ -1 +1 @@ -{"version":3,"file":"Covariance.js","sourceRoot":"","sources":["../../statistics/Covariance.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,+BAA4B;AAC5B;IACC,oBAAY,EAA0B,EAAC,EAA0B;YAApD,qBAAU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AC7C;QACD,OAAO,KAAK,GAAC,OAAO,CAAC,MAAM,CAAC;KAC5B;SAAI;QACJ,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;KACxB;AACF,CAAC;AACoB,yBAAG"} \ No newline at end of file diff --git a/dist/statistics/Gaussian_distribution.js b/dist/statistics/Gaussian_distribution.js new file mode 100644 index 0000000..ea85c26 --- /dev/null +++ b/dist/statistics/Gaussian_distribution.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * 高斯正态分布 + */ +var Gaussiandistribution = /** @class */ (function () { + function Gaussiandistribution() { + this.E = Math.E; + this.PI = Math.PI; + } + return Gaussiandistribution; +}()); +exports.Gaussiandistribution = Gaussiandistribution; +//# sourceMappingURL=Gaussian_distribution.js.map \ No newline at end of file diff --git a/dist/statistics/Gaussian_distribution.js.map b/dist/statistics/Gaussian_distribution.js.map new file mode 100644 index 0000000..f1e4517 --- /dev/null +++ b/dist/statistics/Gaussian_distribution.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Gaussian_distribution.js","sourceRoot":"","sources":["../../statistics/Gaussian_distribution.ts"],"names":[],"mappings":";;AAGA;;GAEG;AAEH;IAGC;QACC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAChB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;IACnB,CAAC;IACF,2BAAC;AAAD,CAAC,AAPD,IAOC;AAPY,oDAAoB"} \ No newline at end of file diff --git a/dist/statistics/LeastSquare.js b/dist/statistics/LeastSquare.js index ea068d8..30f7df1 100644 --- a/dist/statistics/LeastSquare.js +++ b/dist/statistics/LeastSquare.js @@ -14,10 +14,10 @@ function LeastSquare(_a, _b, n) { if (a instanceof Array && b instanceof Array) { var __x__ = Mean_1.Mean(a); //求得x的平均值 var __y__ = Mean_1.Mean(b); //求得y的平均值 + var total_1 = 0, total_2 = 0, _a_, _b_, y_, temp = []; if (a.length != b.length) { throw TypeError("两个数组数据不符合"); } - var total_1 = void 0, total_2 = void 0, _a_ = void 0, _b_ = void 0, y_ = void 0, temp = void 0; for (var i = 0; i < a.length; i++) { total_1 = a[i] * b[i] - (a.length * __x__ * __y__); total_2 = Math.pow(a[i], 2) - (a.length * Math.pow(__x__, 2)); diff --git a/dist/statistics/LeastSquare.js.map b/dist/statistics/LeastSquare.js.map index c27d24b..a590252 100644 --- a/dist/statistics/LeastSquare.js.map +++ b/dist/statistics/LeastSquare.js.map @@ -1 +1 @@ -{"version":3,"file":"LeastSquare.js","sourceRoot":"","sources":["../../statistics/LeastSquare.ts"],"names":[],"mappings":";;AAAA,+BAA4B;AAK5B;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,EAAoB,EAAC,EAAoB,EAAC,CAAQ;QAAjD,eAAI;QAAiB,eAAI;IAC3C,IAAG,CAAC,YAAY,KAAK,IAAI,CAAC,YAAY,KAAK,EAAC;QACzC,IAAI,KAAK,GAAG,WAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;QAC9B,IAAI,KAAK,GAAG,WAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;QAC7B,IAAG,CAAC,CAAC,MAAM,IAAE,CAAC,CAAC,MAAM,EAAC;YAClB,MAAM,SAAS,CAAC,WAAW,CAAC,CAAA;SAC/B;QACD,IAAI,OAAO,SAAO,EAAC,OAAO,SAAO,EAAC,GAAG,SAAO,EAAC,GAAG,SAAO,EAAC,EAAE,SAAO,EAAC,IAAI,SAAa,CAAC;QACpF,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,CAAC,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;YACvB,OAAO,GAAE,CAAC,CAAC,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC,MAAM,GAAC,KAAK,GAAC,KAAK,CAAC,CAAC;YAC1C,OAAO,GAAG,SAAA,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA,GA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AC,EAAE,EAAC;YACvB,OAAO,GAAE,CAAC,CAAC,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC,MAAM,GAAC,KAAK,GAAC,KAAK,CAAC,CAAC;YAC1C,OAAO,GAAG,SAAA,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA,GAAC,CAAC,CAAC,CAAC,MAAM,GAAC,SAAA,KAAK,EAAE,CAAC,CAAA,CAAC,CAAC;SACzC;QACD,GAAG,GAAC,OAAO,GAAC,OAAO,CAAC;QACpB,GAAG,GAAG,KAAK,GAAG,GAAG,GAAC,KAAK,CAAC;QACxB,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,CAAC,EAAC,CAAC,EAAE,EAAC;YAChB,EAAE,GAAC,GAAG,GAAC,CAAC,GAAC,GAAG,CAAC;YACb,IAAI,CAAC,IAAI,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,EAAE,EAAC,CAAC,CAAC;SACzB;QACD,OAAO,IAAI,CAAC;KACf;SAAI;QACD,MAAM,SAAS,CAAC,aAAa,CAAC,CAAC;KAClC;AACL,CAAC;AACO,kCAAW"} \ No newline at end of file diff --git a/dist/statistics/Matrix.js b/dist/statistics/Matrix.js index 9d16000..08dc9b5 100644 --- a/dist/statistics/Matrix.js +++ b/dist/statistics/Matrix.js @@ -45,9 +45,10 @@ var Matrix = /** @class */ (function () { var tempMatrix = new Matrix(this.row, matrix.col); if (matrix instanceof Matrix) { if (this.col == matrix.row) { - for (var k = 0; k < this.col; k++) { - for (var i = 0; i < this.row; i++) { - for (var j = 0; j < matrix.col; j++) { + for (var i = 0; i < this.row; i++) { + for (var j = 0; j < matrix.col; j++) { + tempMatrix.data[i][j] = 0; + for (var k = 0; k < this.col; k++) { tempMatrix.data[i][j] += this.data[i][k] * matrix.data[k][j]; } } @@ -114,6 +115,34 @@ var Matrix = /** @class */ (function () { } return (this, tempAry); }; + /** + * 求矩阵范数 + * @param {Matrix} A [description] + */ + Matrix.prototype.frobenius = function (A) { + var tempNums = 0; + for (var i = 0; i < A.row; i++) { + for (var j = 0; j < A.col; j++) { + tempNums += Math.pow(A.data[i][j], 2); + } + } + return Math.pow(tempNums, (1 / 2)); + }; + /** + * 矩阵的转置 + * [tran description] + * @param {Matrix} A [需被转置的矩阵] + * @return {Matrix} [转置后的结果] + */ + Matrix.prototype.tran = function (A) { + var NMatrix = new Matrix(A.col, A.row); + for (var i = 0; i < A.row; i++) { + for (var j = 0; j < A.col; j++) { + NMatrix.data[j][i] = A.data[i][j]; + } + } + return NMatrix; + }; return Matrix; }()); exports.Matrix = Matrix; diff --git a/dist/statistics/Matrix.js.map b/dist/statistics/Matrix.js.map index 8514a61..b895508 100644 --- a/dist/statistics/Matrix.js.map +++ b/dist/statistics/Matrix.js.map @@ -1 +1 @@ -{"version":3,"file":"Matrix.js","sourceRoot":"","sources":["../../statistics/Matrix.ts"],"names":[],"mappings":";;AAAA,oBAAkB;AAClB,mCAAkC;AAClC;;GAEG;AACH;IAIC,SAAS;IACT;;;;OAIG;IACH,gBAAY,GAAU,EAAC,GAAU;QAChC,IAAI,CAAC,GAAG,GAAC,GAAG,CAAC,CAAA,GAAG;QAChB,IAAI,CAAC,GAAG,GAAC,GAAG,CAAC,CAAA,GAAG;QAChB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5B,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,IAAI,CAAC,GAAG,EAAC,CAAC,EAAE,EAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;SAClC;IACF,CAAC;IACD;;OAEG;IACH,0BAAS,GAAT;QACC,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,IAAI,CAAC,GAAG,EAAC,CAAC,EAAE,EAAC;YAC1B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AC,CAAC,CAAC,CAAC;iBAC3B;aACD;SACD;QACD,OAAO,CAAC,IAAI,EAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IACD;;;OAGG;IACH,0BAAS,GAAT,UAAU,CAAQ;QACjB,IAAI,QAAQ,GAAQ,CAAC,CAAC;QACtB,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,CAAC,CAAC,GAAG,EAAC,CAAC,EAAE,EAAC;YACvB,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,CAAC,CAAC,GAAG,EAAC,CAAC,EAAE,EAAC;gBACvB,QAAQ,IAAG,SAAA,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA,CAAA;aAC1B;SACD;QACD,OAAO,SAAA,QAAQ,EAAE,CAAC,CAAC,GAAC,CAAC,CAAC,CAAA,CAAC;IACxB,CAAC;IACD;;;;;OAKG;IACH,qBAAI,GAAJ,UAAK,CAAQ;QACZ,IAAI,OAAO,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACtC,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,CAAC,CAAC,GAAG,EAAC,CAAC,EAAE,EAAC;YACvB,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,CAAC,CAAC,GAAG,EAAC,CAAC,EAAE,EAAC;gBACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAChC;SACD;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;IACF,aAAC;AAAD,CAAC,AA7ID,IA6IC;AACO,wBAAM"} \ No newline at end of file diff --git a/dist/statistics/Standard_Deviation.js b/dist/statistics/Standard_Deviation.js new file mode 100644 index 0000000..3102e62 --- /dev/null +++ b/dist/statistics/Standard_Deviation.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var StandardDeviation = /** @class */ (function () { + function StandardDeviation() { + } + return StandardDeviation; +}()); +exports.StandardDeviation = StandardDeviation; +//# sourceMappingURL=Standard_Deviation.js.map \ No newline at end of file diff --git a/dist/statistics/Standard_Deviation.js.map b/dist/statistics/Standard_Deviation.js.map new file mode 100644 index 0000000..7f835aa --- /dev/null +++ b/dist/statistics/Standard_Deviation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Standard_Deviation.js","sourceRoot":"","sources":["../../statistics/Standard_Deviation.ts"],"names":[],"mappings":";;AAAA;IAAA;IAIA,CAAC;IAAD,wBAAC;AAAD,CAAC,AAJD,IAIC;AAJY,8CAAiB"} \ No newline at end of file diff --git a/dist/statistics/Summation.js b/dist/statistics/Summation.js index cbaed9f..f2bb335 100644 --- a/dist/statistics/Summation.js +++ b/dist/statistics/Summation.js @@ -2,6 +2,11 @@ var Summation = /** @class */ (function () { function Summation(_a) { var num = _a.slice(0); + /** + * 求和 + * @param {Array} ...num [description] + */ + this.total = 0; for (var i = 0; i < num.length; i++) { this.total += num[i]; } diff --git a/dist/statistics/Summation.js.map b/dist/statistics/Summation.js.map index e136c13..d27f10e 100644 --- a/dist/statistics/Summation.js.map +++ b/dist/statistics/Summation.js.map @@ -1 +1 @@ -{"version":3,"file":"Summation.js","sourceRoot":"","sources":["../../statistics/Summation.ts"],"names":[],"mappings":";AAAA;IAMI,mBAAY,EAAsB;YAArB,iBAAM;QACf,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,GAAG,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;YACzB,IAAI,CAAC,KAAK,IAAE,GAAG,CAAC,CAAC,CAAC,CAAC;SACvB;IACJ,CAAC;IACD,6BAAS,GAAT;QACC,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IACL,gBAAC;AAAD,CAAC,AAdD,IAcC"} \ No newline at end of file +{"version":3,"file":"Summation.js","sourceRoot":"","sources":["../../statistics/Summation.ts"],"names":[],"mappings":";AAAA;IAMI,mBAAY,EAAsB;YAArB,iBAAM;QALtB;;;WAGG;QACH,UAAK,GAAQ,CAAC,CAAC;QAER,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,GAAG,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;YACzB,IAAI,CAAC,KAAK,IAAE,GAAG,CAAC,CAAC,CAAC,CAAC;SACvB;IACJ,CAAC;IACD,6BAAS,GAAT;QACC,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IACL,gBAAC;AAAD,CAAC,AAdD,IAcC"} \ No newline at end of file diff --git a/dist/statistics/expetation.js b/dist/statistics/expetation.js new file mode 100644 index 0000000..0bd6fbd --- /dev/null +++ b/dist/statistics/expetation.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * [expetation 期望值] + * @param {Array} ...x [样本空间] + * @param {Array} ...y [值域] + * @return {number} [期望值] + */ +function expetation(_a, _b) { + var x = _a.slice(0); + var y = _b.slice(0); + var sum = 0; + if (x.length == y.length) { + for (var i = 0; i < y.length; i++) { + sum += x[i] * y[i]; + } + } + return sum; +} +exports.expetation = expetation; +//# sourceMappingURL=expetation.js.map \ No newline at end of file diff --git a/dist/statistics/expetation.js.map b/dist/statistics/expetation.js.map new file mode 100644 index 0000000..41882b3 --- /dev/null +++ b/dist/statistics/expetation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"expetation.js","sourceRoot":"","sources":["../../statistics/expetation.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,SAAS,UAAU,CAAC,EAAoB,EAAC,EAAoB;QAAxC,eAAI;QAAiB,eAAI;IAC7C,IAAI,GAAG,GAAC,CAAC,CAAC;IACV,IAAG,CAAC,CAAC,MAAM,IAAE,CAAC,CAAC,MAAM,EAAC;QACrB,KAAI,IAAI,CAAC,GAAE,CAAC,EAAC,CAAC,GAAC,CAAC,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;YAC3B,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACjB;KACD;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AACO,gCAAU"} \ No newline at end of file diff --git a/dist/statistics/factorial.js b/dist/statistics/factorial.js index 9d91e05..d104a48 100644 --- a/dist/statistics/factorial.js +++ b/dist/statistics/factorial.js @@ -1,23 +1,16 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** - * 求n的阶乘 + * [Factorial 阶乘] + * @param {number} n [阶乘数] + * @return {number} [阶乘值] */ -var Factorial = /** @class */ (function () { - function Factorial(n) { - var total = 1, k = n % 1; - /*if(k<1&&k>0){ - for(let m=1;m<=n;m+=0.1**String(k).length-2){ - //广义的求阶乘未实现 - total*=m; - } - }*/ - for (var i = 1; i <= n; i++) { - total *= i; - } - return total; +function Factorial(n) { + var total = 1, k = n % 1; + for (var i = 1; i <= n; i++) { + total *= i; } - return Factorial; -}()); + return total; +} exports.Factorial = Factorial; //# sourceMappingURL=factorial.js.map \ No newline at end of file diff --git a/dist/statistics/factorial.js.map b/dist/statistics/factorial.js.map index 1c3fb92..f3b98ee 100644 --- a/dist/statistics/factorial.js.map +++ b/dist/statistics/factorial.js.map @@ -1 +1 @@ -{"version":3,"file":"factorial.js","sourceRoot":"","sources":["../../statistics/factorial.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH;IACC,mBAAY,CAAQ;QACnB,IAAI,KAAK,GAAQ,CAAC,EAAC,CAAC,GAAQ,CAAC,GAAC,CAAC,CAAC;QAChC;;;;;WAKG;QACH,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,IAAE,CAAC,EAAC,CAAC,EAAE,EAAC;YACpB,KAAK,IAAE,CAAC,CAAC;SACT;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACF,gBAAC;AAAD,CAAC,AAdD,IAcC;AACO,8BAAS"} \ No newline at end of file +{"version":3,"file":"factorial.js","sourceRoot":"","sources":["../../statistics/factorial.ts"],"names":[],"mappings":";;AAAA;;;;GAIG;AACH,SAAS,SAAS,CAAC,CAAQ;IACzB,IAAI,KAAK,GAAQ,CAAC,EAAC,CAAC,GAAQ,CAAC,GAAC,CAAC,CAAC;IAChC,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,IAAE,CAAC,EAAC,CAAC,EAAE,EAAC;QACpB,KAAK,IAAE,CAAC,CAAC;KACT;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AACM,8BAAS"} \ No newline at end of file diff --git a/dist/statistics/gcd.js b/dist/statistics/gcd.js new file mode 100644 index 0000000..0ac2519 --- /dev/null +++ b/dist/statistics/gcd.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * gcd 最大公约数 + * @param {number} p [description] + * @param {number} q [description] + * @return {number} [description] + */ +function gcd(p, q) { + if (q === 0) + return p; + var r = p % q; + return gcd(q, r); +} +exports.gcd = gcd; +//# sourceMappingURL=gcd.js.map \ No newline at end of file diff --git a/dist/statistics/gcd.js.map b/dist/statistics/gcd.js.map new file mode 100644 index 0000000..922b52f --- /dev/null +++ b/dist/statistics/gcd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"gcd.js","sourceRoot":"","sources":["../../statistics/gcd.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,SAAS,GAAG,CAAC,CAAQ,EAAC,CAAQ;IAC7B,IAAG,CAAC,KAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACnB,IAAI,CAAC,GAAE,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,GAAG,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;AACjB,CAAC;AACO,kBAAG"} \ No newline at end of file diff --git a/dist/statistics/harmonic.js b/dist/statistics/harmonic.js new file mode 100644 index 0000000..ad263c1 --- /dev/null +++ b/dist/statistics/harmonic.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * [Harmonic 调和数] + * @param {number} n [description] + * @return {number} [description] + */ +function Harmonic(n) { + var total = 0; + for (var i = 1; i <= n; i++) { + total += (1 / i); + } + return total; +} +exports.Harmonic = Harmonic; +//# sourceMappingURL=harmonic.js.map \ No newline at end of file diff --git a/dist/statistics/harmonic.js.map b/dist/statistics/harmonic.js.map new file mode 100644 index 0000000..a9d8751 --- /dev/null +++ b/dist/statistics/harmonic.js.map @@ -0,0 +1 @@ +{"version":3,"file":"harmonic.js","sourceRoot":"","sources":["../../statistics/harmonic.ts"],"names":[],"mappings":";;AAAA;;;;GAIG;AACH,SAAS,QAAQ,CAAC,CAAQ;IACzB,IAAI,KAAK,GAAC,CAAC,CAAC;IACZ,KAAI,IAAI,CAAC,GAAQ,CAAC,EAAC,CAAC,IAAE,CAAC,EAAC,CAAC,EAAE,EAAC;QAC3B,KAAK,IAAE,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AACO,4BAAQ"} \ No newline at end of file diff --git a/dist/statistics/index.js b/dist/statistics/index.js index aacebb5..b114af6 100644 --- a/dist/statistics/index.js +++ b/dist/statistics/index.js @@ -1,10 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var Gaussian_distribution_1 = require("./Gaussian-distribution"); +var Gaussian_distribution_1 = require("./Gaussian_distribution"); exports.GD = Gaussian_distribution_1.Gaussiandistribution; var Variance_1 = require("./Variance"); exports.Vc = Variance_1.Variance; -var Standard_Deviation_1 = require("./Standard-Deviation"); +var Standard_Deviation_1 = require("./Standard_Deviation"); exports.SD = Standard_Deviation_1.StandardDeviation; var Bayes_1 = require("./Bayes"); exports.bayes = Bayes_1.bayes; @@ -12,7 +12,7 @@ var Mean_1 = require("./Mean"); exports.Mean = Mean_1.Mean; var Median_1 = require("./Median"); exports.Median = Median_1.Median; -var weigth_variance_1 = require("./weigth-variance"); +var weigth_variance_1 = require("./weigth_variance"); exports.WeiVar = weigth_variance_1.weigthVariance; var QuantilePlot_1 = require("./QuantilePlot"); exports.QuanPlot = QuantilePlot_1.QuantilePlot; @@ -24,4 +24,16 @@ var Permutations_1 = require("./Permutations"); exports.Permu = Permutations_1.Permu; var vector_1 = require("./vector"); exports.Vector = vector_1.Vector; +var sigmoid_1 = require("./sigmoid"); +exports.sigmoid = sigmoid_1.sigmoid; +var rank_1 = require("./rank"); +exports.Rank = rank_1.Rank; +var tensor_1 = require("./tensor"); +exports.Tensor = tensor_1.Tensor; +var LeastSquare_1 = require("./LeastSquare"); +exports.LeastSquare = LeastSquare_1.LeastSquare; +var gcd_1 = require("./gcd"); +exports.gcd = gcd_1.gcd; +var harmonic_1 = require("./harmonic"); +exports.Har = harmonic_1.Harmonic; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/statistics/index.js.map b/dist/statistics/index.js.map index 774df87..d0f1e16 100644 --- a/dist/statistics/index.js.map +++ b/dist/statistics/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../statistics/index.ts"],"names":[],"mappings":";;AAAA,iEAAmE;AAa3D,aAbwB,4CAAE,CAaxB;AAZV,uCAA0C;AAY/B,aAZS,mBAAE,CAYT;AAXb,2DAA6D;AAW/C,aAXe,sCAAE,CAWf;AAVhB,iCAA8B;AAUb,gBAVT,aAAK,CAUS;AATtB,+BAA2B;AASJ,eATf,WAAI,CASe;AAR3B,mCAAgC;AAQJ,iBARpB,eAAM,CAQoB;AAPlC,qDAA2D;AAOI,iBAPrC,gCAAM,CAOqC;AANrE,+CAAwD;AAMF,mBAN9B,2BAAQ,CAM8B;AAL9D,mCAAgC;AAKe,iBALvC,eAAM,CAKuC;AAJrD,yCAA+C;AAIN,gBAJpB,qBAAK,CAIoB;AAH9C,+CAAoC;AAGD,gBAH3B,oBAAK,CAG2B;AAFxC,mCAA+B;AAEuC,iBAF9D,eAAM,CAE8D"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../statistics/index.ts"],"names":[],"mappings":";;AAAA,iEAAmE;AAmB3D,aAnBwB,4CAAE,CAmBxB;AAlBV,uCAA0C;AAkB/B,aAlBS,mBAAE,CAkBT;AAjBb,2DAA6D;AAiB/C,aAjBe,sCAAE,CAiBf;AAhBhB,iCAA8B;AAgBT,gBAhBb,aAAK,CAgBa;AAf1B,+BAA2B;AAeK,eAfxB,WAAI,CAewB;AAdpC,mCAAgC;AAcK,iBAd7B,eAAM,CAc6B;AAb3C,qDAA2D;AAaa,iBAb9C,gCAAM,CAa8C;AAZ9E,+CAAwD;AAYO,mBAZvC,2BAAQ,CAYuC;AAXvE,mCAAgC;AAWwB,iBAXhD,eAAM,CAWgD;AAV9D,yCAA+C;AAUG,gBAV7B,qBAAK,CAU6B;AATvD,+CAAoC;AASQ,gBATpC,oBAAK,CASoC;AARjD,mCAAgC;AAQ+C,iBARvE,eAAM,CAQuE;AAPrF,qCAAkC;AAOoD,kBAP9E,iBAAO,CAO8E;AAN7F,+BAA4B;AAMD,eANnB,WAAI,CAMmB;AAL/B,mCAAgC;AAK8D,iBALtF,eAAM,CAKsF;AAJpG,6CAA0C;AAI2D,sBAJ7F,yBAAW,CAI6F;AAHhH,6BAA0B;AAGuF,cAHzG,SAAG,CAGyG;AAFpH,uCAA0C;AAEzB,cAFG,mBAAG,CAEH"} \ No newline at end of file diff --git a/dist/statistics/powerFactorial.js b/dist/statistics/powerFactorial.js new file mode 100644 index 0000000..27724ad --- /dev/null +++ b/dist/statistics/powerFactorial.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Factorial_1 = require("./Factorial"); +function powerFactorial(x, n) { + return Factorial_1.Factorial(x + n - 1) / Factorial_1.Factorial(x - 1); +} +exports.powerFactorial = powerFactorial; +//# sourceMappingURL=powerFactorial.js.map \ No newline at end of file diff --git a/dist/statistics/powerFactorial.js.map b/dist/statistics/powerFactorial.js.map new file mode 100644 index 0000000..cda93c4 --- /dev/null +++ b/dist/statistics/powerFactorial.js.map @@ -0,0 +1 @@ +{"version":3,"file":"powerFactorial.js","sourceRoot":"","sources":["../../statistics/powerFactorial.ts"],"names":[],"mappings":";;AAAA,yCAA4C;AAC5C,SAAS,cAAc,CAAC,CAAQ,EAAC,CAAQ;IAExC,OAAO,qBAAG,CAAC,CAAC,GAAC,CAAC,GAAC,CAAC,CAAC,GAAC,qBAAG,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AACO,wCAAc"} \ No newline at end of file diff --git a/dist/statistics/product.js b/dist/statistics/product.js index 11f2e94..d93bf90 100644 --- a/dist/statistics/product.js +++ b/dist/statistics/product.js @@ -6,6 +6,8 @@ var product = /** @class */ (function () { */ function product(_a) { var index = _a.slice(0); + this.total = 0; + this.ary = []; for (var i = 0; i < index.length; i++) { this.total += index[i]; this.ary.push(index[i]); diff --git a/dist/statistics/product.js.map b/dist/statistics/product.js.map index 8b636df..cf68dfe 100644 --- a/dist/statistics/product.js.map +++ b/dist/statistics/product.js.map @@ -1 +1 @@ -{"version":3,"file":"product.js","sourceRoot":"","sources":["../../statistics/product.ts"],"names":[],"mappings":";AAAA;IAGC;;;OAGG;IACH,iBAAY,EAAwB;YAAvB,mBAAQ;QACpB,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,KAAK,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;YAC9B,IAAI,CAAC,KAAK,IAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACxB;IACF,CAAC;IACD;;OAEG;IACH,qBAAG,GAAH;QACC,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IACD;;OAEG;IACH,yBAAO,GAAP;QACC,IAAI,KAAK,GAAC,CAAC,CAAC;QACZ,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;YACjC,KAAK,IAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACnB;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACF,cAAC;AAAD,CAAC,AA7BD,IA6BC"} \ No newline at end of file +{"version":3,"file":"product.js","sourceRoot":"","sources":["../../statistics/product.ts"],"names":[],"mappings":";AAAA;IAGC;;;OAGG;IACH,iBAAY,EAAwB;YAAvB,mBAAQ;QANrB,UAAK,GAAQ,CAAC,CAAC;QACf,QAAG,GAAe,EAAE,CAAC;QAMpB,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,KAAK,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;YAC9B,IAAI,CAAC,KAAK,IAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACxB;IACF,CAAC;IACD;;OAEG;IACH,qBAAG,GAAH;QACC,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IACD;;OAEG;IACH,yBAAO,GAAP;QACC,IAAI,KAAK,GAAC,CAAC,CAAC;QACZ,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;YACjC,KAAK,IAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACnB;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACF,cAAC;AAAD,CAAC,AA7BD,IA6BC"} \ No newline at end of file diff --git a/dist/statistics/rank.js b/dist/statistics/rank.js index 467f930..dece62e 100644 --- a/dist/statistics/rank.js +++ b/dist/statistics/rank.js @@ -1,4 +1,5 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); // 排序算法 var Rank = /** @class */ (function () { function Rank() { @@ -22,7 +23,7 @@ var Rank = /** @class */ (function () { return a; }; /** - * 冒泡拍寻 + * 冒泡排序 * @param {Array} ...a [需要排序的数据] * @return {Array} [排序好的数据] */ @@ -40,6 +41,31 @@ var Rank = /** @class */ (function () { } return a; }; + Rank.prototype.SelectSort = function () { + }; + Rank.prototype.quickSort = function (_a, begin, end) { + var arry = _a.slice(0); + var i = begin, j = end, key = arry[begin]; + while (i < j) { + while (i < j && arry[j] >= key) + j--; + if (i < j) { + arry[i] = arry[j]; + i++; + } + while (i < j && arry[i] < key) + i++; + if (i < j) { + arry[j] = arry[i]; + j--; + } + } + arry[i] = key; + this.quickSort(arry, begin, i - 1); + this.quickSort(arry, i + 1, end); + return arry; + }; return Rank; }()); +exports.Rank = Rank; //# sourceMappingURL=rank.js.map \ No newline at end of file diff --git a/dist/statistics/rank.js.map b/dist/statistics/rank.js.map index 7532fff..81874b6 100644 --- a/dist/statistics/rank.js.map +++ b/dist/statistics/rank.js.map @@ -1 +1 @@ -{"version":3,"file":"rank.js","sourceRoot":"","sources":["../../statistics/rank.ts"],"names":[],"mappings":";AAAA,OAAO;AACP;IAAA;IAmCA,CAAC;IAlCA;;;OAGG;IACH,qBAAM,GAAN,UAAO,EAAoB;YAAnB,eAAI;QACX,IAAI,GAAU,EAAC,CAAQ,CAAC;QACxB,KAAI,IAAI,CAAC,GAAQ,CAAC,EAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;YACpC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACX,CAAC,GAAG,CAAC,GAAC,CAAC,CAAC;YACR,OAAM,CAAC,GAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAC,GAAG,EAAC;gBACrB,CAAC,CAAC,CAAC,GAAC,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACZ,CAAC,GAAC,CAAC,GAAC,CAAC,CAAC;gBACN,CAAC,C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CAAC,CAAC,GAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAChB,CAAC,EAAE,CAAC;aACJ;YACD,OAAM,CAAC,GAAC,CAAC,IAAE,IAAI,CAAC,CAAC,CAAC,GAAC,GAAG;gBAAE,CAAC,EAAE,CAAC;YAC5B,IAAG,CAAC,GAAC,CAAC,EAAC;gBACN,IAAI,CAAC,CAAC,CAAC,GAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAChB,CAAC,EAAE,CAAC;aACJ;SACD;QACD,IAAI,CAAC,CAAC,CAAC,GAAC,GAAG,CAAC;QACZ,IAAI,CAAC,SAAS,CAAC,IAAI,EAAC,KAAK,EAAC,CAAC,GAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,IAAI,EAAC,CAAC,GAAC,CAAC,EAAC,GAAG,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IACF,WAAC;AAAD,CAAC,AA3DD,IA2DC;AACO,oBAAI"} \ No newline at end of file diff --git a/dist/statistics/sigmoid.js b/dist/statistics/sigmoid.js index 8797e7d..2c93874 100644 --- a/dist/statistics/sigmoid.js +++ b/dist/statistics/sigmoid.js @@ -8,5 +8,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); function sigmoid(x) { return 1 / (1 + Math.pow(Math.E, (-x))); } -exports.default = sigmoid; +exports.sigmoid = sigmoid; //# sourceMappingURL=sigmoid.js.map \ No newline at end of file diff --git a/dist/statistics/sigmoid.js.map b/dist/statistics/sigmoid.js.map index 25db9f7..ff9e31c 100644 --- a/dist/statistics/sigmoid.js.map +++ b/dist/statistics/sigmoid.js.map @@ -1 +1 @@ -{"version":3,"file":"sigmoid.js","sourceRoot":"","sources":["../../statistics/sigmoid.ts"],"names":[],"mappings":";;AAAA;;;;GAIG;AACH,SAAS,OAAO,CAAC,CAAQ;IACrB,OAAO,CAAC,GAAC,CAAC,CAAC,GAAC,SAAA,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC;AAC9B,CAAC;AACD,kBAAe,OAAO,CAAC"} \ No newline at end of file +{"version":3,"file":"sigmoid.js","sourceRoot":"","sources":["../../statistics/sigmoid.ts"],"names":[],"mappings":";;AAAA;;;;GAIG;AACH,SAAS,OAAO,CAAC,CAAQ;IACrB,OAAO,CAAC,GAAC,CAAC,CAAC,GAAC,SAAA,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC;AAC9B,CAAC;AACO,0BAAO"} \ No newline at end of file diff --git a/dist/statistics/subFactorial.js b/dist/statistics/subFactorial.js new file mode 100644 index 0000000..0374c50 --- /dev/null +++ b/dist/statistics/subFactorial.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Factorial_1 = require("./Factorial"); +function subFactorial(x, n) { + return Factorial_1.Factorial(x) / Factorial_1.Factorial(x - n); +} +exports.subFactorial = subFactorial; +//# sourceMappingURL=subFactorial.js.map \ No newline at end of file diff --git a/dist/statistics/subFactorial.js.map b/dist/statistics/subFactorial.js.map new file mode 100644 index 0000000..82698d3 --- /dev/null +++ b/dist/statistics/subFactorial.js.map @@ -0,0 +1 @@ +{"version":3,"file":"subFactorial.js","sourceRoot":"","sources":["../../statistics/subFactorial.ts"],"names":[],"mappings":";;AAAA,yCAA4C;AAC5C,SAAS,YAAY,CAAC,CAAQ,EAAC,CAAQ;IACtC,OAAO,qBAAG,CAAC,CAAC,CAAC,GAAC,qBAAG,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC;AACxB,CAAC;AACO,oCAAY"} \ No newline at end of file diff --git a/dist/statistics/tree.js b/dist/statistics/tree.js index 84f9e38..f2a884f 100644 --- a/dist/statistics/tree.js +++ b/dist/statistics/tree.js @@ -1,8 +1,6 @@ "use strict"; var Tree = /** @class */ (function () { function Tree() { - var Root; - Root.parent = null; } return Tree; }()); diff --git a/dist/statistics/tree.js.map b/dist/statistics/tree.js.map index 3753a9e..319ff89 100644 --- a/dist/statistics/tree.js.map +++ b/dist/statistics/tree.js.map @@ -1 +1 @@ -{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../statistics/tree.ts"],"names":[],"mappings":";AAKA;IACC;QACC,IAAI,IAAU,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IAEpB,CAAC;IACF,WAAC;AAAD,CAAC,AAND,IAMC"} \ No newline at end of file +{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../statistics/tree.ts"],"names":[],"mappings":";AAKA;IAAA;IAEA,CAAC;IAAD,WAAC;AAAD,CAAC,AAFD,IAEC"} \ No newline at end of file diff --git a/dist/statistics/vector.js b/dist/statistics/vector.js index 1002f0c..2619fba 100644 --- a/dist/statistics/vector.js +++ b/dist/statistics/vector.js @@ -97,14 +97,14 @@ var Vector = /** @class */ (function () { * @param {vector|Array} dada [和向量比较的向量或数据] * @return {boolean} [结果] */ - Vector.prototype.vertical = function (dada) { + Vector.prototype.isVertical = function (dada) { if (dada instanceof Array) { if (this.product(dada) == 0) { return true; } } if (dada instanceof Vector) { - this.vertical(dada.data); + this.isVertical(dada.data); } return false; }; diff --git a/dist/statistics/vector.js.map b/dist/statistics/vector.js.map index e7899db..0f10b69 100644 --- a/dist/statistics/vector.js.map +++ b/dist/statistics/vector.js.map @@ -1 +1 @@ -{"version":3,"file":"vector.js","sourceRoot":"","sources":["../../statistics/vector.ts"],"names":[],"mappings":";;AAAA;IAEI;;;OAGG;IACH,gBAAY,EAAuB;YAAtB,kBAAO;QAChB,IAAI,CAAC,IAAI,GAAE,IAAI,CAAC;IACpB,CAAC;IACD;;;;OAIG;IACH,oBAAG,GAAH,UAAI,IAAW;QACX,IAAI,OAAO,GAAe,EAAE,CAAC;QAC7B,IAAG,IAAI,YAAY,MAAM,IAAG,IAAI,CAAC,IAAI,CAAC,MAAM,IAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAC;YAC3D,KAAI,IAAI,CAAC,GAAC,C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EAAC;YACtB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SAC3B;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IACD;;;;OAIG;IACH,sBAAK,GAAL,UAAM,IAAyB;QAC3B,IAAG,IAAI,YAAY,KAAK,EAAC;YACrB,IAAI,KAAK,GAAS,CAAC,CAAC;YACrB,IAAG,IAAI,CAAC,MAAM,IAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAC;gBAChC,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,IAAI,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;oBAC1B,KAAK,IAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;iBAClC;aACH;YACG,OAAO,KAAK,GAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SACrD;QACD,IAAG,IAAI,YAAY,MAAM,EAAC;YACtB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACzB;IACL,CAAC;IACL,aAAC;AAAD,CAAC,AA5HD,IA4HC;AACO,wBAAM"} \ No newline at end of file +{"version":3,"file":"vector.js","sourceRoot":"","sources":["../../statistics/vector.ts"],"names":[],"mappings":";;AAAA;IAEI;;;OAGG;IACH,gBAAY,EAAuB;YAAtB,kBAAO;QAChB,IAAI,CAAC,IAAI,GAAE,IAAI,CAAC;IACpB,CAAC;IACD;;;;OAIG;IACH,oBAAG,GAAH,UAAI,IAAW;QACX,IAAI,OAAO,GAAe,EAAE,CAAC;QAC7B,IAAG,IAAI,YAAY,MAAM,IAAG,IAAI,CAAC,IAAI,CAAC,MAAM,IAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAC;YAC3D,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,C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AI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SAC7B;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IACD;;;;OAIG;IACH,sBAAK,GAAL,UAAM,IAAyB;QAC3B,IAAG,IAAI,YAAY,KAAK,EAAC;YACrB,IAAI,KAAK,GAAS,CAAC,CAAC;YACrB,IAAG,IAAI,CAAC,MAAM,IAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAC;gBAChC,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,IAAI,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;oBAC1B,KAAK,IAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;iBAClC;aACH;YACG,OAAO,KAAK,GAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SACrD;QACD,IAAG,IAAI,YAAY,MAAM,EAAC;YACtB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACzB;IACL,CAAC;IACL,aAAC;AAAD,CAAC,AA5HD,IA4HC;AACO,wBAAM"} \ No newline at end of file diff --git a/dist/statistics/weigth_variance.js b/dist/statistics/weigth_variance.js new file mode 100644 index 0000000..6d2c299 --- /dev/null +++ b/dist/statistics/weigth_variance.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * 加权平均数 + */ +var weigthVariance = /** @class */ (function () { + /** + * 计算加权平均数 + * @param {Array} numberData 要计算的值 + * @param {Array} weigth 权值 + */ + function weigthVariance(_a, _b) { + var numberData = _a.slice(0); + var weigth = _b.slice(0); + var totalWigth = 0, totaNumber = 0; + if (numberData.length == weigth.length) { + for (var i = 0; i <= numberData.length; i++) { + totalWigth += weigth[i]; + totaNumber += numberData[i] * weigth[i]; + } + } + else { + throw Error("权重值和数据不匹配!"); + } + return totaNumber / totalWigth; + } + return weigthVariance; +}()); +exports.weigthVariance = weigthVariance; +//# sourceMappingURL=weigth_variance.js.map \ No newline at end of file diff --git a/dist/statistics/weigth_variance.js.map b/dist/statistics/weigth_variance.js.map new file mode 100644 index 0000000..b216045 --- /dev/null +++ b/dist/statistics/weigth_variance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"weigth_variance.js","sourceRoot":"","sources":["../../statistics/weigth_variance.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH;IACI;;;;OAIG;IACH,wBAAY,EAAiC,EAAG,EAA6B;YAAhE,wBAAa;YAAuB,oBAAS;QACzD,IAAI,UAAU,GAAQ,CAAC,EAAC,UAAU,GAAQ,CAAC,CAAC;QACzC,IAAI,UAAU,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACvC,KAAI,IAAI,CAAC,GAAS,CAAC,EAAC,CAAC,IAAE,UAAU,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;gBAC5C,UAAU,IAAE,MAAM,CAAC,CAAC,CAAC,CAAC;gBACtB,UAAU,IAAE,UAAU,CAAC,CAAC,CAAC,GAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aACpC;SACD;aAAI;YACJ,MAAM,KAAK,CAAC,YAAY,CAAC,CAAC;SAC1B;QACD,OAAO,UAAU,GAAC,UAAU,CAAC;IACjC,CAAC;IACL,qBAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,wCAAc"} \ No newline at end of file diff --git a/package.json b/package.json index a18d8a7..855551c 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "test": "test" }, "scripts": { + "build":"tsc --build tsconfig.json", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/statistics/Gaussian_distribution.ts b/statistics/Gaussian_distribution.ts index 1687a20..12fc3b1 100644 --- a/statistics/Gaussian_distribution.ts +++ b/statistics/Gaussian_distribution.ts @@ -1,6 +1,6 @@ -import {Gaussiandistribution as GD} from "./Gaussian-distribution"; +import {Gaussiandistribution as GD} from "./Gaussian_distribution"; import {Variance as Vc} from "./Variance"; -import {StandardDeviation as SD} from "./Standard-Deviation"; +import {StandardDeviation as SD} from "./Standard_Deviation"; /** * 高斯正态分布 */ diff --git a/statistics/LeastSquare.ts b/statistics/LeastSquare.ts index 7096796..f86e500 100644 --- a/statistics/LeastSquare.ts +++ b/statistics/LeastSquare.ts @@ -14,10 +14,10 @@ function LeastSquare([...a]:Array,[...b]:Array,n:number):Array=[]; if(a.length!=b.length){ throw TypeError("两个数组数据不符合") } - let total_1:number,total_2:number,_a_:number,_b_:number,y_:number,temp:Array; for(let i=0;i} ...num [description] */ - total:number; + total:number=0; constructor([...num]:Array){ for(let i=0;i0){ - for(let m=1;m<=n;m+=0.1**String(k).length-2){ - //广义的求阶乘未实现 - total*=m; - } - }*/ for(let i=1;i<=n;i++){ total*=i; } return total; } -} export {Factorial} \ No newline at end of file diff --git a/statistics/harmonic.ts b/statistics/harmonic.ts new file mode 100644 index 0000000..201c6ff --- /dev/null +++ b/statistics/harmonic.ts @@ -0,0 +1,13 @@ +/** + * [Harmonic 调和数] + * @param {number} n [description] + * @return {number} [description] + */ +function Harmonic(n:number):number{ + var total=0; + for(let i:number=1;i<=n;i++){ + total+=(1/i); + } + return total; +} +export {Harmonic}; \ No newline at end of file diff --git a/statistics/index.ts b/statistics/index.ts index 8f5ddd9..646d7fb 100644 --- a/statistics/index.ts +++ b/statistics/index.ts @@ -13,7 +13,8 @@ import {Vector} from "./vector"; import {sigmoid} from "./sigmoid"; import {Rank} from "./rank"; import {Tensor} from "./tensor"; -import {LeastSquare} "./LeastSquare"; +import {LeastSquare} from "./LeastSquare"; import {gcd} from "./gcd"; +import {Harmonic as Har} from "./harmonic" //导出多个模块 -export {GD,Vc,SD,bayes,Mean,Median,Permu,fator,Matrix,QuanPlot,WeiVar,Vector,sigmoid,Tensor,LeastSquare,gcd}; \ No newline at end of file +export {GD,Vc,SD,Har,bayes,Rank,Mean,Median,Permu,fator,Matrix,QuanPlot,WeiVar,Vector,sigmoid,Tensor,LeastSquare,gcd}; \ No newline at end of file diff --git a/statistics/powerFactorial.ts b/statistics/powerFactorial.ts new file mode 100644 index 0000000..06aa965 --- /dev/null +++ b/statistics/powerFactorial.ts @@ -0,0 +1,6 @@ +import {Factorial as Fac} from "./Factorial" +function powerFactorial(x:number,n:number):number{ + + return Fac(x+n-1)/Fac(x-1); +} +export {powerFactorial}; \ No newline at end of file diff --git a/statistics/product.ts b/statistics/product.ts index e8262f4..7b73a2a 100644 --- a/statistics/product.ts +++ b/statistics/product.ts @@ -1,6 +1,6 @@ class product{ - total:number; - ary:number[]; + total:number=0; + ary:Array=[]; /** * 初始化一个product对象 * @param {Array} ...index [数据:数组] diff --git a/statistics/sigmoid.ts b/statistics/sigmoid.ts index b0e949b..deb40e3 100644 --- a/statistics/sigmoid.ts +++ b/statistics/sigmoid.ts @@ -6,4 +6,4 @@ function sigmoid(x:number):number{ return 1/(1+Math.E**(-x)); } -export default sigmoid; \ No newline at end of file +export {sigmoid}; \ No newline at end of file diff --git a/statistics/subFactorial.ts b/statistics/subFactorial.ts new file mode 100644 index 0000000..3feda88 --- /dev/null +++ b/statistics/subFactorial.ts @@ -0,0 +1,5 @@ +import {Factorial as Fac} from "./Factorial" +function subFactorial(x:number,n:number):number{ + return Fac(x)/Fac(x-n); +} +export {subFactorial} \ No newline at end of file diff --git a/statistics/tree.ts b/statistics/tree.ts index d237d33..8315a0b 100644 --- a/statistics/tree.ts +++ b/statistics/tree.ts @@ -4,9 +4,5 @@ interface TNode{ child:any; } class Tree{ - constructor(){ - let Root:TNode; - Root.parent = null; - - } + } \ No newline at end of file