Solved

calculate ELO

Posted on 2007-11-15
11
833 Views
Last Modified: 2012-05-05
function k_elo($e)
{
  $eh=2400;$el=2000;
  $kh=16;$kl=32;

  if($e<$el)return $kl;
  if($e>$eh)return $kh;
  return ($eh-$e)*($kl-$kh)/($eh-$el)+$kh;
}
function calcELO(&$n1,&$n2,$won1,$canTie)
{
  $e1=$n1;
  $e2=$n2;
  $ea=1/(1+(float)pow(10,($e2-$e1)/400));
  $eb=1-$ea;

  $k1=k_elo($e1);
  $k2=k_elo($e2);
  if($won1==2)$sa=1;   //won
  if($won1==1)$sa=0.5; //even
  if($won1==0)$sa=0;   //lost
  $sb=1-$sa;

  $n1=round($e1+$k1*($sa-$ea),3);
  $n2=round($e2+$k2*($sb-$eb),3);
}

script above supposed to calculate ELO.
but it doesn't take information on previous games played !
how does one do that ?
0
Comment
Question by:ed987
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 170 total points
ID: 20294736
That information is in the the players previous Elo ratings in $n1 and $n2
0
 
LVL 25

Assisted Solution

by:imitchie
imitchie earned 165 total points
ID: 20297317
elo rating (for chess at least) is supposed to be counted against multiple games at once. the algo you have shown is only for 2 specific players for ONE single game..... it looks like a very poor shadow of elo calculating if you ask me.

but yeah, $n1 is the current rating of p1, $n2 is p2. the expected result (Based on ONE single game?!) is calculated between p1 and p2 as $ea and $eb (which must equal one).  the rest you can probably figure out.

previous games are already taken into account since (in the case of this algo), p1 and p2 are carrying ELO ratings as a result of many many previous games
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20297326
normally a calc-elo would involve:
  startingElo, avgOpponentsElo, totalGamesPlayed, actualResult, i.e. 4.5 for (3 wins + 3 draws)
google has more info
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 84

Expert Comment

by:ozo
ID: 20297577
counting Elo ratings one single game at a time can be better than taking avgOpponentsElo for multiple games
A 1500 player might be expected win more games on average playing one 2800 player and one 1000 player than playing against two 1900 players
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20297655
your extreme example is not real life, so i won't comment too much on it.  find me a tournament keeping elo ratings that has that situation, and let's discuss this again.  the elo rating has limitations, but it works better to adjust once per 10-swiss-round tournament of "like minds" (not master vs novice) than 10 individual times.  why don't you check with professional organisations before you comment
0
 
LVL 25

Assisted Solution

by:InteractiveMind
InteractiveMind earned 165 total points
ID: 20299190
imitchie, was ozo wrong? Or are you getting pissy with him _just_ because he considered the problem from a theoretical standpoint? (Keeping in mind, this thread is also in the Math & Science TA).
0
 
LVL 84

Expert Comment

by:ozo
ID: 20303545
It's also true that a 2015 player might be expected win more games on average playing one 2028 player and one 2010 player than playing two 2019  players, although the effect is more subtle.
An extreme example makes the effect more intuitively obvious and takes fewer games to be noticeable above the expected variation in expected wins.

The question was about how the given program worked, but how actual tournaments are conducted or how that may have been influenced by how simplifications in practical computations differ from Elo's theoretical model or how simplifications in his theoretical model differ from a more accurate model may also be interesting topics if the author wishes to ask about them as well.
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20303890
ozo - I believe that's exactly the point you're missing. given the maths behind the ELO model, a 2015 player is expected to win EXACTLY AS MANY games against 2028 + 2010 as he is playing two 2019 players.  You have to realise that 13 ELO points do not a better player make.  a quick check for the latest real life games will reveal that to be true.  they are considered statistically equivalent in the sense of sitting down and actually playing a game.  the cutoff is 400 because at that range (and practically anywhere close), the difference is clear cut, assuming the current ELO rating of both players are _established_ by many prior (recent) games.
0
 
LVL 84

Expert Comment

by:ozo
ID: 20310158
It's not a cutoff, it's an inflection point, which is why the more extreme example illiustrates the point better
it would take about 22000 games for the difference between 2150 vs 2280+2100 and 2150 vs 2190+2190 to be as significant as the effect of difference between 1500 vs 2800+1000 and 1500 vs 1900+1900 is in two games.
That's given the Elo model, which is itself a simplification of a more accurate model where each player has their own individual  inflection point reflecting how well established by prior games their own individual rating is.
0
 
LVL 7

Author Comment

by:ed987
ID: 20340499
i believe script i gave in my question does not work properly.

any possibility someone could post a correct implementation ?
c++ or php or asp or pascal or ... pseudocode.

thnx
0
 
LVL 84

Expert Comment

by:ozo
ID: 20341519
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever thought of installing a power system that generates solar electricity to power your house? Some may say yes, while others may tell me no. But have you noticed that people around you are now considering installing such systems in their …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question