Skip to content

Instantly share code, notes, and snippets.

@siman-man
Created November 3, 2023 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siman-man/eb4fb559a688563c5f013616b619d76c to your computer and use it in GitHub Desktop.
Save siman-man/eb4fb559a688563c5f013616b619d76c to your computer and use it in GitHub Desktop.
AHC rating calculation
S = 724.4744301
R = 0.8271973364
perfs = DATA.map(&:to_i)
Q = []
perfs.each do |perf|
1.upto(100) do |j|
Q << perf - S * Math.log(j)
end
end
Q.sort_by! { |q| -q }
numerator = (1..100).map { |i| Q[i - 1] * R ** i }.sum
denominator = (1..100).map { |i| R ** i }.sum
r = Rational(numerator, denominator)
if r < 400
r = Rational(400, Math.exp(Rational(400 - r, 400)))
end
pp perfs
puts r.to_f
__END__
1861
1193
2464
1745
1889
2760
2699
2034
2978
1791
2199
3101
2287
2428
1605
2543
2102
2314
2485
3019
2701
1243
2355
2803
@siman-man
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment