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

📄 q916_qfunction.m

📁 using Monte Carlo integeration calculate Q function
💻 M
字号:
y=input('Enter y, argument of Q function >');
M=input('Enter M, argument of experiments >');
N=input('Enter N, argument of trials >');
u=(pi/2)*rand(N,M);    %Generate random numbers
uu=(1/pi).*exp(-(y^2)./(2*(sin(u)).^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
data(1,:)=uu(1,:);
for j=2:N
    data(j,:)=(pi/2)*sum(uu(1:j,:))/j;
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=100:N;
plot(n,data1(100:N),'k',n,real(100:N),'k--')  %plot resulte
xlabel('Number of Trials')
ylabel('Estimate of Q function')
%End

⌨️ 快捷键说明

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