fable 3.1.43 → 3.1.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fable",
3
- "version": "3.1.43",
3
+ "version": "3.1.44",
4
4
  "description": "A service dependency injection, configuration and logging library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
@@ -1550,17 +1550,18 @@ class FableServiceMath extends libFableServiceBase
1550
1550
  * Compute least squares regression coefficients for multivariable linear interpolation.
1551
1551
  *
1552
1552
  * @param {Array<Array<number|string>> | Array<number|string> | string} pIndependentVariableVectors - array of arrays [[x11, x12, ...], [x21, x22, ...], ...] or single array for single variable.
1553
- * @param {Array<number|string>} pDependentVariableVector - array of target values [y1, y2, ...]
1553
+ * @param {Array<number|string>|string} pDependentVariableVector - array of target values [y1, y2, ...]
1554
1554
  *
1555
1555
  * @return {Array<number|string>} - linear coefficients [b0, b1, ..., bn] where y = b0 + b1*x1 + b2*x2 + ... + bn*xn
1556
1556
  */
1557
1557
  leastSquares(pIndependentVariableVectors, pDependentVariableVector)
1558
1558
  {
1559
1559
  const tmpIndependentVariableVectors = Array.isArray(pIndependentVariableVectors) ? (Array.isArray(pIndependentVariableVectors[0]) ? this.matrixTranspose(pIndependentVariableVectors) : pIndependentVariableVectors.map(value => [value])) : [ [ pIndependentVariableVectors ] ];
1560
+ const tmpDependentVariableVector = Array.isArray(pDependentVariableVector) ? pDependentVariableVector : [ pDependentVariableVector ];
1560
1561
  if (tmpIndependentVariableVectors.length === 1)
1561
1562
  {
1562
1563
  // degenerate case: only one independent variable value, result is just a y-intercept
1563
- return [ pDependentVariableVector[0], '0.0' ];
1564
+ return [ tmpDependentVariableVector[0], '0.0' ];
1564
1565
  }
1565
1566
  // Add bias term (intercept)
1566
1567
  const tmpIndependentVariableMatrixWithBiasTerm = tmpIndependentVariableVectors.map(row => [1, ...row]);
@@ -1570,7 +1571,7 @@ class FableServiceMath extends libFableServiceBase
1570
1571
  const tmpDependentTransposeMultiplication = this.matrixMultiply(tmpIndependentTermTranpose, tmpIndependentVariableMatrixWithBiasTerm);
1571
1572
 
1572
1573
  // Compute X^T * y
1573
- const tmpIndependentTransposeMultiplication = this.matrixVectorMultiply(tmpIndependentTermTranpose, pDependentVariableVector);
1574
+ const tmpIndependentTransposeMultiplication = this.matrixVectorMultiply(tmpIndependentTermTranpose, tmpDependentVariableVector);
1574
1575
 
1575
1576
  // Solve (XtX) * beta = Xty
1576
1577
  const tmpLinearCoefficients = this.gaussianElimination(tmpDependentTransposeMultiplication, tmpIndependentTransposeMultiplication);