Returns normalized cumulative distribution from discrete distribution.
(distribution)
| 128 | |
| 129 | |
| 130 | def cumulative_distribution(distribution): |
| 131 | """Returns normalized cumulative distribution from discrete distribution.""" |
| 132 | |
| 133 | cdf = [0.0] |
| 134 | cumulative = 0.0 |
| 135 | for element in distribution: |
| 136 | cumulative += element |
| 137 | cdf.append(cumulative) |
| 138 | return [element / cumulative for element in cdf] |
| 139 | |
| 140 | |
| 141 | @py_random_state(3) |
no test coverage detected
searching dependent graphs…