Description Usage Arguments Details Value Author(s) Examples
This function calculates the cost matrix for the segmentation model
1 | costMatrix(x, maxk)
|
x |
Numeric vector of length |
maxk |
Positive integer. |
See the package vignette Calculation of the cost matrix.
Matrix with maxk
rows and length(x)
columns.
W. Huber
1 2 3 4 5 6 7 8 9 10 11 12 13 | d = 4
x = apply(matrix(rnorm(200), ncol=d), 2, cumsum)
maxk = 50
G = costMatrix(x, maxk=maxk)
G.pedestrian = matrix(NA, nrow=nrow(G), ncol=ncol(G))
for(i in 1:(ncol(G)))
for(k in 1:min(nrow(G), nrow(x)-i+1))
G.pedestrian[k, i] = (k*d-1)*var(as.vector(x[i:(i+k-1), ]))
stopifnot(identical(is.na(G), is.na(G.pedestrian)))
stopifnot(max(abs(G-G.pedestrian), na.rm=TRUE) <= 1e-6)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.