This file contains 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
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 = [] |
This file contains 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 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 |
This file contains 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
# ----------------------------------------- | |
# 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 |
This file contains 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
# 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 |