costMatrix {tilingArray} | R Documentation

## Segmentation cost matrix

### Description

This function calculates the cost matrix for the segmentation model

### Usage

    costMatrix(x, maxk)

### Arguments

`x` | Numeric vector of length `n` or matrix with `n` rows and `d` columns, where `n` is the number of sample points and `d` the number of replicate measurements (e.g. from multiple arrays).
`maxk` | Positive integer.

### Details

See the package vignette Calculation of the cost matrix.

### Value

Matrix with `maxk` rows and `length(x)` columns.

### Author(s)

W. Huber

### Examples

    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)

[Package tilingArray version 1.70.0 Index]