#### pvSubset ####
set.seed(12)
x = BridgeT(rnorm(1000))
pv = pvar(x, 2)
pvSubset = PvarSubset(pv, 200, 800)
pvSmall = pvar(x[200:800], 2)
pvSubset == pvSmall
op = par(mfrow = c(2, 1))
plot(pvSubset)
plot(pvSmall, xlim=range(pvSmall$TimeLabel), ylim=range(pvSmall$x))
par(op)
#### MergePvar ####
set.seed(13)
x = BridgeT(rnorm(1000))
S = Split_MinMax(x)
pv = pvar(x, 2)
pv1 = pvar(x[1:S[2]], 2)
pv2 = pvar(x[S[2]:length(x)], 2)
pvJ = MergePvar(pv1, pv2)
pvJ == pv # since joint point is extremum, we get the correct value
op = par(mfrow = c(2, 1))
plot(pv)
plot(pvJ, xlim=range(pv$TimeLabel), ylim=range(pv$x))
par(op)
# on the other hand if we take other points we usually do not get correct value
pvJ = MergePvar(pvar(x[1:500], 2), pvar(x[500:length(x)], 2))
pvJ == pv
Run the code above in your browser using DataLab