Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ml-levenberg-marquardt

Package Overview
Dependencies
Maintainers
7
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-levenberg-marquardt

Curve fitting method in javascript

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19K
increased by15.95%
Maintainers
7
Weekly downloads
 
Created
Source

levenberg-marquardt

NPM version build status Test coverage David deps npm download

Curve fitting method in javascript

Installation

$ npm install ml-levenberg-marquardt

API Documentation

This algorithm is based on the article Brown, Kenneth M., and J. E. Dennis. "Derivative free analogues of the Levenberg-Marquardt and Gauss algorithms for nonlinear least squares approximation." Numerische Mathematik 18.4 (1971): 289-297.

In order to get a general idea of the problem you could also check the Wikipedia article.

Example

// import library
const LM = require('ml-levenberg-marquardt');

// function that receives the parameters and returns
// a function with the independent variable as a parameter
function sinFunction ([a, b]) {
  return (t) => (a * Math.sin(b * t));
}

// array of points to fit
let data = {
    x: [ /* x1, x2, ... */ ],
    y: [ /* y1, y2, ... */ ]
};

// array of initial parameter values
let initialValues = [ /* a, b, c, ... */ ];

const options = {
  damping: 1.5,
  initialValues: initialValues,
  gradientDifference: 10e-2,
  maxIterations: 100,
  errorTolerance: 10e-3
};

let fittedParams = LM(data, sinFunction, options);

Or test it in Runkit

License

MIT

Keywords

FAQs

Package last updated on 21 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc