(observed, total, p)
| 173 | |
| 174 | // Probability of at least `observed` successes in `total` trials with success rate p. |
| 175 | export function binomialTail(observed, total, p) { |
| 176 | let probability = (1 - p) ** total; |
| 177 | let tail = 0; |
| 178 | for (let k = 0; k <= total; k++) { |
| 179 | if (k >= observed) { |
| 180 | tail += probability; |
| 181 | } |
| 182 | probability *= ((total - k) / (k + 1)) * (p / (1 - p)); |
| 183 | } |
| 184 | return Math.min(1, tail); |
| 185 | } |
| 186 | |
| 187 | export function compare(samples, metric, options = {}) { |
| 188 | if (!samples.length) { |
no outgoing calls
no test coverage detected