Skip to content

Instantly share code, notes, and snippets.

@mattmazzola
Created November 9, 2020 06:55
Show Gist options
  • Save mattmazzola/b6e6795be92b33ee6468affe60003c30 to your computer and use it in GitHub Desktop.
Save mattmazzola/b6e6795be92b33ee6468affe60003c30 to your computer and use it in GitHub Desktop.
Create Player Probabilities
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