필터 지우기
필터 지우기

Problem in creating symbolic function with normcdf

조회 수: 2 (최근 30일)
geeks
geeks 2012년 3월 18일
Hi everyone,
I have a problem when creating a symbolic function with normcdf. I read some related postings and guess that might be the case that 'less than equal to' is not defined in 'syms'. Ultimately, I need to use this symbolic function to get the Hessian matrix. Can anyone please give me some idea on how to solve this problem? Thanks very much!
Here is my code:
syms mu sigma lembda eta
f2 = -(-N_M*log(eta+lembda*(1-normcdf(log(M_minw),mu,sigma)))+N_M*log(lembda)+Nu_M*log(1-normcdf(log(M_minw),mu,sigma))+Nu_M*log(eta)-Ne_M*log((sqrt(2*pi)*sigma))-sum(log(M(n,2)))-sum((log(M(n,2))-ones(n,1)*mu).^2/(2*sigma^2))-lembda*(1-normcdf(log(M_minw),mu,sigma))*sum(M(n(end)+1:end,1)));
This is the error msg:
??? Error using ==> sym.sym>notimplemented at 2514
Function 'le' is not implemented for MuPAD symbolic objects.
Error in ==> sym.sym>sym.le at 825
notimplemented('le');
Error in ==> normcdf at 57
sigma(sigma <= 0) = NaN;
Thanks!
Sonia

채택된 답변

Alexander
Alexander 2012년 3월 19일
It seems that normcdf is not defined for sym objects. You can try to express normcdf for syms in a more elementary way, like this:
normcdfsym = @(x, mu, sigma)(1/2 - erf((2^(1/2)*(mu - x))/(2*(sigma^2)^(1/2)))/2)
With this your formular would look like this:
f2 = -(-N_M*log(eta+lembda*(1-normcdfsym(log(M_minw),mu,sigma)))+N_M*log(lembda)+Nu_M*log(1-normcdfsym(log(M_minw),mu,sigma))+Nu_M*log(eta)-Ne_M*log((sqrt(2*pi)*sigma))-sum(log(M(n,2)))-sum((log(M(n,2))-ones(n,1)*mu).^2/(2*sigma^2))-lembda*(1-normcdfsym(log(M_minw),mu,sigma))*sum(M(n(end)+1:end,1)));
However there are still some undefined variables, like N_M or M.
  댓글 수: 1
geeks
geeks 2012년 3월 19일
Thank you so much, Alexander! It works:) The code I posted is only a fraction of the whole program. I have N_M and M defined at the very beginning. Thanks a lot!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by