s_orderstatisticspdfstudentt.m

来自「经济学专业代码」· M 代码 · 共 34 行

M
34
字号
% this script shows that the pdf of the r-th order statistics is concentrated 
% around the quantile wiht confidence r/T
% see "Risk and Asset Allocation"-Springer (2005), by A. Meucci
% formula (2.248) and (2.253)

close all; clc; clear;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% input  
mu=0;
s=1;
nu=10;
T=70;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% pdf of r-th order statistic concentrated around the r/T quantile

rs=[1: T];
x=mu + s*[-4: .01 : 4];
F=tcdf((x-mu)/s,nu);
f=1/s*tpdf((x-mu)/s,nu);
for n=1:length(rs)
    r=rs(n);
    
    pdf_rT = gamma(T+1)/(gamma(r)*gamma(T-r+1))*(F.^(r-1)).*((1-F).^(T-r)).*f;
    q=mu+s*tinv(r/T,nu);

    hold on
    plot3(x,r/T+0*x,pdf_rT);
    hold on
    plot3(q,r/T,0,'.')
end

⌨️ 快捷键说明

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