meridian.model.knots.l1_distance_weights

Computes weights at knots for every time period.

The two neighboring knots inform the weight estimate of a particular time period. The amount each of the two neighboring knots inform the weight at a time period depends on how close (L1 distance) they are to the time period. If a time point coincides with a knot location, then 100% weight is given to that knot. If a time point lies outside the range of knots, then 100% weight is given to the nearest endpoint knot.

This function computes an (n_knots, n_times) array of weights that are used to model trend and seasonality. For a given time, the array contains two non-zero weights. The weights are inversely proportional to the L1 distance from the given time to the neighboring knots. The two weights are normalized such that they sum to 1.

n_times The number of time points.
knot_locations The location of knots within 0, 1, 2,..., (n_times-1).

A weight array with dimensions (n_knots, n_times) with values summing up to 1 for each time period when summing over knots.