滤波瑞利分布的 MATLAB pdf
MATLAB pdf of filtered Rayleigh distribution
晚上好,
我正在尝试在 MATLAB 中编写以下方程,它是由两个高斯数组组成的瑞利分布。无论我做什么,它看起来都不像瑞利衰落的归一化直方图或通用 pdf 分布:
所以,这就是我所做的。
x1 = randn(100000, 1);
% Create a second array of Gaussian random numbers
y1 = randn(100000, 1);
% Pass both Gaussian arrays through low pass filter and save to variable
x1_LPF = filter(LPF, 1, x1);
y1_LPF = filter(LPF, 1, y1);
% New Histograms of Raleigh distribution for filtered data
ray1 = abs(x1_LPF + j*y1_LPF);
figure('Name', 'Normalized Histogram of Raleigh Distribution')
[a, b] = hist(ray1, 100)
delta_x = b(3) - b(2)
% SIGMA left out in equation because it is equal to 1 in the problem
g = b .* exp((-b.^2) / 2) .* delta_x;
plot(b , g, 'b')
这给了我这个:
什么时候它应该看起来像这样黑线:
这是我在 fdatool 中的过滤器设置,以防有人想 运行 通过导出为变量 LPF:
下面的代码可以生成想要的分布:
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')
结果图如下
要获得过滤瑞利分布的 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')
晚上好,
我正在尝试在 MATLAB 中编写以下方程,它是由两个高斯数组组成的瑞利分布。无论我做什么,它看起来都不像瑞利衰落的归一化直方图或通用 pdf 分布:
所以,这就是我所做的。
x1 = randn(100000, 1);
% Create a second array of Gaussian random numbers
y1 = randn(100000, 1);
% Pass both Gaussian arrays through low pass filter and save to variable
x1_LPF = filter(LPF, 1, x1);
y1_LPF = filter(LPF, 1, y1);
% New Histograms of Raleigh distribution for filtered data
ray1 = abs(x1_LPF + j*y1_LPF);
figure('Name', 'Normalized Histogram of Raleigh Distribution')
[a, b] = hist(ray1, 100)
delta_x = b(3) - b(2)
% SIGMA left out in equation because it is equal to 1 in the problem
g = b .* exp((-b.^2) / 2) .* delta_x;
plot(b , g, 'b')
这给了我这个:
什么时候它应该看起来像这样黑线:
这是我在 fdatool 中的过滤器设置,以防有人想 运行 通过导出为变量 LPF
下面的代码可以生成想要的分布:
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')
结果图如下
要获得过滤瑞利分布的 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')