Skip to content

Instantly share code, notes, and snippets.

View jenniferthompson's full-sized avatar

Jennifer Thompson jenniferthompson

View GitHub Profile
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 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.