Git Product home page Git Product logo

nelder-mead-r's Introduction

Nelder-Mead simplex optimization method in R

The code in R for Nelder–Mead simplex method to find the minimum of an objective function in a multidimensional space
Read more about Nelder-Mead method: https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method

Instructions

The function optim.NM returns the minimum of a multidimensional objective function:

optim.NM(objective.fn, params.init, iter.max, abs.tol)

with the standard inputs for European and American options:

  • objective.fn: objective function to be minimized
  • params.init: initial guess for parameters of the function, a vector of zero's can be provided
  • iter.max: maximum iterations fo the search
  • abs.tol: tolerated precision of the objective function value when the search can be stopped

Examples

The Rosenbrock function with a=1, b=100 has the global minimum at X=(a, a^2).
https://en.wikipedia.org/wiki/Rosenbrock_function

obj.fn.rosenbrock <- function(X)
{
  a <- 1
  b <- 100
  d <- length(X)
  Xi <- X[1:(d-1)]
  Xnext <- X[2:d]
  y <- sum(b*(Xnext-Xi^2)^2 + (Xi-a)^2)
  return(y)
}
optim.NM(udf.rosenbrock, c(0, 0), 1000, 10^-9)
$par
[1] 0.9999877 0.9999738

$value
[1] 3.957329e-10
optim.NM(obj.fn.rosenbrock, c(0, 0, 0), 1000, 10^-9)
$par
[1] 1.000004 1.000007 1.000015

$value
[1] 3.165469e-10

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.