5410
|
1 ## Copyright (C) 1997 Kurt Hornik |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
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 |
|
18 ## 02110-1301, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
7002
|
21 ## @deftypefn {Function File} {} hygeinv (@var{x}, @var{t}, @var{m}, @var{n}) |
5410
|
22 ## For each element of @var{x}, compute the quantile at @var{x} of the |
7002
|
23 ## hypergeometric distribution with parameters @var{t}, @var{m}, and |
5410
|
24 ## @var{n}. |
|
25 ## |
7002
|
26 ## The parameters @var{t}, @var{m}, and @var{n} must positive integers |
5410
|
27 ## with @var{m} and @var{n} not greater than @var{t}. |
|
28 ## @end deftypefn |
|
29 |
5428
|
30 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
5410
|
31 ## Description: Random deviates from the hypergeometric distribution |
|
32 |
7002
|
33 function inv = hygeinv (x, t, m, n) |
5410
|
34 |
|
35 if (nargin != 4) |
6046
|
36 print_usage (); |
5410
|
37 endif |
|
38 |
7002
|
39 if (!isscalar (t) || !isscalar (m) || !isscalar (n)) |
|
40 error ("hygeinv: t, m and n must all be positive integers"); |
5410
|
41 endif |
|
42 |
7002
|
43 if ((t < 0) | (m < 0) | (n <= 0) | (t != round (t)) | |
|
44 (m != round (m)) | (n != round (n)) | (m > t) | (n > t)) |
5410
|
45 inv = NaN * ones (size (x)) |
|
46 else |
7002
|
47 inv = discrete_inv (x, 0 : n, hygepdf (0 : n, t, m, n)); |
5410
|
48 endif |
|
49 |
|
50 endfunction |