All problems
k-out-of-n Reliability
Problem
Reliability of a k-out-of-n system of identical components, each working independently with probability r:
R = sum from i = k to n of C(n, i) * r^i * (1 - r)^(n - i).
Return 0.0 for invalid parameters.
Hint
The number of working components is Binomial(n, r); sum the upper tail.
Test cases
case 1
in: [3,2,0.9]
expected: 0.9720000000000001
case 2
in: [3,1,0.5]
expected: 0.875
case 3
in: [1,1,0.3]
expected: 0.3
case 4
in: [3,4,0.5]
expected: 0
case 5
in: [2,0,0.4]
expected: 1
Starter codePython
import math
def k_out_of_n_reliability(n, k, r):
# Your code here
pass5 test cases · run your code against them in the editor