Writing likelihood function for fmincon
显示 更早的评论
I need to write a likelihood function to be optimized via fmincon. The problem here is that:
1) To simplify things, my likelihood function is dependent on \alpha, \beta where \beta is specified somewhere in the code before the fmincon part. \alpha is the vector to be estimated via fmincon.
2) I plan to use fmincon in a for loop which controls the number of samples I need for the likelihood function. In other words, for n = 1, my likelihood function is simply f(x_1;\alpha,\beta) whereas for n = 3, my likelihood function now becomes f(x_1;\alpha,\beta)*f(x_2;\alpha,\beta)*f(x_3;\alpha,\beta)*f(x_4;\alpha,\beta) and so on.
Because of 1), it appears to me that it is necessary for me to write the likelihood function as fun = @(\alpha) ... because if I write a separate function file for it and call it in fmincon, I have two arguments for my likelihood function, one of which is specified earlier in the code.
Because of 2), things are tricky. Can I have a for loop in the fun = @(\alpha) definition of my likelihood function? If so, how do I do it?
Thanks!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Nonlinear Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!