Skip to content

Instantly share code, notes, and snippets.

class QueueChain():
def __init__(self, arrival, service):
self.arrival = arrival
self.service = service
def sample_path(self, n):
path = [0]
for i in range(1, n):
path.append(path[i - 1])
@Gijs-Koot
Gijs-Koot / read_network.ipynb
Last active October 1, 2017 13:00
Import train network madrid as gexf. See http://moreno.ss.uci.edu/data.html#train.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
library(dplyr)
## use a vector for the files and the dataframes, where we leave a column in some of them
fn <- c("test_1.csv", "test_2.csv", "test_3.csv")
dl <- c(
mtcars %>% select(-gear),
mtcars %>% select(-disp),
mtcars %>% select(-wt)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Gijs-Koot
Gijs-Koot / parse_knvb_scores.py
Created February 13, 2017 14:22
Download and parse current year KNVB eredivisie results and schedule from their site.
from bs4 import BeautifulSoup
import requests
import dateparser
import pandas as pd
uitslagen_url = "http://www.knvb.nl/competities/eredivisie/uitslagen"
programma_url = "http://www.knvb.nl/competities/eredivisie/programma"
uitslagen_soup = BeautifulSoup(requests.get(uitslagen_url).content, "lxml")
programma_soup = BeautifulSoup(requests.get(programma_url).content, "lxml")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Gijs-Koot
Gijs-Koot / check_ov_bikes.gist
Last active February 2, 2017 15:59
"Oneliner" voor het bekijken van het beschikbaar aantal OV-fietsen op alle stations in Nederland.
## Dependencies:
* httpie
* csvkit
* jq
* json2csv
## Dit is de regel (filtert op utrecht en amsterdam, pas aan naar wens)
http http://fiets.openov.nl/locaties.json | jq '[.locaties[] | {loc: .description, bikes: (try .extra.rentalBikes | tonumber), date: .extra.fetchTime | todate}] | sort_by(-.bikes)' | json2csv | csvsql --query "SELECT * FROM stdin WHERE loc LIKE 'Ams%' OR loc LIKE 'Utr%' LIMIT 100" | csvlook

http://andrewgelman.com/wp-content/uploads/2012/11/frequentists_vs_bayesians.png

Question 1

There are three types of coins which have different probabilities of landing heads when tossed.

  • Type A coins are fair, with probability .5 of heads
  • Type B coins are bent and have probability .6 of heads
  • Type C coins are bent and have probability .9 of heads