clear
% Program to generate normal distributions using Box-Muller algorithm and Central Limit
% theorem and compare the two distributions
bits=100;
samples=1000;
%Box - Muller Algorithm
u1 = rand(1,samples);
u2 = rand(1,samples);
for i=1:samples
X1(i) = sqrt((-2)*log(u1(i)))*cos(2*pi*u2(i));
X2(i) = sqrt((-2)*log(u1(i)))*sin(2*pi*u2(i));
end
delta=4*2/bits;
range=-4:delta:4
[a,b]=hist(X1,range)
figure(1);
bar(b,a/sum(a))
title('PDF of Gaussian variate X1 genearted using Box-Muller algorithm');
[a,b]=hist(X2,range)
figure(2);
bar(b,a/sum(a))
title('PDF of Gaussian variate X2 genearted using Box-Muller algorithm');
%TEST
H=ttest(X1)
[mu,sigma]=normfit(X1)
p1=normcdf(X1,mu,sigma);
[H1,s1]=kstest(X1,[X1',p1'],0.05)
awgn.zip_AWGN_AWGN仿真_AWGN信道_BOX-MULLER_awgn信道仿真
版权申诉
194 浏览量
2022-09-14
19:01:32
上传
评论
收藏 1KB ZIP 举报
weixin_42653672
- 粉丝: 93
- 资源: 1万+
评论0