1 ## Copyright (C) 2006 Frederick (Rick) A Niles <niles@rickniles.com>
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
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
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/>.
17 ## @deftypefn {Function File} {} jsupdf (@var{x}, @var{alpha1}, @var{alpha2})
18 ## For each element of @var{x}, compute the probability density function
19 ## (PDF) at @var{x} of the Johnson SU distribution with shape parameters @var{alpha1}
22 ## Default values are @var{alpha1} = 1, @var{alpha2} = 1.
25 ## Author: Frederick (Rick) A Niles <niles@rickniles.com>
26 ## Description: PDF of Johnson SU distribution
28 ## This function is derived from normpdf.m
30 ## This is the TeX equation of this function:
32 ## \[ f(x) = \frac{\alpha_2}{\sqrt{x^2+1}} \phi\left(\alpha_1+\alpha_2
33 ## \log{\left(x+\sqrt{x^2+1}\right)}\right) \]
35 ## where \[ -\infty < x < \infty ; \alpha_2 > 0 \] and $\phi$ is the
36 ## standard normal probability distribution function. $\alpha_1$ and
37 ## $\alpha_2$ are shape parameters.
39 function pdf = jsupdf (x, alpha1, alpha2)
41 if (nargin != 1 && nargin != 3)
50 if (!isscalar (alpha1) || !isscalar(alpha2))
51 [retval, x, alpha1, alpha2] = common_size (x, alpha1, alpha2);
53 error ("normpdf: x, alpha1 and alpha2 must be of common size or scalars");
58 sr = sqrt(x.*x + one);
59 pdf = (alpha2 ./ sr) .* stdnormal_pdf (alpha1 .* one +
60 alpha2 .* log (x + sr));