Skip to content

Instantly share code, notes, and snippets.

View hktosun's full-sized avatar

Hasan K. Tosun hktosun

View GitHub Profile
@hktosun
hktosun / conditional_logit_with_capacity_constraints.R
Last active April 18, 2021 22:44
Conditional Logit with Capacity Constraints
set.seed(1)
N <- 800
J <- 80
id_firm = 1:J
delta = c(1:J)/J
capacity <- c(rep(10, 7*J/8), rep(100, J/8))
enrollment <- rep(0, J)
@hktosun
hktosun / multi_halton.py
Last active May 1, 2019 02:34
Halton draws
def halton(prime, N):
step = 1;
k = 0;
x = [0];
while(True):
t = len(x);
for i in range(1,prime):
for j in range(t):
x.append(i/(prime**step) + x[j])
k = k + 1;
@hktosun
hktosun / Spotify_WebScraper.py
Created March 17, 2018 02:31
This code scrapes the Spotify Charts website, gets the necessary data from the Top 200 list (songs, artists, listen counts, and ranks in each country at each date), and creates a separate data file for each country for which the data is available.
# This code...
# scrapes the Spotify Charts website,
# gets the necessary data from the Top 200 list (songs, artists, listen counts, and ranks in each country at each date), and
# creates a separate data file for each country for which the data is available.
import pandas as pd
import os
import requests
from bs4 import BeautifulSoup as bs