comparison scripts/statistics/distributions/cauchy_pdf.m @ 11587:c792872f8942

all script files: untabify and strip trailing whitespace
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:35:29 -0500
parents fd0a3ac60b0e
children 19b9f17d22af
comparison
equal deleted inserted replaced
11586:12df7854fa7c 11587:c792872f8942
19 ## -*- texinfo -*- 19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} cauchy_pdf (@var{x}, @var{location}, @var{scale}) 20 ## @deftypefn {Function File} {} cauchy_pdf (@var{x}, @var{location}, @var{scale})
21 ## For each element of @var{x}, compute the probability density function 21 ## For each element of @var{x}, compute the probability density function
22 ## (PDF) at @var{x} of the Cauchy distribution with location parameter 22 ## (PDF) at @var{x} of the Cauchy distribution with location parameter
23 ## @var{location} and scale parameter @var{scale} > 0. Default values are 23 ## @var{location} and scale parameter @var{scale} > 0. Default values are
24 ## @var{location} = 0, @var{scale} = 1. 24 ## @var{location} = 0, @var{scale} = 1.
25 ## @end deftypefn 25 ## @end deftypefn
26 26
27 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> 27 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
28 ## Description: PDF of the Cauchy distribution 28 ## Description: PDF of the Cauchy distribution
29 29
36 if (nargin == 1) 36 if (nargin == 1)
37 location = 0; 37 location = 0;
38 scale = 1; 38 scale = 1;
39 endif 39 endif
40 40
41 if (!isscalar (location) || !isscalar (scale)) 41 if (!isscalar (location) || !isscalar (scale))
42 [retval, x, location, scale] = common_size (x, location, scale); 42 [retval, x, location, scale] = common_size (x, location, scale);
43 if (retval > 0) 43 if (retval > 0)
44 error ("cauchy_pdf: X, LOCATION and SCALE must be of common size or scalar"); 44 error ("cauchy_pdf: X, LOCATION and SCALE must be of common size or scalar");
45 endif 45 endif
46 endif 46 endif
49 pdf = NaN (sz); 49 pdf = NaN (sz);
50 50
51 k = find ((x > -Inf) & (x < Inf) & (location > -Inf) & 51 k = find ((x > -Inf) & (x < Inf) & (location > -Inf) &
52 (location < Inf) & (scale > 0) & (scale < Inf)); 52 (location < Inf) & (scale > 0) & (scale < Inf));
53 if (any (k)) 53 if (any (k))
54 if (isscalar (location) && isscalar (scale)) 54 if (isscalar (location) && isscalar (scale))
55 pdf(k) = ((1 ./ (1 + ((x(k) - location) ./ scale) .^ 2)) 55 pdf(k) = ((1 ./ (1 + ((x(k) - location) ./ scale) .^ 2))
56 / pi ./ scale); 56 / pi ./ scale);
57 else 57 else
58 pdf(k) = ((1 ./ (1 + ((x(k) - location(k)) ./ scale(k)) .^ 2)) 58 pdf(k) = ((1 ./ (1 + ((x(k) - location(k)) ./ scale(k)) .^ 2))
59 / pi ./ scale(k)); 59 / pi ./ scale(k));