Mercurial > hg > octave-lyh
comparison scripts/statistics/distributions/chisquare_cdf.m @ 3456:434790acb067
[project @ 2000-01-19 06:58:51 by jwe]
author | jwe |
---|---|
date | Wed, 19 Jan 2000 06:59:23 +0000 |
parents | f8dde1807dee |
children | 74c2fc84f0cf |
comparison
equal
deleted
inserted
replaced
3455:f758be6e1730 | 3456:434790acb067 |
---|---|
12 ## | 12 ## |
13 ## You should have received a copy of the GNU General Public License | 13 ## You should have received a copy of the GNU General Public License |
14 ## along with this file. If not, write to the Free Software Foundation, | 14 ## along with this file. If not, write to the Free Software Foundation, |
15 ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 15 ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
16 | 16 |
17 ## usage: chisquare_cdf (x, n) | 17 ## -*- texinfo -*- |
18 ## | 18 ## @deftypefn {Function File} {} chisquare_cdf (@var{x}, @var{n}) |
19 ## For each element of x, compute the cumulative distribution function | 19 ## For each element of @var{x}, compute the cumulative distribution |
20 ## (CDF) at x of the chisquare distribution with n degrees of freedom. | 20 ## function (CDF) at @var{x} of the chisquare distribution with @var{n} |
21 ## degrees of freedom. | |
22 ## @end deftypefn | |
21 | 23 |
22 ## Author: TT <Teresa.Twaroch@ci.tuwien.ac.at> | 24 ## Author: TT <Teresa.Twaroch@ci.tuwien.ac.at> |
23 ## Description: CDF of the chi-square distribution | 25 ## Description: CDF of the chi-square distribution |
24 | 26 |
25 function cdf = chisquare_cdf (x, n) | 27 function cdf = chisquare_cdf (x, n) |
26 | 28 |
27 if (nargin != 2) | 29 if (nargin != 2) |
28 usage ("chisquare_cdf (x, n)"); | 30 usage ("chisquare_cdf (x, n)"); |
29 endif | 31 endif |
30 | 32 |
31 [retval, x, n] = common_size (x, n); | 33 [retval, x, n] = common_size (x, n); |
32 if (retval > 0) | 34 if (retval > 0) |
33 error (["chisquare_cdf: ", ... | 35 error ("chisquare_cdf: x and n must be of common size or scalar"); |
34 "x and n must be of common size or scalar"]); | |
35 endif | 36 endif |
36 | 37 |
37 cdf = gamma_cdf (x, n / 2, 1 / 2); | 38 cdf = gamma_cdf (x, n / 2, 1 / 2); |
38 | 39 |
39 ## should we really only allow for positive integer n? | 40 ## should we really only allow for positive integer n? |
40 k = find (n != round (n)); | 41 k = find (n != round (n)); |
41 if any (k) | 42 if (any (k)) |
42 fprintf (stderr, ... | 43 warning ("chisquare_cdf: n should be positive integer"); |
43 "WARNING: n should be positive integer\n"); | |
44 [r, c] = size (x); | 44 [r, c] = size (x); |
45 cdf = reshape (cdf, 1, r * c); | 45 cdf = reshape (cdf, 1, r * c); |
46 cdf(k) = NaN * ones (1, length (k)); | 46 cdf(k) = NaN * ones (1, length (k)); |
47 cdf = reshape (cdf, r, c); | 47 cdf = reshape (cdf, r, c); |
48 endif | 48 endif |