WTSTAT Mean and variance for the Student's T distribution. CALL: [m,v] = wtstat(df) m, v = the mean and variance, respectively df = degrees of freedom of the Student's T distribution Mean (m) and variance (v) for the T distribution is m=0 if df>1 and v=df/(df-2) if df>2 See also wtpdf
001 function [m,v]= wtstat(a); 002 %WTSTAT Mean and variance for the Student's T distribution. 003 % 004 % CALL: [m,v] = wtstat(df) 005 % 006 % m, v = the mean and variance, respectively 007 % df = degrees of freedom of the Student's T distribution 008 % 009 % Mean (m) and variance (v) for the T distribution is 010 % 011 % m=0 if df>1 and v=df/(df-2) if df>2 012 % 013 % See also wtpdf 014 015 016 % Reference: Cohen & Whittle, (1988) "Parameter Estimation in Reliability 017 % and Life Span Models", Marcel Dekker. 018 019 020 % Tested on; Matlab 5.3 021 % History: 022 % by pab 23.10.2000 023 024 error(nargchk(1,1,nargin)) 025 026 % Initialize Mean and Variance to zero. 027 m = zeros(size(a)); 028 v = zeros(size(a)); 029 030 ok = (a > 0 & floor(a)==a); 031 k = find(a>2 & ok); 032 if any(k) 033 v(k) = a(k)./(a(k)-2); 034 end 035 036 k1 = find(~ok | a<=1); 037 if any(k1) 038 tmp = NaN; 039 m(k1) = tmp(ones(size(k1))); 040 end 041 k1 = find(~ok | a<=2); 042 if any(k1) 043 tmp = NaN; 044 v(k1) = tmp(ones(size(k1))); 045 end 046 047 048
Comments or corrections to the WAFO group