Mercurial > hg > octave-nkf
annotate scripts/statistics/distributions/wblcdf.m @ 11472:1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 09 Jan 2011 21:33:04 -0800 |
parents | 9cb5c0b7b43b |
children | fd0a3ac60b0e |
rev | line source |
---|---|
9245 | 1 ## Copyright (C) 1995, 1996, 1997, 2006, 2007, 2009 Kurt Hornik |
5693 | 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. | |
5693 | 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/>. | |
5693 | 18 |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} wblcdf (@var{x}, @var{scale}, @var{shape}) | |
21 ## Compute the cumulative distribution function (CDF) at @var{x} of the | |
11128
9cb5c0b7b43b
Fix reversed documentation for shape and scale parameters in Weibull family of functions.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
22 ## Weibull distribution with scale parameter @var{scale} and shape |
5693 | 23 ## parameter @var{shape}, which is |
6754 | 24 ## @tex |
11128
9cb5c0b7b43b
Fix reversed documentation for shape and scale parameters in Weibull family of functions.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
25 ## $$ 1 - e^{-({x \over scale})^{shape}} $$ |
9cb5c0b7b43b
Fix reversed documentation for shape and scale parameters in Weibull family of functions.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
26 ## for $x \geq 0$. |
6754 | 27 ## @end tex |
28 ## @ifnottex | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
29 ## |
5693 | 30 ## @example |
11128
9cb5c0b7b43b
Fix reversed documentation for shape and scale parameters in Weibull family of functions.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
31 ## 1 - exp(-(x/scale)^shape) |
5693 | 32 ## @end example |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
33 ## |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
34 ## @noindent |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10525
diff
changeset
|
35 ## for @var{x} @geq{} 0. |
6754 | 36 ## @end ifnottex |
5693 | 37 ## @end deftypefn |
38 | |
39 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> | |
40 ## Description: CDF of the Weibull distribution | |
41 | |
42 function cdf = wblcdf (x, scale, shape) | |
43 | |
44 if (nargin < 1 || nargin > 3) | |
6046 | 45 print_usage (); |
5693 | 46 endif |
47 | |
48 if (nargin < 3) | |
49 shape = 1; | |
50 endif | |
51 | |
52 if (nargin < 2) | |
53 scale = 1; | |
54 endif | |
55 | |
56 if (!isscalar (shape) || !isscalar (scale)) | |
57 [retval, x, shape, scale] = common_size (x, shape, scale); | |
58 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:
11128
diff
changeset
|
59 error ("wblcdf: X, SCALE and SHAPE must be of common size or scalar"); |
5693 | 60 endif |
61 endif | |
62 | |
10525
3306cfcb856e
Replace constructs like "NaN * one()" with "NaN()" and "Inf * ones ()" with "Inf()"
David Bateman <dbateman@free.fr>
parents:
9245
diff
changeset
|
63 cdf = NaN (size (x)); |
5693 | 64 |
65 ok = ((shape > 0) & (shape < Inf) & (scale > 0) & (scale < Inf)); | |
66 | |
67 k = find ((x <= 0) & ok); | |
68 if (any (k)) | |
69 cdf(k) = 0; | |
70 endif | |
71 | |
72 k = find ((x > 0) & (x < Inf) & ok); | |
73 if (any (k)) | |
74 if (isscalar (shape) && isscalar (scale)) | |
75 cdf(k) = 1 - exp (- (x(k) / scale) .^ shape); | |
76 else | |
77 cdf(k) = 1 - exp (- (x(k) ./ scale(k)) .^ shape(k)); | |
78 endif | |
79 endif | |
80 | |
81 k = find ((x == Inf) & ok); | |
82 if (any (k)) | |
83 cdf(k) = 1; | |
84 endif | |
85 | |
86 endfunction |