# ## Create a "schwartz2f"-object
# model <- schwartz2f()
#
# ## and sample from its distribution at time = 2.5.
# sim <- rstate(n = 1000, s0 = model, time = 2.5)
# par(mfrow = c(1, 2))
# hist(sim[,1], main = "Distribution of Spot Price")
# hist(sim[,2], main = "Distribution of Convenience Yield")
#
#
# ## Create a trajectory over a 6 years horizon sampled on a weekly basis.
# trajectory <- simstate(6 * 52, time = 6, s0 = model)
# par(mfrow = c(1, 2))
# plot(trajectory[,1], main = "Spot Price", type = "l")
# plot(trajectory[,2], main = "Convenience Yield", type = "l")
Run the code above in your browser using DataLab