def ewm_weights(i, com=None, span=None, halflife=None, alpha=None):
    """Exponential weights as a function of position `i`.

    Mimics pandas' methodology with adjust=True:
    http://pandas.pydata.org/pandas-docs/stable/computation.html#exponentially-weighted-windows
    """

    if not any((com, span, halflife, alpha)):
        raise ValueError("specify one of `com`, `span`, `halflife`, `alpha`")

    params = [com, span, halflife, alpha]
    pos = next(i for (i, x) in enumerate(params) if x)
    param_value = next(item for item in params if item is not None)
    lookup = dict(enumerate(["com", "span", "halflife", "alpha"]))
    param = lookup[pos]
    alpha = ewm_params(param=param, param_value=param_value)["alpha"]

    res = (1.0 - alpha) ** np.arange(i)[::-1]
    res /= res.sum()
    return res