# Problems using `fitdist` to Rician distribution

14 ビュー (過去 30 日間)
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)
checkargs(s,sigma)
Error in prob.RicianDistribution.makeFitted (line 175)
pd = prob.RicianDistribution(p(1),p(2));
Error in prob.RicianDistribution.fit (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 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.
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);
plot(x_values,y,'LineWidth',2)

サインインしてコメントする。

### 回答 (1 件)

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:
histogram(data,'normalization','pdf');
ricianMatlab = makedist('Rician','s',1,'sigma',1);
ricianCupid = dMATLABc(ricianMatlab,'rr',[eps eps],[+inf +inf]);
ricianCupid.EstML(data)
% ans = 'Rician(6.5538e-05,0.11714)'
x=0.001:0.01:0.5;
pdfx = ricianCupid.PDF(x);
hold on
plot(x,pdfx,'-')
##### 3 件のコメント表示非表示 2 件の古いコメント
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)?

サインインしてコメントする。

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by