⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s_studentt.m

📁 进行T分布检验
💻 M
字号:
% this script familiarizes the user with some basic properties of the
% Student t distribution, see "Risk and Asset Allocation"-Springer (2005), by A. Meucci
% Section 1.3.4

clear; clc; close all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% inputs
mu=0;
sigma_2=1;  
nu=1;  % 
NumSimulations=100000;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% compute pdf and cdf using matlab functions
sigma=sqrt(sigma_2);
x=[mu-4*sigma : sigma/100 : mu+4*sigma]; % set range
pdf =1/sigma*tpdf((x-mu)/sigma,nu);
cdf =tcdf((x-mu)/sigma,nu);

% generate sample using matlab functions
X = mu+sigma*trnd(nu,NumSimulations,1);

% compute quantile using matlab functions
u=[.01 : .01 : .99]; % set range
quantile = mu+sigma*tinv(u,nu);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% plots
figure
NumBins=round(10*log(NumSimulations));
hist(X,NumBins)
[n,Ds]=hist(X,NumBins);
D=Ds(2)-Ds(1);
hold on
h=plot(x,pdf*NumSimulations*D,'r');
grid on
title('pdf/histogram')

figure
plot([1:NumSimulations],X,'.')
grid on
title('sample vs. observation time')

%break
figure
h=plot(x,cdf,'b');
grid on
title('cdf')

figure
h=plot(u,quantile,'b');
grid on
title('quantile')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -