This package implements the generalized Rouwenhorst algorithm from Fella, G., Gallipoli, G., & Pan, J. (2019). Markov-chain approximations for life-cycle models. Review of Economic Dynamics, 34, 183-201. It is a Julia translation of the Matlab code provided by the authors under the MIT license. If you use this package, I suggest you cite the original authors and their paper.
N = 2 # Nodes
T = 2 # Time periods
rho = fill(0.95,T) # Must have length = T
sigma_eps = fill(0.1,T) # Must have length = T
ygrd, trans = genrouwenhorst(rho,sigma_eps,N,T)
# ygrd is NxT array of grid values, with columns representing time period
# trans is the NxNxT transition matrix. I.e., `trans[1,2,2]' is the probability of transition from node 1 to node 2 in the second period.