【问题标题】:MATLAB pdf of filtered Rayleigh distribution滤波瑞利分布的 MATLAB pdf
【发布时间】:2017-08-26 21:16:12
【问题描述】:

晚上好,

我正在尝试在 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 来为自己运行它:

【问题讨论】:

    标签: matlab pdf plot histogram normalization


    【解决方案1】:

    以下代码可以生成所需的分布:

    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')
    

    结果图如下

    【讨论】:

    • 这是未过滤瑞利分布的正确模拟和理论打印输出。所以,我需要过滤理论和过滤瑞利分布。所以我想我真正的问题是如何正确“过滤”理论曲线以适合我的模拟数据。
    • 您可以发送您的数据样本吗?
    • 这里是我的 github 的链接,其中包含示例代码和您必须导入的低通滤波器:github.com/TreverWagenhals/TreverWagenhals/tree/master/School/…
    【解决方案2】:

    要获得过滤瑞利分布的 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') 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-01
      • 1970-01-01
      相关资源
      最近更新 更多