⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 q915b_qfunction.m

📁 使用pMatlab改写BPSK和QPSK 的Monte Carlo 仿真程序。在多核PC上实现MC仿真速度翻倍(附原程序)
💻 M
字号:
y=input('Enter y, argument of Q function >');
M=input('Enter M, No. of experiments >');
N=input('Enter N, No. of trials >');
u=y*rand(N,M);    %Generate random numbers
uu=(1/sqrt(2*pi)).*exp(-(u.^2)/2); %Define functon
data=zeros(N,M);%Initialize array
data1=zeros(N,1);
%The following four lines of code determine
%M estimates as a function of j, 0<j<=N
if y>0
    data(1,:)=0.5-abs(y)*uu(1,:);
    for j=2:N
        data(j,:)=0.5-abs(y)*sum(uu(1:j,:))/j;
    end
else if y<0
        data(1,:)=0.5+abs(y)*uu(1,:);
        for j=2:N
            data(j,:)=0.5+abs(y)*sum(uu(1:j,:))/j;
        end;
    else data(j,:)=0.5;
    end;
end;
est=data(N,:);   %N estimates of Q(y)
est1=sum(est)/M;
for k=1:N
    data1(k,1)=sum(data(k,:))/M;
end;
real=qfunc(y)*ones(1,N);
n=1000:N;
plot(n,data1(1000:N),'k',n,real(1000:N),'k--')  %plot resulte
xlabel('Number of Trials')
ylabel('Estimate of Q function')
%End

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -