Mercurial > octave-nkf
annotate scripts/statistics/distributions/fcdf.m @ 11523:fd0a3ac60b0e
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 14 Jan 2011 05:47:45 -0500 |
parents | 1740012184f9 |
children | c792872f8942 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 1995-2011 Kurt Hornik |
5410 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
5410 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5410 | 18 |
19 ## -*- texinfo -*- | |
5411 | 20 ## @deftypefn {Function File} {} fcdf (@var{x}, @var{m}, @var{n}) |
5410 | 21 ## For each element of @var{x}, compute the CDF at @var{x} of the F |
22 ## distribution with @var{m} and @var{n} degrees of freedom, i.e., | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
23 ## PROB (F (@var{m}, @var{n}) @leq{} @var{x}). |
5410 | 24 ## @end deftypefn |
25 | |
5428 | 26 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
5410 | 27 ## Description: CDF of the F distribution |
28 | |
5411 | 29 function cdf = fcdf (x, m, n) |
5410 | 30 |
31 if (nargin != 3) | |
6046 | 32 print_usage (); |
5410 | 33 endif |
34 | |
35 if (!isscalar (m) || !isscalar (n)) | |
36 [retval, x, m, n] = common_size (x, m, n); | |
37 if (retval > 0) | |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
38 error ("fcdf: X, M and N must be of common size or scalar"); |
5410 | 39 endif |
40 endif | |
41 | |
42 sz = size (x); | |
43 cdf = zeros (sz); | |
44 | |
45 k = find (!(m > 0) | !(n > 0) | isnan (x)); | |
46 if (any (k)) | |
47 cdf(k) = NaN; | |
48 endif | |
49 | |
50 k = find ((x == Inf) & (m > 0) & (n > 0)); | |
51 if (any (k)) | |
52 cdf(k) = 1; | |
53 endif | |
54 | |
55 k = find ((x > 0) & (x < Inf) & (m > 0) & (n > 0)); | |
56 if (any (k)) | |
57 if (isscalar (m) && isscalar (n)) | |
58 cdf(k) = 1 - betainc (1 ./ (1 + m .* x(k) ./ n), n / 2, m / 2); | |
59 else | |
60 cdf(k) = 1 - betainc (1 ./ (1 + m(k) .* x(k) ./ n(k)), n(k) / 2, | |
10549 | 61 m(k) / 2); |
5410 | 62 endif |
63 endif | |
64 | |
65 endfunction |