Advertisement
Guest User

Simple NvsN elo

a guest
Feb 9th, 2012
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. -- | Projected result of valuation A vs valuation B, with 1 = sure win
  3. -- for A, 0 = sure win for B.
  4. --
  5. -- This is the core formula of Elo.
  6. projected :: Double -> Double -> Double
  7. projected a b = 1 / (1 + exp ( log 10 / e * (b-a) ) )
  8.  where e = 400
  9.  
  10. -- | Points to grant the first player for a given result of a 1vs1
  11. points1vs1 :: Double -> Double -> Double -> Double
  12. points1vs1 a b d = c * (d - projected a b)
  13.  where c = 4
  14.  
  15. -- | 1vs1 result to assume for a player finishing in i-th place vs a
  16. -- player finishing in j-th place.
  17. --
  18. -- It's important that "result i j = 1 - result j i" holds!
  19. result :: Int -> Int -> Double
  20. result i j
  21.   | i < j     = 1
  22.   | otherwise = 0
  23.  
  24. -- | NvsN evaluation. Assumes valuations are sorted by finishing placement.
  25. pointsNvsN :: [Double] -> [Double]
  26. pointsNvsN rs =
  27.   [ sum [ points1vs1 a b (result i j)
  28.         | (j, b) <- rps, i /= j]
  29.   | (i, a) <- rps]
  30.  where rps = zip [1..] rs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement