parzen窗函数正态分布的概率密度函数估计(matlab)02

发布时间:2024-11-28

%%%%%%%%正态分布的概率密度函数估计
function myparzen02()
clc;
close all;
clear all;
N = 20480; %调整N的值可以改进精度
x = linspace(-3, 3, 100);
f = randn(N, 1); %%产生标准正态分布

X = zeros(N, 1);
X=f;

p = Parzen(x, X, 0.25, 1);
subplot(3,3,1);plot(x, p);title('N =1, h1 = 0.25');axis([-3, 3, 0, 1.5]);grid on;
p = Parzen(x, X, 1, 1);
subplot(3,3,2);plot(x, p);title('N =1, h1 = 1');axis([-3, 3, 0, 1.5]); grid on;
p = Parzen(x, X, 4, 1);
subplot(3,3,3);plot(x, p);title('N =1, h1 = 4');axis([-3, 3, 0, 1.5]); grid on;
p = Parzen(x, X, 0.25, 16);
subplot(3,3,4);plot(x, p);title('N =16, h1 = 0.25');axis([-3, 3, 0, 1.5]); grid on;
p = Parzen(x, X, 1, 16);
subplot(3,3,5);plot(x, p);title('N =16, h1 = 1');axis([-3, 3, 0, 1.5]); grid on;
p = Parzen(x, X, 4, 16);
subplot(3,3,6);plot(x, p);title('N =16, h1 = 4');axis([-3, 3, 0, 1.5]); grid on;

p = Parzen(x, X, 0.25, N);
subplot(3,3,7);plot(x, p);title('N =256, h1 = 0.25');axis([-3, 3, 0, 1.5]); grid on;
p = Parzen(x, X, 1, N);
subplot(3,3,8);plot(x, p);title('N =256, h1 = 1');axis([-3, 3, 0, 1.5]); grid on;
p = Parzen(x, X, 4,N);
subplot(3,3,9);plot(x, p);title('N =256, h1 = 4');axis([-3, 3, 0, 1.5]); grid on;
grid on;
end

function p = Parzen(x, X, h1, N) % x为横坐标; X为样本; h1用来调节窗宽h; N为样本个数.
h = h1 / sqrt(N);
% h为窗宽.
sum = zeros(1, 100);
for i = 1:N
sum = sum + normpdf((x - X(i))/h, 0, 1); %用正态窗函数作Parzen窗估计
end
p = sum/(N * h);
end

parzen窗函数正态分布的概率密度函数估计(matlab)02.doc 将本文的Word文档下载到电脑

    精彩图片

    热门精选

    大家正在看

    × 游客快捷下载通道(下载后可以自由复制和排版)

    限时特价:7 元/份 原价:20元

    支付方式:

    开通VIP包月会员 特价:29元/月

    注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
    微信:fanwen365 QQ:370150219