Mercurial > octave-nkf
comparison scripts/statistics/distributions/hygecdf.m @ 7002:12ab7f5fc663
[project @ 2007-10-10 18:27:06 by jwe]
author | jwe |
---|---|
date | Wed, 10 Oct 2007 18:27:07 +0000 |
parents | 34f96dd5441b |
children | 93c65f2a5668 |
comparison
equal
deleted
inserted
replaced
7001:8b0cfeb06365 | 7002:12ab7f5fc663 |
---|---|
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} {} hygecdf (@var{x}, @var{m}, @var{t}, @var{n}) | 21 ## @deftypefn {Function File} {} hygecdf (@var{x}, @var{t}, @var{m}, @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{t}, @var{m}, 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 |
27 ## @var{m} marked items. | 27 ## @var{m} marked items. |
28 ## | 28 ## |
29 ## The parameters @var{m}, @var{t}, and @var{n} must positive integers | 29 ## The parameters @var{t}, @var{m}, and @var{n} must positive integers |
30 ## with @var{m} and @var{n} not greater than @var{t}. | 30 ## with @var{m} and @var{n} not greater than @var{t}. |
31 ## @end deftypefn | 31 ## @end deftypefn |
32 | 32 |
33 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> | 33 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
34 ## Description: CDF of the hypergeometric distribution | 34 ## Description: CDF of the hypergeometric distribution |
35 | 35 |
36 function cdf = hygecdf (x, m, t, n) | 36 function cdf = hygecdf (x, t, m, n) |
37 | 37 |
38 if (nargin != 4) | 38 if (nargin != 4) |
39 print_usage (); | 39 print_usage (); |
40 endif | 40 endif |
41 | 41 |
42 if (!isscalar (m) || !isscalar (t) || !isscalar (n)) | 42 if (!isscalar (t) || !isscalar (m) || !isscalar (n)) |
43 error ("hygecdf: m, t and n must all be positive integers"); | 43 error ("hygecdf: t, m 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 ((t < 0) | (m < 0) | (n <= 0) | (t != round (t)) | |
47 (t != round (t)) | (n != round (n)) | (m > t) | (n > t)) | 47 (m != round (m)) | (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, hygepdf (0 : n, m, t, n)); | 50 cdf = discrete_cdf (x, 0 : n, hygepdf (0 : n, t, m, n)); |
51 endif | 51 endif |
52 | 52 |
53 endfunction | 53 endfunction |
54 | |
55 |