Skip to content
DeepForgeby svx
All problems
HardTime Seriests-220

Diebold-Mariano Statistic

Problem

Compute the Diebold-Mariano statistic comparing two forecast error series. Let d = errors1^2 - errors2^2; return mean(d) / sqrt(population_var(d) / n).

Return 0.0 when there are fewer than two paired errors or the loss differential has zero variance.

Hint

Positive statistics mean forecast 1 has the larger squared errors.

Test cases

case 1
in: [[1,2],[2,1]]
expected: 0
case 2
in: [[1,1],[2,2]]
expected: 0
case 3
in: [[1,1,1],[2,2,2]]
expected: 0
case 4
in: [[1,2,3],[2,1,2]]
expected: 0.8492077756084468
Starter codePython
def diebold_mariano_statistic(errors1, errors2):
    # Your code here
    pass

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