MATLAB Answers

Problems using `fitdist` to Rician distribution

조회 수: 8(최근 30일)
Morten Nissov
Morten Nissov 2021년 6월 8일
댓글: Jeff Miller 2021년 6월 10일
I am having some problems fitting a rician distribution to a set of positive values. Attempting to make the fit returns
>> p_hat = fitdist(data, 'Rician')
Error using prob.RicianDistribution>checkargs (line 197)
The parameter S must be a nonnegative finite numeric scalar.
Error in prob.RicianDistribution (line 101)
Error in prob.RicianDistribution.makeFitted (line 175)
pd = prob.RicianDistribution(p(1),p(2));
Error in (line 157)
pd = prob.RicianDistribution.makeFitted(p,nll,cov,x,cens,freq);
Error in fitdist>localfit (line 245)
pd = feval(fitter,x,'cens',c,'freq',f,varargin{:});
Error in fitdist (line 192)
pd = localfit(dist,fitter,x,cens,freq,args{:});
looking at the histogram the data itself looks plausibly Rician, if you ask me. At least close enough such that it should be able to fit parameters.
  댓글 수: 1
Scott MacKenzie
Scott MacKenzie 2021년 6월 8일
I have an observation, but no answer unfortunately.
If you add 1 to data then the fitdist function succeeds. There are no negative values in the sample data, so it is not clear why this works, but it does. Good luck.
load data; % your data
data = data + 1; % no error if data shifted up by 1
pd = fitdist(data, 'rician');
x_values = linspace(min(data), max(data));
y = pdf(pd,x_values);

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


Jeff Miller
Jeff Miller 2021년 6월 9일
I'm not sure why you are getting that error message, but Rician(6.5538e-05,0.11714) looks quite good:
In case you are curious, to get that, I used the following with Cupid:
ricianMatlab = makedist('Rician','s',1,'sigma',1);
ricianCupid = dMATLABc(ricianMatlab,'rr',[eps eps],[+inf +inf]);
% ans = 'Rician(6.5538e-05,0.11714)'
pdfx = ricianCupid.PDF(x);
hold on
  댓글 수: 3
Jeff Miller
Jeff Miller 2021년 6월 10일
Yes, I also got some complaints from fminsearch.
Great that your fmincon based implementation works faster, but doesn't it look like cupid finds slightly better estimates (i.e., search ending in a slightly lower min)?

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




Community Treasure Hunt

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

Start Hunting!

Translated by