Skip to content

Instantly share code, notes, and snippets.

@grano
grano / st-petersburg-simulations.R
Created January 13, 2015 17:27
Simulations and graph or rolling average for St. Petersburg paradox
PlayGame <- function(winnings=0, turn=1) {
if(sample(0:1, 1)) {
winnings <- winnings + (2^turn)
turn <- turn + 1
PlayGame(winnings, turn)
}
else {
winnings
}
}
library(tidyverse)
library(lubridate)
library(bigrquery)
library(tibble)
# use your project ID here
project <- "project-id" # put your project ID here
# query all Bitcoin data
sql <- "SELECT