def addTeam(self, team, this_team, rest_of_league): this_x_cdf = tb.MakeCdfFromPmf(tb.MakePmfFromList(this_team.X_unadj)) this_y_cdf = tb.MakeCdfFromPmf(tb.MakePmfFromList(this_team.Y_unadj)) other_x_cdf = tb.MakeCdfFromPmf( tb.MakePmfFromList(rest_of_league.X_unadj)) other_y_cdf = tb.MakeCdfFromPmf( tb.MakePmfFromList(rest_of_league.Y_unadj)) self.addCDFs(team, this_x_cdf, this_y_cdf, other_x_cdf, other_y_cdf)
def euro(): if request.method == "GET": pmf = tb.MakePmfFromList(list(range(1, 101))) return packagedpmf(pmf) else: pmf, update = unpacksuiteupdate(request.get_json()) euro = Euro(pmf) euro.Update(update) return packagedpmf(euro)
def dice(): if request.method == "GET": pmf = tb.MakePmfFromList([4, 6, 8, 12, 20]) return packagedpmf(pmf) else: pmf, update = unpacksuiteupdate(request.get_json()) update = int(update) dice = Dice(pmf) dice.Update(update) return packagedpmf(dice)
def __init__(self, pmf=None, p=None, label=None): self.p = p if p else random() if not pmf: pmf = tb.MakePmfFromList(list(range(101))) tb.Suite.__init__(self, pmf, label=label)
def means(): req = request.get_json()["pmfs"] pmfs = [tb.MakePmfFromList(pmf) for pmf in req] return json.jsonify({"means": [pmf.Mean() for pmf in pmfs]})