comparison scripts/statistics/distributions/cauchy_cdf.m @ 4854:4b0f3b055331

[project @ 2004-04-07 02:37:05 by jwe]
author jwe
date Wed, 07 Apr 2004 02:38:06 +0000
parents 38c61cbf086c
children 4c8a2e4e0717
comparison
equal deleted inserted replaced
4853:66b3cce2bf37 4854:4b0f3b055331
37 if (nargin == 1) 37 if (nargin == 1)
38 location = 0; 38 location = 0;
39 scale = 1; 39 scale = 1;
40 endif 40 endif
41 41
42 [retval, x, location, scale] = common_size (x, location, scale); 42 if (!isscalar (location) || !isscalar (scale))
43 if (retval > 0) 43 [retval, x, location, scale] = common_size (x, location, scale);
44 error ("cauchy_cdf: x, lambda and sigma must be of common size or scalar"); 44 if (retval > 0)
45 error ("cauchy_cdf: x, lambda and sigma must be of common size or scalar");
46 endif
45 endif 47 endif
46 48
47 [r, c] = size (x); 49 sz = size (x);
48 s = r * c; 50 cdf = NaN * ones (sz);
49 x = reshape (x, 1, s);
50 location = reshape (location, 1, s);
51 scale = reshape (scale, 1, s);
52 cdf = NaN * ones (1, s);
53 51
54 k = find ((x > -Inf) & (x < Inf) & (location > -Inf) & 52 k = find ((x > -Inf) & (x < Inf) & (location > -Inf) &
55 (location < Inf) & (scale > 0) & (scale < Inf)); 53 (location < Inf) & (scale > 0) & (scale < Inf));
56 if (any (k)) 54 if (any (k))
57 cdf(k) = 0.5 + atan ((x(k) - location(k)) ./ scale(k)) / pi; 55 if (isscalar (location) && isscalar (scale))
56 cdf(k) = 0.5 + atan ((x(k) - location) ./ scale) / pi;
57 else
58 cdf(k) = 0.5 + atan ((x(k) - location(k)) ./ scale(k)) / pi;
59 endif
58 endif 60 endif
59 61
60 cdf = reshape (cdf, r, c);
61
62 endfunction 62 endfunction