"Fminunc cannot continue" Error with gamma function

1 回表示 (過去 30 日間)
Yasin Simsek
Yasin Simsek 2019 年 8 月 21 日
コメント済み: Yasin Simsek 2019 年 8 月 21 日
I am trying to minimize minus likelihood function for the ML estimation. I get the following error: "Objective function is undefined at initial point. Fminunc cannot continue."
Part of my code is that,
likelihoods(i) = - R2(i)/(2*K(i)*sigma^2) - (v0 + v1*K(i)) + V(i)*log(v0 + v1*K(i))/c - ...
log(2*K(i)*sigma^2)/2 - log(gamma(V(i)/c + 1));
The problem is coming from the part " gamma(..) " because it is about factorials and the array V contains bigger numbers matlab compute it as infinity. So it gave me above error. I deal with this difficulty by scaling the array V by 10^-9. Is there any way to handle with this trouble?

採用された回答

David Goodmanson
David Goodmanson 2019 年 8 月 21 日
Hi Yasin,
You can use the gammaln function which is tailor made for this situation.
  1 件のコメント
Yasin Simsek
Yasin Simsek 2019 年 8 月 21 日
thanks a lot David!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGlobal Optimization Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by