Learn R Programming

Sabermetrics (version 2.0)

pyth: Pythagorean Expectation

Description

Pythagorean expectation portrays what a team's winning percentage "should" be given it's runs scored and allowed.

Usage

pyth(rs, ra, alpha = 2)

Arguments

rs
Runs Scored
ra
Runs Allowed
alpha
Exponent to use

Value

Returns a value equal to (rs^alpha)/(rs^alpha + ra^alpha)

Details

2 and 1.83 are the most common exponents used. 1.83 is the exponent baseball-reference uses in its calculations.

References

http://www.fangraphs.com/library/principles/expected-wins-and-losses/ https://en.wikipedia.org/wiki/Pythagorean_expectation

See Also

log5

Examples

Run this code
## Let's calculate the Angels 2014 Pythagorean Expectation
## The Angels had 773 Runs Scored and 630 Runs Allowed
## We should get an output close to .600
pyth(773,630,2)

## The function is currently defined as
function (rs, ra, alpha = 2) 
{
    pyth <- (rs^alpha)/(rs^alpha + ra^alpha)
    return(pyth)
  }

Run the code above in your browser using DataLab