# Demo entry 3609380

**ERR Algorithm**

Submitted by **Marc Leef**
on Feb 13, 2016 at 21:42

Language: Python. Code size: 649 Bytes.

#!/usr/bin/python # Marc Leef # COS 435 # Implementation of ERR algorithm # List of scores scores = [2, 0, 0, 1, 2, 0, 0, 0, 1, 1] # Number of scores N = 10 # Max score (range is 0, 1, 2) MAX = 2.0 # To compute R function def R(score): return (1.0/2**MAX) * ((2**score) - 1) # To compute Expected Reciprocal Rank def ERR(scores): sum = 0 # From 1 to N (inclusive) for j in range(1, N + 1): product = 1 # From 1 to j - 1 (inclusive) for k in range(1, j): product *= (1.0 - R(scores[k - 1])) sum += ((1.0/j) * product * R(scores[j - 1])) return sum # Run algorithm print(ERR(scores))

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.