NaN and Infs popping in my matrices after a few iterations of EM algorithm
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello ;
So, I'm implementing the EM algorithm in Matlab, but my matrices quickly end up contaminated by NaN and Inf values. I think it might be caused by matrix inversions, but I'm not sure it's the only reason.
Here is the code : em_algo.m http://pastebin.com/vJGqQPw7 iterates until convergence (which never happens due to my issue) and calls smoother.m http://pastebin.com/yD9Je37i at each iteration. The NaNs and Infs start popping around the ~8th iteration, usually.
I guess in there somewhere I'm doing something unholy with my matrices, but I really have no clue about what's wrong. I trust your expertise.
Thanks in advance for the help!
댓글 수: 0
답변 (3개)
José-Luis
2012년 11월 20일
It sounds like you are running into numerical stability issues. Look at the following example, that might help you understand what is happening:
val = 1;
while (val ~= Inf)
val = val / 10^-100
end
The NaN's that pop up can be a result of
0/0
댓글 수: 0
Matt J
2012년 11월 23일
편집: Matt J
2012년 11월 23일
Set a conditional breakpoint at line 45 (making it conditional on i==8 or whenever the NaNs start to pop up). When the code stops there, see whether inv(A) has sensible values.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!