Code Monkey home page Code Monkey logo

lm's Introduction

lm

Package lm solves non-linear least squares problems using the Levenberg-Marquardt method.

Example

  • Define a function:
func biggsEXP6Func(dst, x []float64) {
	for i := 0; i < 13; i++ {
		z := float64(i) / 10
		y := math.Exp(-z) - 5*math.Exp(-10*z) + 3*math.Exp(-4*z)
		dst[i] = x[2]*math.Exp(-x[0]*z) - x[3]*math.Exp(-x[1]*z) + x[5]*math.Exp(-x[4]*z) - y
	}
}
  • Define the jacobian. In this case the jacobian will be evaluated by finite differences:
biggsNumJac := lm.NumJac{Func: biggsEXP6Func}
  • Call the solver:
biggsProb := lm.LMProblem{
	Dim:        6,
 	Size:       13,
 	Func:       biggsEXP6Func,
 	Jac:        biggsNumJac.Jac,
 	InitParams: []float64{1, 2, 1, 1, 1, 1},
 	Tau:        1e-6,
 	Eps1:       1e-8,
 	Eps2:       1e-8,
}
biggsResults, biggsErr := lm.LM(biggsProb, &lm.Settings{Iterations: 100, ObjectiveTol: 1e-16})
fmt.Println(biggsResults)
fmt.Println(biggsErr)

References

  • Madsen, Kaj, Hans Bruun Nielsen, and Ole Tingleff. "Methods for non-linear least squares problems.", 2nd edition, 2004.
  • Lourakis, Manolis. "A Brief Description of the Levenberg-Marquardt Algorithm Implemened by levmar", 2005.

lm's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.