Simple NvsN elo
a guest Feb 9th, 2012 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- -- | Projected result of valuation A vs valuation B, with 1 = sure win
- -- for A, 0 = sure win for B.
- -- This is the core formula of Elo.
- projected :: Double -> Double -> Double
- projected a b = 1 / (1 + exp ( log 10 / e * (b-a) ) )
- where e = 400
- -- | Points to grant the first player for a given result of a 1vs1
- points1vs1 :: Double -> Double -> Double -> Double
- points1vs1 a b d = c * (d - projected a b)
- where c = 4
- -- | 1vs1 result to assume for a player finishing in i-th place vs a
- -- player finishing in j-th place.
- -- It's important that "result i j = 1 - result j i" holds!
- result :: Int -> Int -> Double
- result i j
- | i < j = 1
- | otherwise = 0
- -- | NvsN evaluation. Assumes valuations are sorted by finishing placement.
- pointsNvsN :: [Double] -> [Double]
- pointsNvsN rs =
- [ sum [ points1vs1 a b (result i j)
- | (j, b) <- rps, i /= j]
- | (i, a) <- rps]
- where rps = zip [1..] rs
RAW Paste Data