Incorrect output when working with estimating normal random variables. #842
-
|
Hello again, I know this is so soon after my last post, but, now, I'm facing yet another issue. It isn't with the code itself but rather the output. From my previous post, I am trying to find the parameters for mu, the mean, and sigma, the standard deviation, using the log-likelihood to find whether those parameters are the correct ones. Since the random variable I am working with is normal, therefore This is because we are trying to maximize the probability of each Z(i) entry. One can compute the first and second derivatives as .I have implemented all of the following equations for the gradient of f and the Hessian functions; however, not only do the results remain the same after every execution, which should not occur due to the random device I am using(seen in function.cpp), but the result is nowhere close to the answer. Possible solutions I have tried to come up with rely on changing the mu_strategy and adaptive settings. However, even after I change it from adaptive to monotone, I still get an incorrect answer. Even when I initialize it with the answer as the starting points, it diverges from this answer when adaptive is chosen. On the other hand, if I were to change it to monotone, it doesn't even reach the answer and stays relatively close to the initialized points. To add one more point, it seems that in all cases, my first variable is not moved at all, regardless of what setting I choose. When monotone is selected and the initial points are the answer of OU_optim_cpp.txt |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
|
Even when I input Z=[5,5,5...,5,5] it does not even update mu variable, the first variable, and the standard deviation, the second variable, stays high when it should be 0. |
Beta Was this translation helpful? Give feedback.
-
|
In your If you remove these, it becomes more interesting: This is with Hessian approximation, because there seems to be a mistake in you Hessian implementation: |
Beta Was this translation helpful? Give feedback.
-
|
Thank you once again. Overwriting the variable Z was the issue, and changing it solved this. How do I begin fixing my Hessian implementation? Is it a problem with the code I wrote, since it uses a for loop, or is it due to other settings I would need to change? After some testing, I found that when I reduce the size of Z, no issues appear during my optimization; however, when it exceeds 1000 in length, the optimization fails. I am guessing this is where my improper Hessian implementation comes into play. |
Beta Was this translation helpful? Give feedback.
Turn on the Hessian check in Ipopt ($$\frac{\partial^2 f}{\partial \mu^2}$$ :
derivative_test second-order) and check your formulas. The errors reported by Ipopt should be small or vanish.One thing is that you missed multiplying by
obj_factor, but also after fixing that, there seems to be still an issue with