Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-065

Heteroscedasticity Ratio

Problem

Split data into two halves at n//2 and return the ratio max(var1, var2) / min(var1, var2) of the population variances. Return 0.0 when n < 4 or the smaller variance is zero.

Hint

The ratio is 1 for equal spread and grows with unequal spread.

Test cases

case 1
in: [[1,2,1,10,20,10]]
expected: 99.99999999999999
case 2
in: [[1,2,3,10,20,30]]
expected: 100.00000000000001
case 3
in: [[5,5,5,5]]
expected: 0
case 4
in: [[1,3,1,5,7,5]]
expected: 1
case 5
in: [[2,4,2,4]]
expected: 1
Starter codePython
def heteroscedasticity_ratio(data):
    # Your code here
    pass

5 test cases · run your code against them in the editor