Problems using `fitdist` to Rician distribution
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Scott MacKenzie
le 8 Juin 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);
plot(x_values,y,'LineWidth',2)
Réponses (1)
Jeff Miller
le 9 Juin 2021
I'm not sure why you are getting that error message, but Rician(6.5538e-05,0.11714) looks quite good:
load('temp');
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 commentaires
Jeff Miller
le 10 Juin 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)?
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!