comparison scripts/statistics/distributions/hygecdf.m @ 5411:bee21f388110

[project @ 2005-07-13 17:53:44 by jwe]
author jwe
date Wed, 13 Jul 2005 17:53:49 +0000
parents 56e066f5efc1
children 2a16423e4aa0
comparison
equal deleted inserted replaced
5410:56e066f5efc1 5411:bee21f388110
16 ## along with Octave; see the file COPYING. If not, write to the Free 16 ## along with Octave; see the file COPYING. If not, write to the Free
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 ## 02110-1301, USA. 18 ## 02110-1301, USA.
19 19
20 ## -*- texinfo -*- 20 ## -*- texinfo -*-
21 ## @deftypefn {Function File} {} hypergeometric_cdf (@var{x}, @var{m}, @var{t}, @var{n}) 21 ## @deftypefn {Function File} {} hygecdf (@var{x}, @var{m}, @var{t}, @var{n})
22 ## Compute the cumulative distribution function (CDF) at @var{x} of the 22 ## Compute the cumulative distribution function (CDF) at @var{x} of the
23 ## hypergeometric distribution with parameters @var{m}, @var{t}, and 23 ## hypergeometric distribution with parameters @var{m}, @var{t}, and
24 ## @var{n}. This is the probability of obtaining not more than @var{x} 24 ## @var{n}. This is the probability of obtaining not more than @var{x}
25 ## marked items when randomly drawing a sample of size @var{n} without 25 ## marked items when randomly drawing a sample of size @var{n} without
26 ## replacement from a population of total size @var{t} containing 26 ## replacement from a population of total size @var{t} containing
31 ## @end deftypefn 31 ## @end deftypefn
32 32
33 ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> 33 ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at>
34 ## Description: CDF of the hypergeometric distribution 34 ## Description: CDF of the hypergeometric distribution
35 35
36 function cdf = hypergeometric_cdf (x, m, t, n) 36 function cdf = hygecdf (x, m, t, n)
37 37
38 if (nargin != 4) 38 if (nargin != 4)
39 usage ("hypergeometric_cdf (x, m, t, n)"); 39 usage ("hygecdf (x, m, t, n)");
40 endif 40 endif
41 41
42 if (!isscalar (m) || !isscalar (t) || !isscalar (n)) 42 if (!isscalar (m) || !isscalar (t) || !isscalar (n))
43 error ("hypergeometric_cdf: m, t and n must all be positive integers"); 43 error ("hygecdf: m, t and n must all be positive integers");
44 endif 44 endif
45 45
46 if ((m < 0) | (t < 0) | (n <= 0) | (m != round (m)) | 46 if ((m < 0) | (t < 0) | (n <= 0) | (m != round (m)) |
47 (t != round (t)) | (n != round (n)) | (m > t) | (n > t)) 47 (t != round (t)) | (n != round (n)) | (m > t) | (n > t))
48 cdf = NaN * ones (size (x)) 48 cdf = NaN * ones (size (x))
49 else 49 else
50 cdf = discrete_cdf (x, 0 : n, hypergeometric_pdf (0 : n, m, t, n)); 50 cdf = discrete_cdf (x, 0 : n, hygepdf (0 : n, m, t, n));
51 endif 51 endif
52 52
53 endfunction 53 endfunction
54 54
55 55