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: |
weights |
weights for choosing interval boundaries for method |
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))