Skip to content

Instantly share code, notes, and snippets.

View JLDC's full-sized avatar
🦉

Jonathan Chassot JLDC

🦉
View GitHub Profile
@JLDC
JLDC / slides-01.jl
Last active April 16, 2024 09:03
Recent Advances in the Econometrics of Optimal Policy Design (Part 1)
using Plots
using Random
using Statistics
Random.seed!(1)
function eval_pol(pol, n, ε, n_rep)
ε < 0 && error("ε must be non-negative")
p_sel = [1, 0, -1]
R = []
@JLDC
JLDC / pd_to_latex.py
Last active July 20, 2022 07:58
pd_to_latex
def pd_to_latex(df, print_index=True, out_file=None, align='r', col_sep="|",
digits=2, centering=True):
# If out_file is specified, outputs a .tex file, otherwise, just output the contents as a string
if len(align) == 1: # Everything is aligned the same
align = [align for _ in range((len(df.columns) + print_index))]
else: # Alignment fully specified, must match df length
if len(align) != len(df.columns) + print_index:
raise Exception("Fully specified alignment must match dataframe size")
align = col_sep + col_sep.join(align) + col_sep
# Add alignment, top border
@JLDC
JLDC / TCN.jl
Last active January 17, 2023 20:35
Temporal Convolutional Network
# -----------------------------------------
# Temporal Convolutional Network in Flux.jl
# Author: Jonathan Chassot, May 17, 2022
# -----------------------------------------
# Reference:
# Shaojie Bai, J. Zico Kolter, Vladlen Koltun. (2018)
# An Empirical Evaluation of Generic Convolutional and Recurrent Networks for Sequence Modeling
# https://arxiv.org/abs/1803.01271
# -----------------------------------------
# Note that this gist uses batch normalization instead of weight normalization as in the original paper
@JLDC
JLDC / AR1_LSTM_mod.jl
Last active April 9, 2022 22:10
AR1_LSTM_mod.jl
# All credits go to mcreel, see https://discourse.julialang.org/t/simple-flux-lstm-for-time-series/35494/42
using Flux, Plots, Statistics
using Base.Iterators
# data generating process is autoregressive order 1
# modeling objective is to forecast y conditional
# on lags of y
function AR1(n)
y = zeros(n)
for t = 2:n