A team plays a run of games and wins game independently with its own probability (home and away, rested or not). Compute the exact distribution of the number of wins, and analyse a best-of series where play stops as soon as one side clinches.
Implement two functions:
poisson_binomial(p) returns a list of floats where entry is .best_of_series(p) takes an odd-length list: game of the series is won with probability , and the series ends when either side reaches wins. Return a tuple (p_win, expected_games): the probability the team wins the series and the expected number of games actually played.poisson_binomial; (odd) for best_of_series. Each .