costMatrix            package:tilingArray            R Documentation

_S_e_g_m_e_n_t_a_t_i_o_n _c_o_s_t _m_a_t_r_i_x

_D_e_s_c_r_i_p_t_i_o_n:

     This function calculates the cost matrix for the segmentation
     model

_U_s_a_g_e:

     costMatrix(x, maxk)

_A_r_g_u_m_e_n_t_s:

       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.

_D_e_t_a_i_l_s:

_V_a_l_u_e:

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

_A_u_t_h_o_r(_s):

     W. Huber

_E_x_a_m_p_l_e_s:

     d = 4
     x = apply(matrix(rnorm(200), ncol=d), 2, cumsum)
     maxk = 30
      
     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)/d*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)

