测试MATLAB的广义极值分布函数GEV

您所在的位置:网站首页 gev轴承 测试MATLAB的广义极值分布函数GEV

测试MATLAB的广义极值分布函数GEV

2023-09-14 11:53| 来源: 网络整理| 查看: 265

nRows   = 1000;  nColumn= 250;  data = trnd(8, nRows , nColumn);    %1000行250列,自由度为5的student t的随机数 maxSeries = max(data );                   % 250 列最大值,也就是所谓的极值 paras=gevfit(maxSeries);                  %根据极值参数,参数为形状参数k≠0,尺度参数sigma(σ),位置参数mu(?) k=paras(1); sigma=paras(2); mu=paras(3);  histogram(maxSeries,2:20);            %绘制极大值x的频数分布图,指定x轴指定范围在2-20年内,否则无法匹配高度 x= linspace(2,20,100);                      %产生1000个[2,20]的数据列%1.根据指定的x序列值,计算GEV分布的概率值(GEV的3参数已知) y_pdf= nColumn*gevpdf(x, k,sigma,mu ); line(x,y_pdf);                                      %这是概率分布曲线,如下图所示 %2.根据指定的x序列值,计算GEV分布的累计概率值(GEV的3参数已知) y_cdf= gevcdf(x,  k,sigma,mu ); %或用 y_cdf=cdf('gev', x,k,sigma,mu ); %name也可以用''Generalized Extreme Value'' line(x,y_cdf); %3.根据指定的概率值(或者分位数),获取对应的变量值 gevinv(0.5,k,sigma,mu);%4.其余的函数有随机数和统计 R = gevrnd(k,sigma,mu)                                     %创建符合指定参数的随机数 [MeanVale,Variation] = gevstat(k,sigma,mu);  %计算均值和变异

ps:当k0时,是PⅡ极值分布;

%% 测试正态分布 x=-5:0.1:5; mu=0; std=0.5; %1.根据均值和标准差获得x的概率 y=normpdf(x,mu,std);%或y=pdf('norm',x,0,1); hold on plot(x,y) %2.根据均值和标准差获得x的累积概率 y=cdf('norm',x,mu,std);%或y=pdf('norm',x,0,1); hold on plot(x,y) %3.给定一个学生成绩求参数,分位数等 clc;clear load('score') [mu,std]=normfit(scores);  histogram(scores,20:100)%这里的范围是20-100,下面画概率密度时一定要20-100 x=20:0.1:100; y=normpdf(x,mu,std)*118;%概率密度.后者用:y=pdf('norm',x,mu,std)*500;  line(x,y) y=normcdf(x,mu,std);    %累积概率密度 line(x,y) y=norminv(0.5,mu,std)  ;%分位数查找对应的变量值,比如中等50%分位数 %或用 y=icdf('norm',0.5,mu,std);

%% 4.验证拟合的优度 scores=sort(scores,'ascend');%对原始数据进行排序 scores(:,2)=[1:118]/119;    %计算原始数据的频数 scores(:,3)=norminv(scores(:,2),mu,std);%根据频数,计算在拟合曲线中的预测值 x=scores(:,1); y=scores(:,3); plot(x) hold on plot(y,'-') legend('x','y')

[r1,p]=corr(scores,y_predict,'type','Pearson');   [r2,p]=corr(scores,y_predict,'type','Kendall'); [r3,p]=corr(scores,y_predict,'type','Spearman'); line(1:118,y_predict) histogram(y_predict,10) histogram(scores,10) line(1:118,scores)



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3