一、问题描述
想产生不同特征参数的α稳定随机变量,并且作出其概率密度函数进行对比。
二、解决思路
运行了MATLAB的官方实例代码:
openExample(‘stats/ComparePDFsOfStableDistributionsExample’)
(1)使用makedist()函数生成概率分布对象
(2)使用pdf()函数对该概率分布对象作出PDF曲线
三、实验代码
(1)第一种方式:直接打开官方实例代码
openExample('stats/ComparePDFsOfStableDistributionsExample')
(2)第二种方式:给出官方实例代码,并加以部分注释
% openExample('stats/ComparePDFsOfStableDistributionsExample') %
% 从这个example里复制close all;clear;clc;%% 产生稳定分布
pd1 = makedist('Stable','alpha',2,'beta',0,'gam',1,'delta',0); % 产生对称α稳定分布
pd2 = makedist('Stable','alpha',1,'beta',0,'gam',1,'delta',0);
pd3 = makedist('Stable','alpha',0.5,'beta',0,'gam',1,'delta',0);pd4 = makedist('Stable','alpha',0.5,'beta',0,'gam',1,'delta',0);
pd5 = makedist('Stable','alpha',0.5,'beta',0.5,'gam',1,'delta',0);
pd6 = makedist('Stable','alpha',0.5,'beta',1,'gam',1,'delta',0);%% 计算pdf
x = -5:1e-1:5;
pdf1 = pdf(pd1,x);
pdf2 = pdf(pd2,x);
pdf3 = pdf(pd3,x);x = -5:1e-1:5;
pdf4 = pdf(pd4,x);
pdf5 = pdf(pd5,x);
pdf6 = pdf(pd6,x);%% 作图figure;
plot(x,pdf1,'b-');
hold on
plot(x,pdf2,'r-.');
plot(x,pdf3,'k--');
title('Compare Alpha Parameters in Stable Distribution PDF Plots')
legend('\alpha = 2','\alpha = 1','\alpha = 0.5','Location','northwest')
hold offfigure;
plot(x,pdf4,'b-');
hold on
plot(x,pdf5,'r-.');
plot(x,pdf6,'k--');
title('Compare Beta Parameters in Stable Distribution PDF Plots')
legend('\beta = 0','\beta = 0.5','\beta = 1','Location','northwest')
hold off
四、运行结果
(1)第一种方式
(2)第二种方式