annotate scripts/statistics/distributions/wblcdf.m @ 10821:693e22af08ae

Grammarcheck documentation of m-files Add newlines between @item fields for readability.
author Rik <octave@nomad.inbox5.com>
date Mon, 26 Jul 2010 21:25:36 -0700
parents be55736a0783
children a4f482e66b65
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9245
16f53d29049f update copyright notices
John W. Eaton <jwe@octave.org>
parents: 9211
diff changeset
1 ## Copyright (C) 1995, 1996, 1997, 2006, 2007, 2009 Kurt Hornik
5693
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
2 ##
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
4 ##
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6754
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6754
diff changeset
8 ## your option) any later version.
5693
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
9 ##
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
14 ##
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6754
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6754
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5693
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
18
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
20 ## @deftypefn {Function File} {} wblcdf (@var{x}, @var{scale}, @var{shape})
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
21 ## Compute the cumulative distribution function (CDF) at @var{x} of the
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
22 ## Weibull distribution with shape parameter @var{scale} and scale
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
23 ## parameter @var{shape}, which is
6754
451b346d8c2f [project @ 2007-06-25 17:31:46 by jwe]
jwe
parents: 6046
diff changeset
24 ## @tex
451b346d8c2f [project @ 2007-06-25 17:31:46 by jwe]
jwe
parents: 6046
diff changeset
25 ## $$ 1 - \exp(-(x/shape)^{scale}) $$
451b346d8c2f [project @ 2007-06-25 17:31:46 by jwe]
jwe
parents: 6046
diff changeset
26 ## for $x\geq 0$.
451b346d8c2f [project @ 2007-06-25 17:31:46 by jwe]
jwe
parents: 6046
diff changeset
27 ## @end tex
451b346d8c2f [project @ 2007-06-25 17:31:46 by jwe]
jwe
parents: 6046
diff changeset
28 ## @ifnottex
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
29 ##
5693
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
30 ## @example
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
31 ## 1 - exp(-(x/shape)^scale)
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
32 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
33 ##
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10525
diff changeset
34 ## for @var{x} @geq{} 0.
6754
451b346d8c2f [project @ 2007-06-25 17:31:46 by jwe]
jwe
parents: 6046
diff changeset
35 ## @end ifnottex
5693
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
36 ## @end deftypefn
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
37
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
38 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
39 ## Description: CDF of the Weibull distribution
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
40
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
41 function cdf = wblcdf (x, scale, shape)
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
42
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
43 if (nargin < 1 || nargin > 3)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5693
diff changeset
44 print_usage ();
5693
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
45 endif
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
46
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
47 if (nargin < 3)
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
48 shape = 1;
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
49 endif
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
50
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
51 if (nargin < 2)
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
52 scale = 1;
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
53 endif
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
54
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
55 if (!isscalar (shape) || !isscalar (scale))
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
56 [retval, x, shape, scale] = common_size (x, shape, scale);
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
57 if (retval > 0)
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
58 error ("wblcdf: x, scale and shape must be of common size or scalar");
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
59 endif
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
60 endif
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
61
10525
3306cfcb856e Replace constructs like "NaN * one()" with "NaN()" and "Inf * ones ()" with "Inf()"
David Bateman <dbateman@free.fr>
parents: 9245
diff changeset
62 cdf = NaN (size (x));
5693
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
63
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
64 ok = ((shape > 0) & (shape < Inf) & (scale > 0) & (scale < Inf));
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
65
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
66 k = find ((x <= 0) & ok);
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
67 if (any (k))
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
68 cdf(k) = 0;
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
69 endif
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
70
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
71 k = find ((x > 0) & (x < Inf) & ok);
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
72 if (any (k))
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
73 if (isscalar (shape) && isscalar (scale))
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
74 cdf(k) = 1 - exp (- (x(k) / scale) .^ shape);
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
75 else
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
76 cdf(k) = 1 - exp (- (x(k) ./ scale(k)) .^ shape(k));
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
77 endif
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
78 endif
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
79
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
80 k = find ((x == Inf) & ok);
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
81 if (any (k))
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
82 cdf(k) = 1;
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
83 endif
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
84
446b28529300 [project @ 2006-03-17 18:16:03 by jwe]
jwe
parents:
diff changeset
85 endfunction