def one_sided_ema(xolds, yolds, low=None, high=None, n=<NUM_LIT>, decay_steps=<NUM_LIT:1.>, low_counts_threshold=<NUM_LIT>):
low = xolds[<NUM_LIT:0>] if low is None else low<EOL>high = xolds[-<NUM_LIT:1>] if high is None else high<EOL>assert xolds[<NUM_LIT:0>] <= low, '<STR_LIT>'.format(low, xolds[<NUM_LIT:0>])<EOL>assert xolds[-<NUM_LIT:1>] >= high, '<STR_LIT>'.format(high, xolds[-<NUM_LIT:1>])<EOL>assert len(xolds) == len(yolds), '<STR_LIT>'.format(len(xolds), len(yolds))<EOL>xolds = xolds.astype('<STR_LIT>')<EOL>yolds = yolds.astype('<STR_LIT>')<EOL>luoi = <NUM_LIT:0> <EOL>sum_y = <NUM_LIT:0.><EOL>count_y = <NUM_LIT:0.><EOL>xnews = np.linspace(low, high, n)<EOL>decay_period = (high - low) / (n - <NUM_LIT:1>) * decay_steps<EOL>interstep_decay = np.exp(- <NUM_LIT:1.> / decay_steps)<EOL>sum_ys = np.zeros_like(xnews)<EOL>count_ys = np.zeros_like(xnews)<EOL>for i in range(n):<EOL><INDENT>xnew = xnews[i]<EOL>sum_y *= interstep_decay<EOL>count_y *= interstep_decay<EOL>while True:<EOL><INDENT>xold = xolds[luoi]<EOL>if xold <= xnew:<EOL><INDENT>decay = np.exp(- (xnew - xold) / decay_period)<EOL>sum_y += decay * yolds[luoi]<EOL>count_y += decay<EOL>luoi += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT>if luoi >= len(xolds):<EOL><INDENT>break<EOL><DEDENT><DEDENT>sum_ys[i] = sum_y<EOL>count_ys[i] = count_y<EOL><DEDENT>ys = sum_ys / count_ys<EOL>ys[count_ys < low_counts_threshold] = np.nan<EOL>return xnews, ys, count_ys<EOL>
perform one-sided (causal) EMA (exponential moving average)
smoothing and resampling to an even grid with n points.
Does not do extrapolation, so we assume
xolds[0] <= low && high <= xolds[-1]

Arguments:

xolds: array or list  - x values of data. Needs to be sorted in ascending order
yolds: array of list  - y values of data. Has to have the same length as xolds

low: float            - min value of the new x grid. By default equals to xolds[0]
high: float           - max value of the new x grid. By default equals to xolds[-1]

n: int                - number of points in new x grid

decay_steps: float    - EMA decay factor, expressed in new x grid steps.

low_counts_threshold: float or int
                      - y values with counts less than this value will be set to NaN

Returns:
    tuple sum_ys, count_ys where
        xs        - array with new x grid
        ys        - array of EMA of y at each point of the new x grid
        count_ys  - array of EMA of y counts at each point of the new x grid