comparison scripts/statistics/distributions/nbinpdf.m @ 10549:95c3e38098bf

Untabify .m scripts
author Rik <code@nomad.inbox5.com>
date Fri, 23 Apr 2010 11:28:50 -0700
parents a1dbe9d80eee
children 1740012184f9
comparison
equal deleted inserted replaced
10548:479536c5bb10 10549:95c3e38098bf
44 endif 44 endif
45 45
46 pdf = zeros (size (x)); 46 pdf = zeros (size (x));
47 47
48 k = find (isnan (x) | (n < 1) | (n == Inf) | (n != round (n)) 48 k = find (isnan (x) | (n < 1) | (n == Inf) | (n != round (n))
49 | (p < 0) | (p > 1)); 49 | (p < 0) | (p > 1));
50 if (any (k)) 50 if (any (k))
51 pdf(k) = NaN; 51 pdf(k) = NaN;
52 endif 52 endif
53 53
54 ## Just for the fun of it ... 54 ## Just for the fun of it ...
55 k = find ((x == Inf) & (n > 0) & (n < Inf) & (n == round (n)) 55 k = find ((x == Inf) & (n > 0) & (n < Inf) & (n == round (n))
56 & (p == 0)); 56 & (p == 0));
57 if (any (k)) 57 if (any (k))
58 pdf(k) = 1; 58 pdf(k) = 1;
59 endif 59 endif
60 60
61 k = find ((x >= 0) & (x < Inf) & (x == round (x)) & (n > 0) 61 k = find ((x >= 0) & (x < Inf) & (x == round (x)) & (n > 0)
62 & (n < Inf) & (n == round (n)) & (p > 0) & (p <= 1)); 62 & (n < Inf) & (n == round (n)) & (p > 0) & (p <= 1));
63 if (any (k)) 63 if (any (k))
64 if (isscalar (n) && isscalar (p)) 64 if (isscalar (n) && isscalar (p))
65 pdf(k) = bincoeff (-n, x(k)) .* (p ^ n) .* ((p - 1) .^ x(k)); 65 pdf(k) = bincoeff (-n, x(k)) .* (p ^ n) .* ((p - 1) .^ x(k));
66 else 66 else
67 pdf(k) = bincoeff (-n(k), x(k)) .* (p(k) .^ n(k)) .* ((p(k) - 1) .^ x(k)); 67 pdf(k) = bincoeff (-n(k), x(k)) .* (p(k) .^ n(k)) .* ((p(k) - 1) .^ x(k));