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

📄 tdis_rnd.m

📁 计量工具箱
💻 M
字号:
function t = tdis_rnd (n,df)
% PURPOSE: returns random draws from the t(n) distribution
%---------------------------------------------------
% USAGE: rnd = tdis_rnd(n,df)
% where: n = size of vector 
%        df = a scalar dof parameter
% NOTE:  mean=0, std=1
%---------------------------------------------------
% RETURNS:
%        a vector of random draws from the t(n) distribution      
% --------------------------------------------------
% SEE ALSO: tdis_cdf, tdis_rnd, tdis_pdf, tdis_prb
%---------------------------------------------------

% written by:
% James P. LeSage, Dept of Economics
% University of Toledo
% 2801 W. Bancroft St,
% Toledo, OH 43606
% jpl@jpl.econ.utoledo.edu

  
if nargin ~= 2
error('Wrong # of arguments to tdis_rnd');
end;

if is_scalar(df)
 if (df<=0)
   error('tdis_rnd dof is wrong');
 end
 z = randn(n,1);
 x = chis_rnd(n,df);
 t = (z*sqrt(df))./sqrt(x);
else
 error('tdis_rnd: df must be a scalar');
end;

⌨️ 快捷键说明

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