StochasticGrid: Stochastic grid

Description Usage Arguments Value Author(s) Examples

Description

Generate a grid using k-means clustering.

Usage

1
StochasticGrid(path, n_grid, max_iter, warning)

Arguments

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

Value

Matrix representing the stochastic grid. Each row represents a particular grid point. The first column contains only 1.

Author(s)

Jeremy Yee

Examples

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)

rcss documentation built on May 1, 2019, 10:13 p.m.