Problems using `fitdist` to Rician distribution

18 views (last 30 days)
Morten Nissov
Morten Nissov on 8 Jun 2021
Commented: Jeff Miller on 10 Jun 2021
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 Comment
Scott MacKenzie
Scott MacKenzie on 8 Jun 2021
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);

Sign in to comment.

Answers (1)

Jeff Miller
Jeff Miller on 9 Jun 2021
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
Jeff Miller
Jeff Miller on 10 Jun 2021
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)?

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!

Translated by