Built matrix of interval costs for held-out linear models. One indexed.
lin_costs(x, y, w, min_seg, indices)
NumericVector, x-coords of values to group.
NumericVector, values to group in order.
NumericVector, weights.
positive integer, minimum segment size (>=1).
IntegerVector, ordered list of indices to pair.
xcosts NumericMatix, for j>=i xcosts(i,j) is the cost of partition element [i,...,j] (inclusive).
lin_costs(c(1, 2, 3, 4), c(1, 2, 2, 1), c(1, 1, 1, 1), 1, 1:4)
#> [,1] [,2] [,3] [,4]
#> [1,] 1.797693e+308 5.000038e-01 2.250203e+00 6.576132e+00
#> [2,] 5.000038e-01 1.797693e+308 3.611067e-01 2.250398e+00
#> [3,] 2.250203e+00 3.611067e-01 1.797693e+308 3.043395e+00
#> [4,] 6.576132e+00 2.250398e+00 3.043395e+00 1.797693e+308