The basic formula is:
Empirically, this formula correlates fairly well with how baseball teams actually perform, although an exponent of 1.81 is slightly more accurate. This correlation is one justification for using runs as a unit of measurement for player performance. Efforts have been made to find the ideal exponent for the formula, the most widely known being the pythagenport formula (invented by Clay Davenport) 1.5log((r+ra)/g)+.45 and the less well known but equally effective: ((r+ra)/g)^.287, invented by David Smyth.
It is widely believed that deviations from a team's expectations are primarily due to luck and the quality of the team's bullpen and to the situation in the game when runs are scored.