For each position i, averages a[j] weighted by
weights[j] over every later position (tda_mwvec:
every j > i; tda_mwvec1: every j with
t[j] > t[i], letting an arbitrary order vector t
stand in for position – tda_mwvec is the special case
t = seq_along(a)) – TDA's mwvec/mwvec1.
Falls back to a[i] unchanged wherever the weights beyond
i sum to zero (including the last position, which always
has nothing after it). No base-R builtin matches this directly.
See also
Other matrix algebra:
tda_mcel(),
tda_mcent(),
tda_mch(),
tda_mcross(),
tda_mdiag(),
tda_mev(),
tda_mevs(),
tda_midf(),
tda_midf1(),
tda_midf2(),
tda_midf3(),
tda_minvs(),
tda_mkmet(),
tda_mkp(),
tda_mmul(),
tda_mnc(),
tda_mnrow(),
tda_mpbl(),
tda_mpfit(),
tda_mpinv(),
tda_mpit(),
tda_mple(),
tda_mpz(),
tda_mscal1(),
tda_msqrtd(),
tda_msvd()
Examples
a <- c(10, 20, 30, 40)
w <- c(1, 1, 1, 1)
# position 1 averages 20, 30, 40; position 3 averages 40 alone;
# the last position has nothing after it and keeps its own value
tda_mwvec(a, w)
#> [1] 30 35 40 40
# with an order vector, "later" means a larger t: positions 1 and 2
# share t = 1, so both average the values at t = 2 and t = 3
tda_mwvec1(a, w, t = c(1, 1, 2, 3))
#> [1] 35 35 40 40