def estimate_mu_sigma(data, single_vals=True):
    """Return an estimate for mu (drift) and sigma (volatility) given a list of historical values."""
    n = len(data)
    diff = data[1:] - data[:-1]
    mus = diff  # samples from the random variable for drift and volatility
    mu_hat = mus.sum() / (n - 1)

    if single_vals:  # We want a single estimate, not a sample distribution.
        sigma_hat = ((diff - mu_hat) ** 2).sum() / (n - 2)
        return mu_hat, sigma_hat
    # We want a sample distribution of mus and sigmas
    sigmas = (n - 1) / (n - 2) * ((diff - mu_hat) ** 2)  # unbiased
    return mus, sigmas