]> Creatis software - CreaPhase.git/blob - octave_packages/statistics-1.1.3/jsucdf.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / statistics-1.1.3 / jsucdf.m
1 ## Copyright (C) 2006 Frederick (Rick) A Niles <niles@rickniles.com>
2 ##
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
6 ## version.
7 ##
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 ## details.
12 ##
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
15
16 ## -*- texinfo -*-
17 ## @deftypefn {Function File} {} jsucdf (@var{x}, @var{alpha1}, @var{alpha2})
18 ## For each element of @var{x}, compute the cumulative distribution
19 ## function (CDF) at @var{x} of the Johnson SU distribution with shape parameters
20 ## @var{alpha1} and @var{alpha2}.
21 ##
22 ## Default values are @var{alpha1} = 1, @var{alpha2} = 1.
23 ## @end deftypefn
24
25 ## Author: Frederick (Rick) A Niles <niles@rickniles.com>
26 ## Description: CDF of the Johnson SU distribution
27
28 ## This function is derived from normcdf.m
29
30 ## This is the TeX equation of this function:
31 ## 
32 ## \[ F(x) = \Phi\left(\alpha_1 + \alpha_2 
33 ##    \log\left(x + \sqrt{x^2 + 1} \right)\right) \]
34 ## 
35 ## where \[ -\infty < x < \infty ; \alpha_2 > 0 \] and $\Phi$ is the
36 ## standard normal cumulative distribution function.  $\alpha_1$ and
37 ## $\alpha_2$ are shape parameters.
38
39
40 function cdf = jsucdf (x, alpha1, alpha2)
41
42   if (! ((nargin == 1) || (nargin == 3)))
43     print_usage;
44   endif
45
46   if (nargin == 1)
47     m = 0;
48     v = 1;
49   endif
50
51   if (!isscalar (alpha1) || !isscalar(alpha2))
52     [retval, x, alpha1, alpha2] = common_size (x, alpha1, alpha2);
53     if (retval > 0)
54       error ("normcdf: x, alpha1 and alpha2 must be of common size or scalar");
55     endif
56   endif
57
58   one = ones (size (x));
59   cdf = stdnormal_cdf (alpha1 .* one + alpha2 .* log (x + sqrt(x.*x + one)));
60
61 endfunction