晚上好,
我正在尝试在MATLAB中编程以下等式,这是一个由两个高斯数组组成的瑞利分布。无论我做什么,它都不会接近标准化直方图或rayleigh fade的通用pdf分布:
所以,这就是我所做的。
self.isUserInteractionEnabled = true
这给了我这个:
相反,它应该看起来像这样的黑线:
答案 0 :(得分:0)
以下代码可以生成所需的分发:
N=1000000;
%Random uniform variables
U=rand(N,1);
%Rayleight random variable using an inverse transform sampling
sigma=1;
x1=sigma*sqrt(-2*log(1-U));
histogram(x1,'Normalization','pdf');
% Theoretical equation
x=linspace(0,6,100);
pdf=x/sigma^2.*exp((-x.^2)/(2*sigma^2));
% Plot
hold on
plot(x,pdf,'r')
legend('Stochastic','Theoretical')
结果图如下
答案 1 :(得分:0)
要获得滤波瑞利分布的pdf,您必须采用原始的pdf方程,并用滤波的瑞利分布的均方值替换sigma ^ 2的任何实例。因此,等式变为
2x / MSV * exp(-x ^ 2 / MSV)
这样的事情:
x1 = randn(N, 1);
y1 = randn(N, 1);
x1_LPF = filter(LPF, 1, x1);
y1_LPF = filter(LPF, 1, y1);
ray1_f = abs(x1_LPF + 1i*y1_LPF);
range = [0:0.01:4];
subplot(1, 2, 2);
histogram(ray1_f, 'Normalization', 'pdf');
title('Normalized Histogram of Raleigh Distribution (filtered)')
xlabel('Random Variable')
ylabel('Probability')
mean_square = mean(ray1_f .^ 2);
filter_theory = (range) * 2 / mean_square .* exp( - (range.^2) ./ mean_square);
hold on
plot(range, filter_theory, 'Linewidth', 1.5)
xlim([0 .6])
legend('Simulation', 'Theoretical')