Skip to content

Instantly share code, notes, and snippets.

View lauraxm's full-sized avatar
💭
👩‍🎤

Laura Montemayor lauraxm

💭
👩‍🎤
View GitHub Profile
numSamples <- 1000
obsPerSample <- 1000
###Uniform Distr
resultsUniform <- unlist(lapply(1:numSamples, function(x){
return(mean(
runif(obsPerSample, min = 0, max = 100)
)
library(ggplot2)
library(plotly)
# estimated model is: y = a0 + a1*x + e
obs<-100 # obs in each single regression
Nloops<-1000 # number of experiments
output<-numeric(Nloops) # vector holding p-values of estimated a1 parameter from Nloops experiments
for(i in seq_along(output)){
library(dplyr)
numSims <- 10000
numDoors <- 1:3
myDF <- data.frame(winningDoor = sample(x = numDoors, size = numSims, replace = TRUE),
initialChoice = sample(x = numDoors, size = numSims, replace = TRUE))
myDF$openedDoor <- apply(myDF, 1, function(x){
optionsToChoose <- setdiff(numDoors, as.numeric(x))
@lauraxm
lauraxm / guns-history.csv
Created October 11, 2016 15:03
Where did all the guns in Chicago come from? [scale 1]
st county STATE composite fipstxt FIPS count3
AK Aleutians East Alaska ak_aleutians east 02013 2013 0
AK Aleutians West Alaska ak_aleutians west 02016 2016 0
AK Anchorage Alaska ak_anchorage 02020 2020 19
AK Bethel Alaska ak_bethel 02050 2050 1
AK Bristol Bay Alaska ak_bristol bay 02060 2060 0
AK Denali Alaska ak_denali 02068 2068 0
AK Dillingham Alaska ak_dillingham 02070 2070 0
AK Fairbanks North Star Alaska ak_fairbanks north star 02090 2090 4
AK Haines Alaska ak_haines 02100 2100 0
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
"date_str","opp","result","record","team","league","division","pct","date_str2"
"Monday, Apr 6","OAK","L","0-1","TEX","AL","west",0,2015-04-06
"Tuesday, Apr 7","OAK","W","1-1","TEX","AL","west",0.5,2015-04-07
"Wednesday, Apr 8","OAK","L","1-2","TEX","AL","west",0.333333333333333,2015-04-08
"Thursday, Apr 9","OAK","W","2-2","TEX","AL","west",0.5,2015-04-09
"Friday, Apr 10","HOU","L","2-3","TEX","AL","west",0.4,2015-04-10
"Saturday, Apr 11","HOU","W","3-3","TEX","AL","west",0.5,2015-04-11
"Sunday, Apr 12","HOU","L","3-4","TEX","AL","west",0.428571428571429,2015-04-12
"Monday, Apr 13","LAA","L","3-5","TEX","AL","west",0.375,2015-04-13
"Tuesday, Apr 14","LAA","W","4-5","TEX","AL","west",0.444444444444444,2015-04-14
@lauraxm
lauraxm / index.html
Last active September 15, 2016 01:25
Quartet Scatterplot
<!DOCTYPE html>
<html>
<body>
<div class="buttons"></div>
<br />
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
.circleGroups text {
font: 10px sans-serif;
@lauraxm
lauraxm / add-d3
Created September 13, 2016 00:16
Adds d3 to any website
var script = document.createElement('script')
script.type = 'text/javascript'
script.src = 'http://d3js.org/d3.v3.min.js'
document.head.appendChild(script)
class Car
@@WHEELS = 4
def initialize(args)
@color = args[:color]
@wheels = @@WHEELS
end
def drive
@status = :driving
end
def brake
class Vehicle
attr_accessor :args
def self.wheels
0
end
def initialize(args)
@colour = args[:colour]
class Car
@@WHEELS = 4
def initialize(args)
@color = args[:color]
@wheels = @@WHEELS
end
def drive
@status = :driving
end
def brake