ml-levenberg-marquardt
Advanced tools
Comparing version 4.1.1 to 4.1.2
@@ -16,3 +16,3 @@ /** | ||
}, evaluatedData: ArrayLike<number>, params: Array<number>, gradientDifference: number | any[], paramFunction: Function, centralDifference: boolean): Matrix; | ||
import { Matrix } from "ml-matrix"; | ||
import { Matrix } from 'ml-matrix'; | ||
//# sourceMappingURL=gradientFunction.d.ts.map |
@@ -5,3 +5,4 @@ /** | ||
* @param {function} parameterizedFunction - Takes an array of parameters and returns a function with the independent variable as its sole argument | ||
* @param {object} [options] - Options object | ||
* @param {object} options - Options object | ||
* @param {ArrayLike<number>} options.initialValues - Array of initial parameter values | ||
* @param {number|ArrayLike<number>} [options.weights = 1] - weighting vector, if the length does not match with the number of data points, the vector is reconstructed with first value. | ||
@@ -17,3 +18,2 @@ * @param {number} [options.damping = 1e-2] - Levenberg-Marquardt parameter, small values of the damping parameter λ result in a Gauss-Newton update and large | ||
* @param {ArrayLike<number>} [options.maxValues] - Maximum allowed values for parameters | ||
* @param {ArrayLike<number>} [options.initialValues] - Array of initial parameter values | ||
* @param {number} [options.maxIterations = 100] - Maximum of allowed iterations | ||
@@ -27,3 +27,4 @@ * @param {number} [options.errorTolerance = 10e-3] - Minimum uncertainty allowed for each point. | ||
y: ArrayLike<number>; | ||
}, parameterizedFunction: Function, options?: { | ||
}, parameterizedFunction: Function, options: { | ||
initialValues: ArrayLike<number>; | ||
weights?: number | ArrayLike<number> | undefined; | ||
@@ -38,7 +39,6 @@ damping?: number | undefined; | ||
maxValues?: ArrayLike<number> | undefined; | ||
initialValues?: ArrayLike<number> | undefined; | ||
maxIterations?: number | undefined; | ||
errorTolerance?: number | undefined; | ||
timeout?: number | undefined; | ||
} | undefined): { | ||
}): { | ||
parameterValues: Array<number>; | ||
@@ -45,0 +45,0 @@ parameterError: number; |
@@ -8,3 +8,4 @@ import checkOptions from './checkOptions'; | ||
* @param {function} parameterizedFunction - Takes an array of parameters and returns a function with the independent variable as its sole argument | ||
* @param {object} [options] - Options object | ||
* @param {object} options - Options object | ||
* @param {ArrayLike<number>} options.initialValues - Array of initial parameter values | ||
* @param {number|ArrayLike<number>} [options.weights = 1] - weighting vector, if the length does not match with the number of data points, the vector is reconstructed with first value. | ||
@@ -20,3 +21,2 @@ * @param {number} [options.damping = 1e-2] - Levenberg-Marquardt parameter, small values of the damping parameter λ result in a Gauss-Newton update and large | ||
* @param {ArrayLike<number>} [options.maxValues] - Maximum allowed values for parameters | ||
* @param {ArrayLike<number>} [options.initialValues] - Array of initial parameter values | ||
* @param {number} [options.maxIterations = 100] - Maximum of allowed iterations | ||
@@ -27,3 +27,3 @@ * @param {number} [options.errorTolerance = 10e-3] - Minimum uncertainty allowed for each point. | ||
*/ | ||
export function levenbergMarquardt(data, parameterizedFunction, options = {}) { | ||
export function levenbergMarquardt(data, parameterizedFunction, options) { | ||
let { checkTimeout, minValues, maxValues, parameters, weightSquare, damping, dampingStepUp, dampingStepDown, maxIterations, errorTolerance, centralDifference, gradientDifference, improvementThreshold, } = checkOptions(data, parameterizedFunction, options); | ||
@@ -30,0 +30,0 @@ let error = errorCalculation(data, parameters, parameterizedFunction, weightSquare); |
@@ -18,3 +18,3 @@ /** | ||
}; | ||
import { Matrix } from "ml-matrix"; | ||
import { Matrix } from 'ml-matrix'; | ||
//# sourceMappingURL=step.d.ts.map |
@@ -16,3 +16,3 @@ /** | ||
}, evaluatedData: ArrayLike<number>, params: Array<number>, gradientDifference: number | any[], paramFunction: Function, centralDifference: boolean): Matrix; | ||
import { Matrix } from "ml-matrix"; | ||
import { Matrix } from 'ml-matrix'; | ||
//# sourceMappingURL=gradientFunction.d.ts.map |
@@ -5,3 +5,4 @@ /** | ||
* @param {function} parameterizedFunction - Takes an array of parameters and returns a function with the independent variable as its sole argument | ||
* @param {object} [options] - Options object | ||
* @param {object} options - Options object | ||
* @param {ArrayLike<number>} options.initialValues - Array of initial parameter values | ||
* @param {number|ArrayLike<number>} [options.weights = 1] - weighting vector, if the length does not match with the number of data points, the vector is reconstructed with first value. | ||
@@ -17,3 +18,2 @@ * @param {number} [options.damping = 1e-2] - Levenberg-Marquardt parameter, small values of the damping parameter λ result in a Gauss-Newton update and large | ||
* @param {ArrayLike<number>} [options.maxValues] - Maximum allowed values for parameters | ||
* @param {ArrayLike<number>} [options.initialValues] - Array of initial parameter values | ||
* @param {number} [options.maxIterations = 100] - Maximum of allowed iterations | ||
@@ -27,3 +27,4 @@ * @param {number} [options.errorTolerance = 10e-3] - Minimum uncertainty allowed for each point. | ||
y: ArrayLike<number>; | ||
}, parameterizedFunction: Function, options?: { | ||
}, parameterizedFunction: Function, options: { | ||
initialValues: ArrayLike<number>; | ||
weights?: number | ArrayLike<number> | undefined; | ||
@@ -38,7 +39,6 @@ damping?: number | undefined; | ||
maxValues?: ArrayLike<number> | undefined; | ||
initialValues?: ArrayLike<number> | undefined; | ||
maxIterations?: number | undefined; | ||
errorTolerance?: number | undefined; | ||
timeout?: number | undefined; | ||
} | undefined): { | ||
}): { | ||
parameterValues: Array<number>; | ||
@@ -45,0 +45,0 @@ parameterError: number; |
@@ -14,3 +14,4 @@ "use strict"; | ||
* @param {function} parameterizedFunction - Takes an array of parameters and returns a function with the independent variable as its sole argument | ||
* @param {object} [options] - Options object | ||
* @param {object} options - Options object | ||
* @param {ArrayLike<number>} options.initialValues - Array of initial parameter values | ||
* @param {number|ArrayLike<number>} [options.weights = 1] - weighting vector, if the length does not match with the number of data points, the vector is reconstructed with first value. | ||
@@ -26,3 +27,2 @@ * @param {number} [options.damping = 1e-2] - Levenberg-Marquardt parameter, small values of the damping parameter λ result in a Gauss-Newton update and large | ||
* @param {ArrayLike<number>} [options.maxValues] - Maximum allowed values for parameters | ||
* @param {ArrayLike<number>} [options.initialValues] - Array of initial parameter values | ||
* @param {number} [options.maxIterations = 100] - Maximum of allowed iterations | ||
@@ -33,3 +33,3 @@ * @param {number} [options.errorTolerance = 10e-3] - Minimum uncertainty allowed for each point. | ||
*/ | ||
function levenbergMarquardt(data, parameterizedFunction, options = {}) { | ||
function levenbergMarquardt(data, parameterizedFunction, options) { | ||
let { checkTimeout, minValues, maxValues, parameters, weightSquare, damping, dampingStepUp, dampingStepDown, maxIterations, errorTolerance, centralDifference, gradientDifference, improvementThreshold, } = (0, checkOptions_1.default)(data, parameterizedFunction, options); | ||
@@ -36,0 +36,0 @@ let error = (0, errorCalculation_1.default)(data, parameters, parameterizedFunction, weightSquare); |
@@ -18,3 +18,3 @@ /** | ||
}; | ||
import { Matrix } from "ml-matrix"; | ||
import { Matrix } from 'ml-matrix'; | ||
//# sourceMappingURL=step.d.ts.map |
{ | ||
"name": "ml-levenberg-marquardt", | ||
"version": "4.1.1", | ||
"version": "4.1.2", | ||
"description": "Curve fitting method in javascript", | ||
@@ -14,3 +14,2 @@ "main": "./lib/index.js", | ||
"scripts": { | ||
"build": "cheminfo-build", | ||
"check-types": "tsc --noEmit", | ||
@@ -49,18 +48,17 @@ "clean": "rimraf lib lib-esm", | ||
"devDependencies": { | ||
"@types/jest": "^27.4.1", | ||
"@types/jest": "^29.5.0", | ||
"benchmark": "^2.1.4", | ||
"cheminfo-build": "^1.1.11", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^8.10.0", | ||
"eslint-config-cheminfo-typescript": "^10.3.0", | ||
"jest": "^27.5.1", | ||
"eslint": "^8.38.0", | ||
"eslint-config-cheminfo-typescript": "^11.3.1", | ||
"jest": "^29.5.0", | ||
"jest-matcher-deep-close-to": "^3.0.2", | ||
"prettier": "^2.5.1", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^27.1.3", | ||
"typescript": "^4.5.5" | ||
"prettier": "^2.8.7", | ||
"rimraf": "^5.0.0", | ||
"ts-jest": "^29.1.0", | ||
"typescript": "^5.0.4" | ||
}, | ||
"dependencies": { | ||
"is-any-array": "^2.0.0", | ||
"ml-matrix": "^6.9.0" | ||
"ml-matrix": "^6.10.4" | ||
}, | ||
@@ -67,0 +65,0 @@ "config": { |
@@ -1,2 +0,1 @@ | ||
/* eslint-disable jest/no-standalone-expect */ | ||
import { toBeDeepCloseTo, toMatchCloseTo } from 'jest-matcher-deep-close-to'; | ||
@@ -128,2 +127,8 @@ | ||
testInvocation(`Should fit ${problem.name}`, () => { | ||
/** @type {any} */ | ||
const params = { | ||
decimalsForParameterError: 2, | ||
decimalsForParameterValues: 3, | ||
...problem, | ||
}; | ||
const { | ||
@@ -138,9 +143,3 @@ getFunctionFromParameters, | ||
decimalsForParameterValues, | ||
} = Object.assign( | ||
{ | ||
decimalsForParameterError: 2, | ||
decimalsForParameterValues: 3, | ||
}, | ||
problem, | ||
); | ||
} = params; | ||
const xs = new Array(n) | ||
@@ -242,8 +241,6 @@ .fill(0) | ||
const { data, expected, getFunctionFromParameters, options, decimals } = | ||
Object.assign( | ||
{ | ||
decimals: 3, | ||
}, | ||
problem, | ||
); | ||
{ | ||
decimals: 3, | ||
...problem, | ||
}; | ||
const actual = levenbergMarquardt( | ||
@@ -250,0 +247,0 @@ data, |
@@ -25,5 +25,5 @@ import { toBeDeepCloseTo } from 'jest-matcher-deep-close-to'; | ||
expect(() => | ||
// @ts-expect-error | ||
levenbergMarquardt(inputData, sinFunction, { | ||
damping: 0.1, | ||
//initialValues: undefined, | ||
}), | ||
@@ -30,0 +30,0 @@ ).toThrow(expectedErrorMessage); |
@@ -9,3 +9,4 @@ import checkOptions from './checkOptions'; | ||
* @param {function} parameterizedFunction - Takes an array of parameters and returns a function with the independent variable as its sole argument | ||
* @param {object} [options] - Options object | ||
* @param {object} options - Options object | ||
* @param {ArrayLike<number>} options.initialValues - Array of initial parameter values | ||
* @param {number|ArrayLike<number>} [options.weights = 1] - weighting vector, if the length does not match with the number of data points, the vector is reconstructed with first value. | ||
@@ -21,3 +22,2 @@ * @param {number} [options.damping = 1e-2] - Levenberg-Marquardt parameter, small values of the damping parameter λ result in a Gauss-Newton update and large | ||
* @param {ArrayLike<number>} [options.maxValues] - Maximum allowed values for parameters | ||
* @param {ArrayLike<number>} [options.initialValues] - Array of initial parameter values | ||
* @param {number} [options.maxIterations = 100] - Maximum of allowed iterations | ||
@@ -28,3 +28,3 @@ * @param {number} [options.errorTolerance = 10e-3] - Minimum uncertainty allowed for each point. | ||
*/ | ||
export function levenbergMarquardt(data, parameterizedFunction, options = {}) { | ||
export function levenbergMarquardt(data, parameterizedFunction, options) { | ||
let { | ||
@@ -31,0 +31,0 @@ checkTimeout, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94050
11
1534
Updatedml-matrix@^6.10.4