fminbound and pandas dataframe
Closed this issue · 4 comments
Hello,
I am going to compare a situation in which we didn’t have any problem with the situation in which we have problems.
In the no-problems situation we minimize x of the z(x,t,m,R) function for a range of m values that go from 0.5 to 1.5. We use optimize.minimize ; everything works fine and range_x.shape = (11,1). Hence, the values of x and m can be stored in a pandas dataframe (attached below).
In the problem situation we minimize x of the g(x,t,m,R) function that is the same as previous z(x,t,m,R) for a range of t values that go from 0 to 1. We cannot use optimize.minimize anymore since the initial guess of x = 0.7 it would only be valid when t= 0.7 but since t and x are similar values when t is not 0.7 then x=0.7 is not a good initial guess anymore. Instead, we use optimize.fminbound, since it does not require us to make an initial guess. Here range_x.shape = (11,) (in the no-problem situation was (11,1)) and it does not let us store the values of x and t in the pandas dataframe. According to the errors, it appears to have a dimensional problem; optimize.fminbound only considers 1, but the dataframe needs 2 (attached below).
How can it be solved?
Thanks
Mariona
Your function g
has terms which divide by range_t
does include 0 and 1. I would start by redefining range_t
to exclude these values.
Does that help?
Jan.
"now the range_x = (9,) and it should be (9,1)": I am not sure I understand why you want range_x
to be two dimensional. In the definition of the dataframe, just use range_x
without the [:,0]
.
Thanks!