WEXPSTAT Mean and variance for the Exponential distribution. CALL: [m,v] = wexpstat(m0) m, v = the mean and variance, respectively m0 = parameter of the Exponential distribution, m0>0. Mean (m) and variance (v) for the Exponential distribution is m=m0 and v=m0^2; Example: [m,v] = wexpstat(5)
001 function [m,v]= wexpstat(m0); 002 %WEXPSTAT Mean and variance for the Exponential distribution. 003 % 004 % CALL: [m,v] = wexpstat(m0) 005 % 006 % m, v = the mean and variance, respectively 007 % m0 = parameter of the Exponential distribution, m0>0. 008 % 009 % Mean (m) and variance (v) for the Exponential distribution is 010 % 011 % m=m0 and v=m0^2; 012 % 013 % Example: 014 % [m,v] = wexpstat(5) 015 016 % Reference: Johnson, Kotz and Balakrishnan (1994) 017 % "Continuous Univariate Distributions, vol. 1", p. 494 ff 018 % Wiley 019 020 % Tested on; Matlab 5.3 021 % History: 022 % revised pab Dec2003 023 % fixed a bug k1->k3 024 % revised pab 24.10.2000 025 % - added nargchk 026 % added ms 15.06.2000 027 028 error(nargchk(1,1,nargin)) 029 030 % Initialize fm to zero. 031 m = zeros(size(m0)); 032 v=m; 033 034 k=find(m0 > 0); 035 if any(k), 036 m(k) = m0(k); 037 v(k) = m0(k).^2; 038 end 039 040 k3 = find(m0<0 ); 041 if any(k3) 042 tmp = NaN; 043 m(k3) = tmp(ones(size(k3))); 044 v(k3)=m(k3); 045 end 046 047
Comments or corrections to the WAFO group