Mercurial > hg > octave-lyh
changeset 7002:12ab7f5fc663
[project @ 2007-10-10 18:27:06 by jwe]
author | jwe |
---|---|
date | Wed, 10 Oct 2007 18:27:07 +0000 |
parents | 8b0cfeb06365 |
children | 2980cb35270c |
files | scripts/ChangeLog scripts/statistics/distributions/hygecdf.m scripts/statistics/distributions/hygeinv.m scripts/statistics/distributions/hygepdf.m scripts/statistics/distributions/hygernd.m |
diffstat | 5 files changed, 46 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,11 @@ +2007-10-10 Arno Onken <asnelt@asnelt.org> + + * 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 <Olli.Saarela@kcl.fi> * control/hinf/hinfsyn.m, control/hinf/wgt1o.m,
--- a/scripts/statistics/distributions/hygecdf.m +++ b/scripts/statistics/distributions/hygecdf.m @@ -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 <Kurt.Hornik@wu-wien.ac.at> ## 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 - -
--- a/scripts/statistics/distributions/hygeinv.m +++ b/scripts/statistics/distributions/hygeinv.m @@ -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 <Kurt.Hornik@wu-wien.ac.at> ## 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
--- a/scripts/statistics/distributions/hygepdf.m +++ b/scripts/statistics/distributions/hygepdf.m @@ -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 <Kurt.Hornik@wu-wien.ac.at> ## 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
--- a/scripts/statistics/distributions/hygernd.m +++ b/scripts/statistics/distributions/hygernd.m @@ -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