def get_population_fraction(cmd, distribution):
    """
    Given a command like 60+, <10, 50-59, etc, return the fraction of population
    in the given interval.
    """

    total = distribution.sum()
    if cmd.endwith("+"):
        pos = int(cmd[:-1])
        return distribution.loc[pos:].sum() / total
    elif cmd.startswith("<"):
        pos = int(cmd[1:])
        return distribution.loc[:pos].sum() / total
    else:
        a, b = map(int, cmd.split("-"))
        b += 1
        return distribution.loc[a:b].sum() / total