Description Usage Arguments Value Author(s) Examples
Generate a grid using k-means clustering.
1 | StochasticGrid(path, n_grid, max_iter, warning)
|
path |
3-D array representing sample paths. Entry [i,,j] represents the state at time j for sample path i. |
n_grid |
Number of grid points in the stochastic grid. |
max_iter |
Maximum iterations in the k-means clustering algorithm. |
warning |
Boolean indicating whether messages from the k-means clustering algorithm are to be displayed |
Matrix representing the stochastic grid. Each row represents a particular grid point. The first column contains only 1.
Jeremy Yee
1 2 3 4 5 6 7 8 9 | ## Generate paths
start <- c(1, 36)
path_disturb <- array(0, dim = c(2, 2, 100, 50))
path_disturb[1, 1,,] <- 1
rand1 <- rnorm((50 * 100) / 2)
rand1 <- as.vector(rbind(rand1, -rand1))
path_disturb[2, 2,,] <- exp((0.06 - 0.5 * 0.2^2) * 0.02 + 0.2 * sqrt(0.02) * rand1)
path <- PathDisturb(start, path_disturb)
sgrid <- StochasticGrid(path, 81, 10)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.