Mercurial > octave-nkf
comparison scripts/statistics/distributions/nbincdf.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 |
---|---|
43 endif | 43 endif |
44 | 44 |
45 cdf = zeros (size (x)); | 45 cdf = zeros (size (x)); |
46 | 46 |
47 k = find (isnan (x) | (n < 1) | (n == Inf) | (n != round (n)) | 47 k = find (isnan (x) | (n < 1) | (n == Inf) | (n != round (n)) |
48 | (p < 0) | (p > 1)); | 48 | (p < 0) | (p > 1)); |
49 if (any (k)) | 49 if (any (k)) |
50 cdf(k) = NaN; | 50 cdf(k) = NaN; |
51 endif | 51 endif |
52 | 52 |
53 k = find ((x == Inf) & (n > 0) & (n < Inf) & (n == round (n)) | 53 k = find ((x == Inf) & (n > 0) & (n < Inf) & (n == round (n)) |
54 & (p >= 0) & (p <= 1)); | 54 & (p >= 0) & (p <= 1)); |
55 if (any (k)) | 55 if (any (k)) |
56 cdf(k) = 1; | 56 cdf(k) = 1; |
57 endif | 57 endif |
58 | 58 |
59 k = find ((x >= 0) & (x < Inf) & (x == round (x)) & (n > 0) | 59 k = find ((x >= 0) & (x < Inf) & (x == round (x)) & (n > 0) |
60 & (n < Inf) & (n == round (n)) & (p > 0) & (p <= 1)); | 60 & (n < Inf) & (n == round (n)) & (p > 0) & (p <= 1)); |
61 if (any (k)) | 61 if (any (k)) |
62 ## Does anyone know a better way to do the summation? | 62 ## Does anyone know a better way to do the summation? |
63 m = zeros (size (k)); | 63 m = zeros (size (k)); |
64 x = floor (x(k)); | 64 x = floor (x(k)); |
65 y = cdf(k); | 65 y = cdf(k); |
66 if (isscalar (n) && isscalar (p)) | 66 if (isscalar (n) && isscalar (p)) |
67 while (1) | 67 while (1) |
68 l = find (m <= x); | 68 l = find (m <= x); |
69 if (any (l)) | 69 if (any (l)) |
70 y(l) = y(l) + nbinpdf (m(l), n, p); | 70 y(l) = y(l) + nbinpdf (m(l), n, p); |
71 m(l) = m(l) + 1; | 71 m(l) = m(l) + 1; |
72 else | 72 else |
73 break; | 73 break; |
74 endif | 74 endif |
75 endwhile | 75 endwhile |
76 else | 76 else |
77 n = n(k); | 77 n = n(k); |
78 p = p(k); | 78 p = p(k); |
79 while (1) | 79 while (1) |
80 l = find (m <= x); | 80 l = find (m <= x); |
81 if (any (l)) | 81 if (any (l)) |
82 y(l) = y(l) + nbinpdf (m(l), n(l), p(l)); | 82 y(l) = y(l) + nbinpdf (m(l), n(l), p(l)); |
83 m(l) = m(l) + 1; | 83 m(l) = m(l) + 1; |
84 else | 84 else |
85 break; | 85 break; |
86 endif | 86 endif |
87 endwhile | 87 endwhile |
88 endif | 88 endif |
89 cdf(k) = y; | 89 cdf(k) = y; |
90 endif | 90 endif |
91 | 91 |