All problems
Bland-Altman Limits of Agreement
Problem
Return the limits of agreement [mean(d) - z*sd(d), mean(d) + z*sd(d)] for paired measurements d = a - b, using the sample standard deviation. Return [0.0, 0.0] when fewer than two pairs are given or lengths differ, and [mean(d), mean(d)] when all differences are equal.
Hint
Most differences should fall between the two limits.
Test cases
case 1
in: [[10,12,14],[9,11,13],1.96]
expected: [1,1]
case 2
in: [[10,12,14,16],[9,11,14,15],1.96]
expected: [-0.22999999999999998,1.73]
case 3
in: [[5,6,7],[4,6,8],1.645]
expected: [-1.645,1.645]
case 4
in: [[1],[2],1.96]
expected: [0,0]
case 5
in: [[],[],1.96]
expected: [0,0]
Starter codePython
def bland_altman_limits(a, b, z_crit):
# Your code here
pass5 test cases · run your code against them in the editor