필터 지우기
필터 지우기

Fitting probability distributions to the data (allfitdist)

조회 수: 31 (최근 30일)
Sepp
Sepp 2016년 3월 3일
댓글: Kacper PLUTA 2017년 3월 5일
Hello
I have found the amazing script allfitdist which fits all valid parametric distributions to the data and sorts them using a metric (e.g. BIC or AIC). In a blog post there is a example for a normal distribution:
% Create a normally distributed (mu: 5, sigma: 3) random data set
x = normrnd(5, 3, 1e4, 1);
% Compute and plot results. The results are sorted by "Bayesian information
% criterion".
[D, PD] = allfitdist(x, 'PDF');
If I do this, I'm getting the Rayleigh as winning distribution. In the blog post they got the normal distribution (as expected). The plot I'm getting is in the attachment.
Does somebody see from where this problem comes? I have the newest version of Matlab. Is this the problem?
  댓글 수: 1
Kacper PLUTA
Kacper PLUTA 2017년 3월 5일
I had the same problem and I swiched from 2016b to 2012b. Well, in 2012b the code gives results which seem to be OK.

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

채택된 답변

Ahmet Cecen
Ahmet Cecen 2016년 3월 3일
It is probably a result of changes in default behavior across MATLAB versions. You are getting that, because the log likelihood value for Raleigh Distribution returns a complex number, which shouldn't happen. You can go to line 212 to and append this there:
if ~isreal(NLL)
error('non-finite NLL');
end
Now the program will catch the complex log likelihood and disregard the distribution like it should.
  댓글 수: 7
Ahmet Cecen
Ahmet Cecen 2016년 3월 5일
No, here is a modified version that uses the same data to get the same results using two different notation:
% Example 2
data = nbinrnd(20,.3,1e4,1);
values=unique(data); freq=histc(data,values);
[D PD] = allfitdist(values,'NLogL','frequency',freq,'PDF','DISCRETE'); <-- Counts and Frequency
% Example 3
[D PD] = allfitdist(data,'NLogL','PDF','DISCRETE'); <-- Data
Sepp
Sepp 2016년 3월 6일
편집: Sepp 2016년 3월 6일
Thank you again. I have just encountered the following warning message: Maximum likelihood estimation did not converge. Iteration limit exceeded. This appeared e.g. for tlocationscale. Of course such a fit is bad. How can I exclude this? I mean if this warning appears, I just want to throw an error.
Second, currently, I'm investigating if the neagtive log likelihood is complex or infinite and if so, I'm throwing an error. Are there other checks which I should do?

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by