set

tennis_probability.set(games_won_a: int, games_won_b: int, p: float) float

Recursively calculates the probability of player A winning at any state in a set.

This models a set played without a tie-breaker such as in the French Open, where the player needs to win a set with at least a margin of two games. This function calls and uses the game function.

Parameters:
  • games_won_a – The number of games won for player A

  • games_won_b – The number of games won for player B.

  • p – The independent probability of player A winning any given point in a game.

Raises:
  • NegativeNumber – When either score is negative.

  • InvalidInput – When the number of games won for the players is invalid - arguments games_won_a and games_won_b.

  • InvalidProbability – When the probability is invalid - the p argument.

Returns:

The probability of player A winning the set.