Mercurial > octave-nkf
comparison scripts/statistics/distributions/discrete_cdf.m @ 3837:bb3e654d6684
[project @ 2001-06-07 00:24:25 by jwe]
author | jwe |
---|---|
date | Thu, 07 Jun 2001 00:24:25 +0000 |
parents | 434790acb067 |
children | 38c61cbf086c |
comparison
equal
deleted
inserted
replaced
3836:b8c1cb5b9fd9 | 3837:bb3e654d6684 |
---|---|
42 | 42 |
43 n = r * c; | 43 n = r * c; |
44 m = length (v); | 44 m = length (v); |
45 x = reshape (x, n, 1); | 45 x = reshape (x, n, 1); |
46 v = reshape (v, 1, m); | 46 v = reshape (v, 1, m); |
47 P = reshape (P / sum (P), m, 1); | 47 p = reshape (p / sum (p), m, 1); |
48 | 48 |
49 cdf = zeros (n, 1); | 49 cdf = zeros (n, 1); |
50 k = find (isnan (x)); | 50 k = find (isnan (x)); |
51 if (any (k)) | 51 if (any (k)) |
52 cdf (k) = NaN * ones (length (k), 1); | 52 cdf (k) = NaN * ones (length (k), 1); |
53 endif | 53 endif |
54 k = find (!isnan (x)); | 54 k = find (!isnan (x)); |
55 if (any (k)) | 55 if (any (k)) |
56 n = length (k); | 56 n = length (k); |
57 cdf (k) = ((x(k) * ones (1, m)) >= (ones (n, 1) * V)) * P; | 57 cdf (k) = ((x(k) * ones (1, m)) >= (ones (n, 1) * v)) * p; |
58 endif | 58 endif |
59 | 59 |
60 cdf = reshape (cdf, r, c); | 60 cdf = reshape (cdf, r, c); |
61 | 61 |
62 endfunction | 62 endfunction |