所以我创建了Laplacian dist。对于A部分。但是,不知道如何从B部分开始。请帮忙。 下面是我对A部分的代码。它显示了Laplacian dist。
t=10000;
a1=2;
U1=rand(1,t)-0.5;
sigmal=sqrt(2/a1);
b1=1/a1;
X1=-b1*sign(U1).*log(1-2*abs(U1)); %transformation method
[pdf1,domain1] = hist(X1,(min(X1):0.2:max(X1)));%defining steps
figure
plot(domain1, pdf1/trapz(domain1,pdf1)) %plot pdf
xlabel('x')
ylabel('PDF Value')
title('Laplacian PDF (alpha=2)')
grid on
figure
plot(domain1, cumsum(pdf1)/t) %plot cdf
xlabel('x')
ylabel('CDF')
title('Laplacian CDF (alpha=2)')
a2=0.5;
U2=rand(1,t)-0.5;
sigma2=sqrt(2/a2);
b2=1/a2;
X2=-b2*sign(U2).*log(1-2*abs(U2)); %transformation method
[pdf2,domain2] = hist(X2,(min(X2):0.2:max(X2))); %defining steps
figure
plot(domain2, pdf2/trapz(domain2,pdf2))
xlabel('x')
ylabel('PDF Value')
title('Laplacian PDF (alpha=0.5)')
grid on
figure
plot(domain2, cumsum(pdf2)/t)
xlabel('x')
ylabel('CDF')
title('Laplacian CDF (alpha=0.5)')
这是问题所在: