Home > wafo > wstats > wchi2stat.m

# wchi2stat

## PURPOSE

Mean and variance for the Chi squared distribution.

## SYNOPSIS

[m,v]= wchi2stat(p);

## DESCRIPTION

``` WCHI2STAT Mean and variance for the Chi squared distribution.

CALL:  [m,v] = wchi2stat(p)

m, v = the mean and variance, respectively
p = degrees of freedom, p=1,2,3,....

Mean (m) and variance (v) for the Chi squared distribution is

m=p  and  v=2p;

Example:
[m,v] = wchi2stat(2)```

## CROSS-REFERENCE INFORMATION

This function calls:
 nan Not-a-Number. warning Display warning message; disable or enable warning messages.
This function is called by:

## SOURCE CODE

```001 function [m,v]= wchi2stat(p);
002 %WCHI2STAT Mean and variance for the Chi squared distribution.
003 %
004 % CALL:  [m,v] = wchi2stat(p)
005 %
006 %   m, v = the mean and variance, respectively
007 %      p = degrees of freedom, p=1,2,3,....
008 %
009 %  Mean (m) and variance (v) for the Chi squared distribution is
010 %
011 %  m=p  and  v=2p;
012 %
013 % Example:
014 %   [m,v] = wchi2stat(2)
015
016 % Reference: Johnson, Kotz and Balakrishnan (1994)
017 % "Continuous Univariate Distributions, vol. 1", p. 415 ff
018 % Wiley
019
020 % Tested on; Matlab 5.3
021 % History:
022 % revised pab 25.10.2000
023 % - found a bug: forgot multiplication
024 % - added warning+nan's
025 % added ms 26.06.2000
026
027 m =  p;
028 v = 2*p;
029 ok = find(p~=round(p) & p>0);
030 if any(~ok),
031   warning('p should be a positive integer')
032   m(k)=NaN;
033   v(k)=NaN;
034 end
035
036
037
038```

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group

Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003