All problems
Pitch Slope
Problem
Return the least-squares slope of pitch values against frame index, ignoring unvoiced frames where the pitch is not positive.
Return 0.0 when fewer than two frames are voiced or the voiced indices have no variance.
Hint
Fit the slope against the original frame indices, skipping zeros.
Test cases
case 1
in: [[100,110,120]]
expected: 10
case 2
in: [[0,0,100]]
expected: 0
case 3
in: [[100,0,120]]
expected: 10
case 4
in: [[]]
expected: 0
case 5
in: [[5,5,5]]
expected: 0
Starter codePython
def pitch_slope(pitches):
# Your code here
pass5 test cases · run your code against them in the editor