import shutil
import os
cwd = os.getcwd()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
### Likelihood of getting 3 heads out of 8 flips given a fair coin | |
n = 8 | |
k = 3 | |
steps = 10001 # Non zero ending to get likelihood; best if > 10000 | |
p_grid = seq(0,1,length.out = steps) | |
prior = rep(1, steps) | |
likelihood = dbinom(k, n, prob = p_grid) | |
# unstd.posterior = likelihood*prior | |
# posterior = unstd.posterior/sum(unstd.posterior) | |
# plot(p_grid, posterior) |
library(mosaic)
f <- makeFun(x^2 + y ~ x & y)
g <- makeFun(x^2 - y^2 ~ x & y)
# levelset <- 10
# plotFun(f(x,y) ~ x & y, xlim = range(-10, 10),
# levels = levelset, ylim = range(-10, 10), filled = F)
# plotFun(g(x,y) ~ x & y, levels = levelset, xlim = range(-10, 10),
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
packages <- c("twitteR", "dismo", "maps", "ggplot2") | |
installAll <- packageList[!packages %in% rownames(installed.packages())] | |
if(installAll){install.packages(installAll, repos = "http://cran.us.r-project.org")} else {print("No Packages Installed")} | |
lapply(packages, library, character.only = TRUE) |
binomProbs <- function(w, n, propStep){
# print(w)
# print(n)
# print(propStep)
plot(seq(0, 1, propStep), dbinom(w, n, prob = seq(0,1, propStep)), xlim = c(0, 1),
xlab = "", ylab = "")
points(seq(0, 1, propStep),
Game explained
https://www.scientificamerican.com/article/the-3-door-monty-hall-problem/
##### Play the game ######
# Example
# sampleSpaceDoorPick = c("ABC","ACB","BCA","BAC","CAB","CBA")
# Prep combinations table
# Function
xylist <- function(start, finish){
x <- seq(start, finish)
y <- seq(start, finish)^2
return(list("x" = x, "y" = y))
}
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
mpg | cyl | disp | hp | drat | wt | qsec | vs | am | gear | carb | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Mazda RX4 | 21 | 6 | 160 | 110 | 3.9 | 2.62 | 16.46 | 0 | 1 | 4 | 4 | |
Mazda RX4 Wag | 21 | 6 | 160 | 110 | 3.9 | 2.875 | 17.02 | 0 | 1 | 4 | 4 | |
Datsun 710 | 22.8 | 4 | 108 | 93 | 3.85 | 2.32 | 18.61 | 1 | 1 | 4 | 1 | |
Hornet 4 Drive | 21.4 | 6 | 258 | 110 | 3.08 | 3.215 | 19.44 | 1 | 0 | 3 | 1 | |
Hornet Sportabout | 18.7 | 8 | 360 | 175 | 3.15 | 3.44 | 17.02 | 0 | 0 | 3 | 2 | |
Valiant | 18.1 | 6 | 225 | 105 | 2.76 | 3.46 | 20.22 | 1 | 0 | 3 | 1 | |
Duster 360 | 14.3 | 8 | 360 | 245 | 3.21 | 3.57 | 15.84 | 0 | 0 | 3 | 4 | |
Merc 240D | 24.4 | 4 | 146.7 | 62 | 3.69 | 3.19 | 20 | 1 | 0 | 4 | 2 | |
Merc 230 | 22.8 | 4 | 140.8 | 95 | 3.92 | 3.15 | 22.9 | 1 | 0 | 4 | 2 |
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
place | stateAbbr | Rank | county | state | stateFips | countyFips | placeFips | censusPlaceType | placeSym | zip | latitude | longitude | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Fishers | IN | 1 | Hamilton | INDIANA | 18 | 57 | 23278 | Incorporated Place | A | 46037 | 39.96 | -85.94 | |
Allen | TX | 2 | Collin | TEXAS | 48 | 85 | 1924 | Incorporated Place | A | 75002 | 33.092846 | -96.62447 | |
Monterey Park | CA | 3 | Los Angeles | CALIFORNIA | 6 | 37 | 48914 | Incorporated Place | A | 91754 | 34.048207 | -118.14161 | |
Franklin | TN | 4 | Williamson | TENNESSEE | 47 | 187 | 27740 | Incorporated Place | A | 37064 | 35.893823 | -86.89919 | |
Olive Branch | MS | 5 | DeSoto | MISSISSIPPI | 28 | 33 | 54040 | Incorporated Place | A | 38654 | 34.954106 | -89.83743 | |
Dickenson | ND | 6 | Stark | NORTH DAKOTA | 38 | 89 | 19620 | Unknown | Unknown | 58601 | 46.879176 | -102.789624 | |
Lone Tree | CO | 7 | Douglas | COLORADO | 8 | 35 | 45955 | Incorporated Place | A | 80130 | 39.541571 | -104.92152 | |
North Arlington | NJ | 8 | Bergen | NEW JERSEY | 34 | 3 | 52320 | Unknown | Unknown | 7031 | 40.791895 | -74.13254 | |
Schaumburg | IL | 9 | Cook | ILLINOIS | 17 | 31 | 68003 | Unknown | Unknown | 60159 | 41.811929 | -87.68732 |