Skip to content

Instantly share code, notes, and snippets.

import random
from random import randint
import pylab
class TrafficSimulation:
"""A class that simulates traffic on a single lane. """
def __init__(self, length, density, maxvel, prob):
""" Initializes the instance of a simulation. The user has to specify the length of the road,
the initial density, max velocity and the probability of slowing down.
"""
# Installing all the necessary libraries
library(Matching)
library(rbounds)
library(tableHTML)
# Loading the data
load("datamatch.Rdata")
# Outcome variables
outcomes <- datamatch[10:18]
library(haven)
# Installing thelibraries and importing the data
library(foreign)
library(Matching)
setwd("~/Downloads")
nsw_dw <- read_dta("nsw_dw.dta")
# Subsetting the treatment and control groups
treat <- subset(nsw_dw, treat==1)
control <- subset(nsw_dw, treat == 0)
install.packages("Matching")
library(Matching)
data(lalonde)
#Creaing two subsets: people with high school degree and people without high school degree
nodegree <- subset(lalonde, nodegr==1)
degree <- subset(lalonde, nodegr==0)
mean(nodegree$re78)
#[1] 4929.842
mean(degree$re78)