annotate scripts/statistics/distributions/cauchy_inv.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 c776f063fefe
children fd0a3ac60b0e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
1 ## Copyright (C) 1995, 1996, 1997, 1998, 2000, 2002, 2004, 2005, 2006,
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
2 ## 2007 Kurt Hornik
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
3 ##
3922
38c61cbf086c [project @ 2002-05-01 06:48:35 by jwe]
jwe
parents: 3456
diff changeset
4 ## This file is part of Octave.
38c61cbf086c [project @ 2002-05-01 06:48:35 by jwe]
jwe
parents: 3456
diff changeset
5 ##
38c61cbf086c [project @ 2002-05-01 06:48:35 by jwe]
jwe
parents: 3456
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
38c61cbf086c [project @ 2002-05-01 06:48:35 by jwe]
jwe
parents: 3456
diff changeset
7 ## 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: 6046
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
9 ## your option) any later version.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
10 ##
3922
38c61cbf086c [project @ 2002-05-01 06:48:35 by jwe]
jwe
parents: 3456
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
14 ## General Public License for more details.
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
15 ##
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
16 ## 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: 6046
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
18 ## <http://www.gnu.org/licenses/>.
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
19
3456
434790acb067 [project @ 2000-01-19 06:58:51 by jwe]
jwe
parents: 3426
diff changeset
20 ## -*- texinfo -*-
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 10525
diff changeset
21 ## @deftypefn {Function File} {} cauchy_inv (@var{x}, @var{location}, @var{scale})
3456
434790acb067 [project @ 2000-01-19 06:58:51 by jwe]
jwe
parents: 3426
diff changeset
22 ## For each element of @var{x}, compute the quantile (the inverse of the
434790acb067 [project @ 2000-01-19 06:58:51 by jwe]
jwe
parents: 3426
diff changeset
23 ## CDF) at @var{x} of the Cauchy distribution with location parameter
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 10525
diff changeset
24 ## @var{location} and scale parameter @var{scale}. Default values are
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 10525
diff changeset
25 ## @var{location} = 0, @var{scale} = 1.
3456
434790acb067 [project @ 2000-01-19 06:58:51 by jwe]
jwe
parents: 3426
diff changeset
26 ## @end deftypefn
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
27
5428
2a16423e4aa0 [project @ 2005-08-23 18:38:27 by jwe]
jwe
parents: 5307
diff changeset
28 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
3456
434790acb067 [project @ 2000-01-19 06:58:51 by jwe]
jwe
parents: 3426
diff changeset
29 ## Description: Quantile function of the Cauchy distribution
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
30
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
31 function inv = cauchy_inv (x, location, scale)
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
32
3456
434790acb067 [project @ 2000-01-19 06:58:51 by jwe]
jwe
parents: 3426
diff changeset
33 if (! (nargin == 1 || nargin == 3))
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5428
diff changeset
34 print_usage ();
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
35 endif
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
36
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
37 if (nargin == 1)
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
38 location = 0;
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
39 scale = 1;
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
40 endif
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
41
4854
4b0f3b055331 [project @ 2004-04-07 02:37:05 by jwe]
jwe
parents: 3922
diff changeset
42 if (!isscalar (location) || !isscalar (scale))
4b0f3b055331 [project @ 2004-04-07 02:37:05 by jwe]
jwe
parents: 3922
diff changeset
43 [retval, x, location, scale] = common_size (x, location, scale);
4b0f3b055331 [project @ 2004-04-07 02:37:05 by jwe]
jwe
parents: 3922
diff changeset
44 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: 11469
diff changeset
45 error ("cauchy_inv: X, LOCATION and SCALE must be of common size or scalar");
4854
4b0f3b055331 [project @ 2004-04-07 02:37:05 by jwe]
jwe
parents: 3922
diff changeset
46 endif
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
47 endif
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
48
4854
4b0f3b055331 [project @ 2004-04-07 02:37:05 by jwe]
jwe
parents: 3922
diff changeset
49 sz = size (x);
10525
3306cfcb856e Replace constructs like "NaN * one()" with "NaN()" and "Inf * ones ()" with "Inf()"
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
50 inv = NaN (sz);
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
51
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
52 ok = ((location > -Inf) & (location < Inf) &
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
53 (scale > 0) & (scale < Inf));
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
54
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
55 k = find ((x == 0) & ok);
3456
434790acb067 [project @ 2000-01-19 06:58:51 by jwe]
jwe
parents: 3426
diff changeset
56 if (any (k))
4854
4b0f3b055331 [project @ 2004-04-07 02:37:05 by jwe]
jwe
parents: 3922
diff changeset
57 inv(k) = -Inf;
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
58 endif
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
59
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
60 k = find ((x > 0) & (x < 1) & ok);
3456
434790acb067 [project @ 2000-01-19 06:58:51 by jwe]
jwe
parents: 3426
diff changeset
61 if (any (k))
4854
4b0f3b055331 [project @ 2004-04-07 02:37:05 by jwe]
jwe
parents: 3922
diff changeset
62 if (isscalar (location) && isscalar (scale))
4b0f3b055331 [project @ 2004-04-07 02:37:05 by jwe]
jwe
parents: 3922
diff changeset
63 inv(k) = location - scale .* cot (pi * x(k));
4b0f3b055331 [project @ 2004-04-07 02:37:05 by jwe]
jwe
parents: 3922
diff changeset
64 else
4b0f3b055331 [project @ 2004-04-07 02:37:05 by jwe]
jwe
parents: 3922
diff changeset
65 inv(k) = location(k) - scale(k) .* cot (pi * x(k));
4b0f3b055331 [project @ 2004-04-07 02:37:05 by jwe]
jwe
parents: 3922
diff changeset
66 endif
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
67 endif
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
68
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
69 k = find ((x == 1) & ok);
3456
434790acb067 [project @ 2000-01-19 06:58:51 by jwe]
jwe
parents: 3426
diff changeset
70 if (any (k))
4854
4b0f3b055331 [project @ 2004-04-07 02:37:05 by jwe]
jwe
parents: 3922
diff changeset
71 inv(k) = Inf;
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
72 endif
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3191
diff changeset
73
3191
e4f4b2d26ee9 [project @ 1998-10-23 05:43:59 by jwe]
jwe
parents:
diff changeset
74 endfunction