# Explain how Nelder-Mead algorithm can be implemented using SciPy Python?

SciPy library can be used to perform complex scientific computations at speed, with high efficiency. Nelder-Mead algorithm is also known as simple search algorithm.

It is considered to be one of the best algorithms that can be used to solve parameter estimation problems, and statistical problems. Relevant to use this algorithm in situations where the values of functions are uncertain or have lots of noise associated with it.

This algorithm can also be used to work with discontinuous functions which occur frequently in statistics. It is a simple algorithm and it is easy to understand as well. Used to minimize the parameters of a non-linear function in case of a multidimensional unconstrained optimization.

It is not suggested to use this algorithm to find the optimal gradient values because it may take long periods of time.

Let us see an example −

## Example

import numpy as np
from scipy.optimize import minimize
def f(x):
return .6*(1 - x[0])**2
scipy.optimize.minimize(f, [2, -1], method="Nelder-Mead")

## Output

final_simplex: (array([[ 1. , -1.27109375],
[ 1. , -1.27118835],
[ 1. , -1.27113762]]), array([0., 0., 0.]))
fun: 0.0
message: 'Optimization terminated successfully.'
nfev: 147
nit: 69
status: 0
success: True
x: array([ 1. , -1.27109375])

## Explanation

• The required libraries are imported.

• A function ‘f’ is defined that takes a value as argument, and performs some mathematical computations on it.

• This function is called outside the function definition to the ‘f’ function that computes the value.

• This function is passed as a parameter to the ‘minimize’ function present in ‘optimize’ class of ‘scipy’ library.

• This output is displayed on the console.