Random Variables with Nakagami - m distribution.
8 views (last 30 days)
Show older comments
How can i generate random variables having distribution Nakagami-m ? such that parameter 'm' is user defined.
Thank you.
1 Comment
Pawan Kumar
on 25 Aug 2017
clc;
clear all;
N = 10^7;
M = 2;
g = sin(pi/M)^2;
hmod = modem.pskmod(M);
hdemod = modem.pskdemod(M);
int = randi([0 M-1],1,N);
symb = modulate(hmod,int);
snr_dB = 0:3:30;
snr = 10.^(snr_dB/10);
sze = zeros(size(snr_dB));
jmath = sqrt(-1);
sigm = 1; % channel variance
m = 1.5; % Nakagami-m parameter
thta = 0 + (pi-0).*rand(1,N); % uniform phase
y = gamrnd(m, sigm/m, 1, N); % amplitude having Gamma distribution
h = sqrt(y).*exp(-1i*thta); % Samples for Nakagami-m distribution
n = sqrt(1/2)* (randn(1,N)+jmath*randn(1,N)); % Noise
for j1 = 1:length(snr_dB) j1
r = sqrt(snr(j1))*h.*symb + n; % received signal
rhat = r.*exp(-jmath*angle(h)); % fading phase compensation
Det_r = demodulate(hdemod,rhat); % demodulation
nerr_r = size(find(int-Det_r),2); % number of errors for given snr level
Pe_sim(j1) = nerr_r/N; % error rate
Pe_ana(j1) = 1/pi*quad(@(t) (1+g*snr(j1)./(m*sin(t).^2)).^(-m) , 0, (M-1)*pi/M);
end
figure;
semilogy(snr_dB,Pe_sim,'-.ok');
hold on;
semilogy(snr_dB,Pe_ana,'-+k');
xlabel('SNR (dB)'); ylabel('Average symbol error rate');
legend('Simulation', 'Analytical');
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!