Given two functions y1(t) and y2(t), this function finds the L2-distance between the following two curves:
a) y1(t)-y2(t) sampled at all time points (tp
)
b) y1(t)-y2(t) sampled at the time points indexed by index
(tp[index]
).
Note that by setting y2
to rep(0,length(tp))
, this function can be used to estimate the L2-error in the shape of y1
.
L2(tp, y1, y2, start, stop, index, numSubdivisions = 2000)
A numerical vector of time points (or spatial coordinates along a single axis)
A numerical vector of measurements (of the control)
A numerical vector of measurements (of the experimental condition)
A numerical value representing the start time (or spatial coordinate) of the integration
A numerical value representing the end time (or spatial coordinate) of the integration
A vector of positive integers representing the indices of tp
that we subsample
This can be adjusted to ensure the integration doesn't take too long, especially if we aren't overly concerned with rounding errors.
A numeric value-- the L2 error.