Mercurial > octave-nkf
comparison scripts/statistics/distributions/nbininv.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 inv = zeros (size (x)); | 46 inv = zeros (size (x)); |
47 | 47 |
48 k = find (isnan (x) | (x < 0) | (x > 1) | (n < 1) | (n == Inf) | 48 k = find (isnan (x) | (x < 0) | (x > 1) | (n < 1) | (n == Inf) |
49 | (n != round (n)) | (p < 0) | (p > 1)); | 49 | (n != round (n)) | (p < 0) | (p > 1)); |
50 if (any (k)) | 50 if (any (k)) |
51 inv(k) = NaN; | 51 inv(k) = NaN; |
52 endif | 52 endif |
53 | 53 |
54 k = find ((x == 1) & (n > 0) & (n < Inf) & (n == round (n)) | 54 k = find ((x == 1) & (n > 0) & (n < Inf) & (n == round (n)) |
55 & (p >= 0) & (p <= 1)); | 55 & (p >= 0) & (p <= 1)); |
56 if (any (k)) | 56 if (any (k)) |
57 inv(k) = Inf; | 57 inv(k) = Inf; |
58 endif | 58 endif |
59 | 59 |
60 k = find ((x >= 0) & (x < 1) & (n > 0) & (n < Inf) | 60 k = find ((x >= 0) & (x < 1) & (n > 0) & (n < Inf) |
61 & (n == round (n)) & (p > 0) & (p <= 1)); | 61 & (n == round (n)) & (p > 0) & (p <= 1)); |
62 if (any (k)) | 62 if (any (k)) |
63 m = zeros (size (k)); | 63 m = zeros (size (k)); |
64 x = x(k); | 64 x = x(k); |
65 if (isscalar (n) && isscalar (p)) | 65 if (isscalar (n) && isscalar (p)) |
66 s = p ^ n * ones (size(k)); | 66 s = p ^ n * ones (size(k)); |
67 while (1) | 67 while (1) |
68 l = find (s < x); | 68 l = find (s < x); |
69 if (any (l)) | 69 if (any (l)) |
70 m(l) = m(l) + 1; | 70 m(l) = m(l) + 1; |
71 s(l) = s(l) + nbinpdf (m(l), n, p); | 71 s(l) = s(l) + nbinpdf (m(l), n, p); |
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 s = p .^ n; | 79 s = p .^ n; |
80 while (1) | 80 while (1) |
81 l = find (s < x); | 81 l = find (s < x); |
82 if (any (l)) | 82 if (any (l)) |
83 m(l) = m(l) + 1; | 83 m(l) = m(l) + 1; |
84 s(l) = s(l) + nbinpdf (m(l), n(l), p(l)); | 84 s(l) = s(l) + nbinpdf (m(l), n(l), p(l)); |
85 else | 85 else |
86 break; | 86 break; |
87 endif | 87 endif |
88 endwhile | 88 endwhile |
89 endif | 89 endif |
90 inv(k) = m; | 90 inv(k) = m; |
91 endif | 91 endif |
92 | 92 |