library(tidyverse)
library(patchwork)
make_plot <- function(cut) {
ggplot(data = filter(diamonds, cut == cut, color %in% LETTERS[4:5]),
aes(x = carat, y = price)) +
geom_point() +
facet_wrap(~ color) +
labs(title = cut)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This example simulates a stock price 1 time and 10k times. | |
# It uses a functional approach and a loop approach. | |
# A speed test is done at the end. | |
# This example for GBM ignores the fact that | |
# 1) There is an explicit solution to GBM where simulation isn't needed | |
# 2) Along the same lines, there is a vectorized form where pure matrix mult can be used. | |
# These are ignored for the sake of the example, because there are often cases | |
# where this isn't the case and you HAVE to do the discrete loop. |