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
def merge(arr, l, mids, r): | |
''' | |
Merge is a subprocedure of mergeSort, declared below. It | |
merges k sorted subarrays into a sorted array. It does so by | |
iterating continuously over all subarrays, finding the smallest key, | |
and relocating it to the right position of the outcome array. | |
Inputs: | |
arr (list) The entire array to be sorted. | |
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
import pylab as py | |
import scipy | |
import random | |
import matplotlib | |
from matplotlib import pyplot as plt | |
%matplotlib inline | |
class TrafficSimulation: | |
def __init__(self, road_length=100, traffic_density=0.1, maximum_velocity=5, |
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
set.seed(2626) | |
# Create toy dataset | |
x1 <- rnorm(200, mean = 10, sd =2) | |
x2 <- rnorm(200, mean = 50, sd =7) | |
y <- 10 + 4*x1 + 0.5*x2 - 0.1*x1*x2 + rnorm(200, mean = 0, sd = 5) | |
data <- data.frame(x1, x2, y) | |
# Spliting the data |
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
# Cleaning the workspace | |
rm(list = ls()) | |
# Loading the data | |
library(Matching) | |
data(lalonde) | |
View(lalonde) | |
str(lalonde) | |
# Let's look at two individuals. For the purposes of this tutorial, |
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
# Importing the data | |
# I'm just importing the dataset after having transformed the data columns to numeric. | |
df <- read.csv("C:/Users/Vinic/Downloads/Copy of datasetforCS112 - TA.csv", | |
stringsAsFactors = F) | |
str(df) | |
# Converting char columns to numeric | |
df$cumulative.disbursements <- | |
as.numeric(df$cumulative.disbursements) | |
df$undisbursed.amount <- |
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
# Characteristics of the data set to be generated: | |
# | |
# N(mu, sigma) error term, | |
# 500 treated units, 500 control units, | |
# Predictors: treatment (binary variable), and | |
# hectares (continuous variable--use a uniform distribution), | |
# pre-treatment productivity (continuous variable--use a uniform distribution). | |
# Outcome variable: post-treatment productivity: (continuous variable). |
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
set.seed(1234) | |
############## | |
# QUESTION 1 # | |
############## | |
# Generating 99 observations |
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
library(haven) | |
df <- read_dta("C:/Users/Vinic/Downloads/turnout.dta") | |
View(df) | |
df[1,1] | |
df[1,] | |
lm2 <- glm(turnout ~ ., data = df, family = binomial) | |
summary(lm2) | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer