Created
November 9, 2020 06:55
-
-
Save mattmazzola/b6e6795be92b33ee6468affe60003c30 to your computer and use it in GitHub Desktop.
Create Player Probabilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ExpectedProbabilitiesFn = (playerARating: number, playerBRating: number) => | |
[ | |
playerAProbability: number, | |
playerBProbability: number, | |
ratingADifference: number, | |
ratingBDifference: number | |
] | |
function createPlayerProbabilitiesFn(exponentBase: number, exponentDenominator: number): ExpectedProbabilitiesFn { | |
const expectedPlayerProbabilityFn = createBaseExpectedPlayerProbabilityFn(exponentBase, exponentDenominator) | |
const expectedPlayerProbability: ExpectedProbabilitiesFn = (playerARating, playerBRating) => { | |
const ratingADifference = playerBRating - playerARating | |
const ratingBDifference = playerARating - playerBRating | |
const playerAProbability = expectedPlayerProbabilityFn(ratingADifference) | |
const playerBProbability = expectedPlayerProbabilityFn(ratingBDifference) | |
return [ | |
playerAProbability, | |
playerBProbability, | |
ratingADifference, | |
ratingBDifference, | |
] | |
} | |
return expectedPlayerProbability | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment