Error in estimating Nakagami parameters using maximum likelihood estimate function: Error using prob.Nakag​amiDistrib​ution>naka​fit (line 271) The data in X must be positive

2 次查看(过去 30 天)
Hello:
I want to compute the m-Nakagami and omega parameters of the generated signal composed from a Nakagami and gaussian supperposed using the MLE function. I get this error every time but I don't know how to fix it. Does anyone here have an idea how to fix it? Thank You in advance.
Error using prob.NakagamiDistribution>nakafit (line 271)
The data in X must be positive
Error in prob.NakagamiDistribution.fit (line 152)
p = nakafit(x,0.05,cens,freq,opt);
Error in fitdist>localfit (line 238)
pd = feval(fitter,x,'cens',c,'freq',f,varargin{:});
Error in fitdist (line 185)
pd = localfit(dist,fitter,x,cens,freq,args{:});
Error in mle (line 400)
pd =
fitdist(data,dist,'cens',cens,'freq',freq,'options',options);
Error in Untitled22 (line 17)
phat_m_Naka= mle(signal,'distribution','Nakagami');
clear;
clc;
pd_cp = makedist('Nakagami','mu',2,'omega',2);
R_cp = random(pd_cp,5000,1);
pd_lp = makedist('Normal','mu',2,'sigma',1);
R_lp = random(pd_lp,5000,1);
R_lp_Linear= 10.^(R_lp./20);
signal=R_cp'+R_lp';
filter_size= 10;
Mean_Power=filter(ones(1,filter_size)/filter_size,1,signal);
short_fading=signal./Mean_Power;
signal=short_fading(filter_size:end);
phat_m_Naka= mle(signal,'distribution','Nakagami');

回答(1 个)

Torsten
Torsten 2022-4-17
I don't know if this makes sense with respect to what you are trying to do, but MATLAB expects your data to fit a Nakagami distribution to be positive:
signal = short_fading(filter_size:end);
signal = signal(signal > 0);
phat_m_Naka= mle(signal,'distribution','Nakagami');
  1 个评论
youcha
youcha 2022-4-18
Thank You Torsten, Your answer enlighted me so I found the solution. It was an error in the code so here is how I fixed it.
clear;
clc;
pd_cp = makedist('Nakagami','mu',2,'omega',2);
R_cp = random(pd_cp,5000,1);
pd_lp = makedist('Normal','mu',2,'sigma',1);
R_lp = random(pd_lp,5000,1);
R_lp_Linear= 10.^(R_lp./20);
signal=R_cp'.*R_lp_Linear';
filter_size= 10;
Mean_Power=filter(ones(1,filter_size)/filter_size,1,signal);
short_fading=signal./Mean_Power;
signal=short_fading(filter_size:end);
phat_m_Naka= mle(signal,'distribution','Nakagami');

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by