maximum likelihood estimation with fminsearch

Hello, I would like to do a maximum likelihood estimation of normal function with the help of fminsearch. It is already working when I dont have any constraints for mu and sigma. I get the estimated mu, sigma and its value of the likelihood function. However, i will fix mu=0 but the resulting mu is never exactly 0 at the end. I dont understand why and in wich way i could do it better.
My code:
first_guess=[0 2];
[Mu_Sigma,Lk] = fminsearch('nlglklySACCzeroMu',first_guess,data);
MuEstimate(2) = Mu_Sigma(1);
SigmaEstimate(2) = Mu_Sigma(2);
L(2)=Lk;
---- next function
function L = nlglklySACCzeroMu(guess)
global data;
guess(1)=0;
if guess(2) < 0
L = inf;
else
l=-0.5*log(2*pi)-log(guess(2))-0.5*( data/guess(2) ).^2;
L = -sum(l);
end
I would be very glad to receive some suggestions! Julia

 採用された回答

Matt J
Matt J 2013 年 9 月 25 日
編集済み: Matt J 2013 年 9 月 25 日

0 投票

If you are fixing mu=0, your function should depend on only one unknown (sigma), not two.

4 件のコメント

Julia
Julia 2013 年 9 月 25 日
0 and 2 are the parameters to start fminsearch. They will change within every iteration.
Matt J
Matt J 2013 年 9 月 25 日
編集済み: Matt J 2013 年 9 月 25 日
You shouldn't be asking fminsearch to solve for 2 unknowns if you say that mu is fixed. mu should not be treated as an unknown at all if you already know that mu=0.
Julia
Julia 2013 年 9 月 25 日
i got it :-D I dont have to give fminsearch two startparameters! thank you!
mohanish
mohanish 2018 年 10 月 31 日
what is the code you used to find the maximum likelihood ratio?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraph and Network Algorithms についてさらに検索

質問済み:

2013 年 9 月 25 日

コメント済み:

2018 年 10 月 31 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by