randsplit {timedeppar}R Documentation

Draw indices for a random split of a vector into intervals of the same mean length

Description

This function draws indices for a random split of a vector into sub-vectors.

Usage

randsplit(
  n.grid,
  n.interval,
  method = c("modunif", "random", "weighted"),
  weights = numeric(0),
  offset = 0,
  min.internal = 2
)

Arguments

n.grid

number of grid points to divide into intervals

n.interval

number of intervals

method

method for random splitting:
modunif modification of uniform intervals
random random split (higher variability in inverval lengths)
weighted random split with weights; non-normalized weights must be specified by the argument weights

weights

weights for choosing interval boundaries for method weighted; vector of length i2-i1+1 (does not need to be normalized and will be ignored for all methods except for method weighted)

offset

offset to shift subset of potential interval boundaries to draw from. To guarantee different intervals on subsequent calls, offset should be increased by one between subsequent calls for the same variable.

min.internal

minimum number of internal points between interval boundary points

Value

the function returns an index vector of length n+1 with the endpoint indices of the random intervals.

Examples

randsplit(100,10)
randsplit(100,10)
randsplit(100,10,method="random")
randsplit(100,10,method="weighted",weights=1:100)
for ( i in 1:10 ) print(randsplit(100,10,method="weighted",weights=1:100,offset=i))

[Package timedeppar version 1.0.3 Index]