0

I am trying to fit a wind data set v=v1,.....,vm using a two component mixture weibull distribution.

I found a paper suggesting to use the Maximum Likelihood method and in particular to maximize the following equation:

equation to maximize

Omega, a1, a2, b1 and b2 are the parameters I want to change in order to maximize the function and v=v1,.....,vm is a series of known wind speeds.

I have been trying to use the SciPy minimization algorithm but without success.

Here is what I have so far:

def minimizer_function(v,omega,a1,b1,a2,b2):
   return np.reciprocal(np.sum((omega*(a1/b1)*((v/b1)**(a1-1))*(np.exp(-((v/b1)**a1)))+(1-omega)*(a2/b2)*((v/b2)**(a2-1))*(np.exp(-((v/b2)**a2))))))

x0 = np.array([0.5,1.0,1.0,1.0,1.0])
res = optimization.minimize(minimizer_function, x0, method='nelder-mead',options={'xtol': 1e-8, 'disp': True})

However I keep on getting the following error:

minimizer_function() missing 5 required positional arguments: 'omega', 'a1', 'b1', 'a2', and 'b2'

I am pretty sure I am missing something.

1 Answer 1

1

The scipy minimizers expect the variables to be stored in a single one-dimensional array. In your case, the objective function should be something like minimizer_function(x, v), where x is an array of five elements containing omega, a1, b1, a2 and b2. That is, something like

def minimizer_function(x, v):
   omega, a1, b1, a2, b2 = x
   return np.reciprocal(np.sum((omega*(a1/b1)*((v/b1)**(a1-1))*(np.exp(-((v/b1)**a1)))+(1-omega)*(a2/b2)*((v/b2)**(a2-1))*(np.exp(-((v/b2)**a2))))))

The call to minimize would be something like

x0 = np.array([0.5,1.0,1.0,1.0,1.0])
res = optimization.minimize(minimizer_function, x0, args=(v,), method='nelder-mead',options={'xtol': 1e-8, 'disp': True})
Sign up to request clarification or add additional context in comments.

2 Comments

Hi Warren, thank you very much for looking into this. It runs now, the values look very strange but I am probably still missing something
Any suggestion on how to maximize the function? At present I am minimizing the reciprocal of the abs of the function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.