# HG changeset patch # User jwe # Date 1192040827 0 # Node ID 12ab7f5fc6634ffbf5382fcedfed4c680b53e550 # Parent 8b0cfeb063654ab16e98bb3bb38358e76e6e7502 [project @ 2007-10-10 18:27:06 by jwe] diff -r 8b0cfeb06365 -r 12ab7f5fc663 scripts/ChangeLog --- a/scripts/ChangeLog Wed Oct 10 18:03:02 2007 +0000 +++ b/scripts/ChangeLog Wed Oct 10 18:27:07 2007 +0000 @@ -1,3 +1,11 @@ +2007-10-10 Arno Onken + + * statistics/distributions/hygecdf.m, + statistics/distributions/hygeinv.m, + statistics/distributions/hygepdf.m, + statistics/distributions/hygernd.m: + Swap order of T and M args for compatibility. + 2007-10-10 Olli Saarela * control/hinf/hinfsyn.m, control/hinf/wgt1o.m, diff -r 8b0cfeb06365 -r 12ab7f5fc663 scripts/statistics/distributions/hygecdf.m --- a/scripts/statistics/distributions/hygecdf.m Wed Oct 10 18:03:02 2007 +0000 +++ b/scripts/statistics/distributions/hygecdf.m Wed Oct 10 18:27:07 2007 +0000 @@ -18,38 +18,36 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} hygecdf (@var{x}, @var{m}, @var{t}, @var{n}) +## @deftypefn {Function File} {} hygecdf (@var{x}, @var{t}, @var{m}, @var{n}) ## Compute the cumulative distribution function (CDF) at @var{x} of the -## hypergeometric distribution with parameters @var{m}, @var{t}, and +## hypergeometric distribution with parameters @var{t}, @var{m}, and ## @var{n}. This is the probability of obtaining not more than @var{x} ## marked items when randomly drawing a sample of size @var{n} without ## replacement from a population of total size @var{t} containing ## @var{m} marked items. ## -## The parameters @var{m}, @var{t}, and @var{n} must positive integers +## The parameters @var{t}, @var{m}, and @var{n} must positive integers ## with @var{m} and @var{n} not greater than @var{t}. ## @end deftypefn ## Author: KH ## Description: CDF of the hypergeometric distribution -function cdf = hygecdf (x, m, t, n) +function cdf = hygecdf (x, t, m, n) if (nargin != 4) print_usage (); endif - if (!isscalar (m) || !isscalar (t) || !isscalar (n)) - error ("hygecdf: m, t and n must all be positive integers"); + if (!isscalar (t) || !isscalar (m) || !isscalar (n)) + error ("hygecdf: t, m and n must all be positive integers"); endif - if ((m < 0) | (t < 0) | (n <= 0) | (m != round (m)) | - (t != round (t)) | (n != round (n)) | (m > t) | (n > t)) + if ((t < 0) | (m < 0) | (n <= 0) | (t != round (t)) | + (m != round (m)) | (n != round (n)) | (m > t) | (n > t)) cdf = NaN * ones (size (x)) else - cdf = discrete_cdf (x, 0 : n, hygepdf (0 : n, m, t, n)); + cdf = discrete_cdf (x, 0 : n, hygepdf (0 : n, t, m, n)); endif endfunction - - diff -r 8b0cfeb06365 -r 12ab7f5fc663 scripts/statistics/distributions/hygeinv.m --- a/scripts/statistics/distributions/hygeinv.m Wed Oct 10 18:03:02 2007 +0000 +++ b/scripts/statistics/distributions/hygeinv.m Wed Oct 10 18:27:07 2007 +0000 @@ -18,33 +18,33 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} hygeinv (@var{x}, @var{m}, @var{t}, @var{n}) +## @deftypefn {Function File} {} hygeinv (@var{x}, @var{t}, @var{m}, @var{n}) ## For each element of @var{x}, compute the quantile at @var{x} of the -## hypergeometric distribution with parameters @var{m}, @var{t}, and +## hypergeometric distribution with parameters @var{t}, @var{m}, and ## @var{n}. ## -## The parameters @var{m}, @var{t}, and @var{n} must positive integers +## The parameters @var{t}, @var{m}, and @var{n} must positive integers ## with @var{m} and @var{n} not greater than @var{t}. ## @end deftypefn ## Author: KH ## Description: Random deviates from the hypergeometric distribution -function inv = hygeinv (x, m, t, n) +function inv = hygeinv (x, t, m, n) if (nargin != 4) print_usage (); endif - if (!isscalar (m) || !isscalar (t) || !isscalar (n)) - error ("hygeinv: m, t and n must all be positive integers"); + if (!isscalar (t) || !isscalar (m) || !isscalar (n)) + error ("hygeinv: t, m and n must all be positive integers"); endif - if ((m < 0) | (t < 0) | (n <= 0) | (m != round (m)) | - (t != round (t)) | (n != round (n)) | (m > t) | (n > t)) + if ((t < 0) | (m < 0) | (n <= 0) | (t != round (t)) | + (m != round (m)) | (n != round (n)) | (m > t) | (n > t)) inv = NaN * ones (size (x)) else - inv = discrete_inv (x, 0 : n, hygepdf (0 : n, m, t, n)); + inv = discrete_inv (x, 0 : n, hygepdf (0 : n, t, m, n)); endif endfunction diff -r 8b0cfeb06365 -r 12ab7f5fc663 scripts/statistics/distributions/hygepdf.m --- a/scripts/statistics/distributions/hygepdf.m Wed Oct 10 18:03:02 2007 +0000 +++ b/scripts/statistics/distributions/hygepdf.m Wed Oct 10 18:27:07 2007 +0000 @@ -18,9 +18,9 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} hygepdf (@var{x}, @var{m}, @var{t}, @var{n}) +## @deftypefn {Function File} {} hygepdf (@var{x}, @var{t}, @var{m}, @var{n}) ## Compute the probability density function (PDF) at @var{x} of the -## hypergeometric distribution with parameters @var{m}, @var{t}, and +## hypergeometric distribution with parameters @var{t}, @var{m}, and ## @var{n}. This is the probability of obtaining @var{x} marked items ## when randomly drawing a sample of size @var{n} without replacement ## from a population of total size @var{t} containing @var{m} marked items. @@ -31,29 +31,29 @@ ## Author: KH ## Description: PDF of the hypergeometric distribution -function pdf = hygepdf (x, m, t, n) +function pdf = hygepdf (x, t, m, n) if (nargin != 4) print_usage (); endif - if (!isscalar (m) || !isscalar (t) || !isscalar (n)) - [retval, x, m, t, n] = common_size (x, m, t, n); + if (!isscalar (t) || !isscalar (m) || !isscalar (n)) + [retval, x, t, m, n] = common_size (x, t, m, n); if (retval > 0) - error ("hygepdf: x, m, t, and n must be of common size or scalar"); + error ("hygepdf: x, t, m, and n must be of common size or scalar"); endif endif pdf = zeros (size (x)); ## everything in i1 gives NaN - i1 = ((m < 0) | (t < 0) | (n <= 0) | (m != round (m)) | - (t != round (t)) | (n != round (n)) | (m > t) | (n > t)); + i1 = ((t < 0) | (m < 0) | (n <= 0) | (t != round (t)) | + (m != round (m)) | (n != round (n)) | (m > t) | (n > t)); ## everything in i2 gives 0 unless in i1 i2 = ((x != round (x)) | (x < 0) | (x > m) | (n < x) | (n-x > t-m)); k = find (i1); if (any (k)) - if (isscalar (m) && isscalar (t) && isscalar (n)) + if (isscalar (t) && isscalar (m) && isscalar (n)) pdf = NaN * ones ( size (x)); else pdf (k) = NaN; @@ -61,7 +61,7 @@ endif k = find (!i1 & !i2); if (any (k)) - if (isscalar (m) && isscalar (t) && isscalar (n)) + if (isscalar (t) && isscalar (m) && isscalar (n)) pdf (k) = (bincoeff (m, x(k)) .* bincoeff (t-m, n-x(k)) / bincoeff (t, n)); else diff -r 8b0cfeb06365 -r 12ab7f5fc663 scripts/statistics/distributions/hygernd.m --- a/scripts/statistics/distributions/hygernd.m Wed Oct 10 18:03:02 2007 +0000 +++ b/scripts/statistics/distributions/hygernd.m Wed Oct 10 18:27:07 2007 +0000 @@ -18,18 +18,17 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} hygernd (@var{m}, @var{t}, @var{n}, @var{r}, @var{c}) -## @deftypefnx {Function File} {} hygernd (@var{m}, @var{t}, @var{n}, @var{sz}) +## @deftypefn {Function File} {} hygernd (@var{t}, @var{m}, @var{n}, @var{r}, @var{c}) +## @deftypefnx {Function File} {} hygernd (@var{t}, @var{m}, @var{n}, @var{sz}) ## Return an @var{r} by @var{c} matrix of random samples from the -## hypergeometric distribution with parameters @var{m}, @var{t}, +## hypergeometric distribution with parameters @var{t}, @var{m}, ## and @var{n}. ## -## The parameters @var{m}, @var{t}, and @var{n} must positive integers +## The parameters @var{t}, @var{m}, and @var{n} must positive integers ## with @var{m} and @var{n} not greater than @var{t}. ## @end deftypefn -## function rnd = hygernd (N, m, t, n) -function rnd = hygernd (m, t, n, r, c) +function rnd = hygernd (t, m, n, r, c) if (nargin == 5) if (! (isscalar (r) && (r > 0) && (r == round (r)))) @@ -60,15 +59,15 @@ print_usage (); endif - if (!isscalar (m) || !isscalar (t) || !isscalar (n)) - error ("hygernd: m, t and n must all be positive integers"); + if (!isscalar (t) || !isscalar (m) || !isscalar (n)) + error ("hygernd: t, m and n must all be positive integers"); endif - if ((m < 0) | (t < 0) | (n <= 0) | (m != round (m)) | - (t != round (t)) | (n != round (n)) | (m > t) | (n > t)) + if ((t < 0) | (m < 0) | (n <= 0) | (t != round (t)) | + (m != round (m)) | (n != round (n)) | (m > t) | (n > t)) rnd = NaN * ones (sz) else - rnd = discrete_rnd (0 : n, hygepdf (0 : n, m, t, n), sz); + rnd = discrete_rnd (0 : n, hygepdf (0 : n, t, m, n), sz); endif endfunction