Returns a vector of the rolling mean of a vector calculated for a given window size.
rolling_mean(vec, window = 3)
vec | A vector of numeric values |
---|---|
window | Size of rolling mean to compare against |
Vector of same length as vec
with each element being the mean of
the last window
elements in vec
(including current element).
The rolling mean is calculated using the available data. For elements at
start of the vector before a full window is able to fit, the mean is simply
taken with respect to the available values. E.g. for a window size of 3
the
first element will be the same as the source vector, the second will be the
second elements distance from mean of the first and second elements of the
source vector, and the remaining will be the mean of the element and the
previous two elements.
This is used internally to compute elbow points in entropy calculations
Other helpers:
build_score_fn()
,
combination_indices()
,
get_sweep_pair_counts()
,
get_sweep_results()
,
print.sbm_network()
,
verify_model()
# An increased window size rolled_mean_window_5 <- rolling_mean(my_vec, window = 5) plot(rolled_mean_window_5)