This file contains hidden or 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
#!/usr/bin/env python3 | |
# | |
# Python script that toggles blocking the 20 most visited sites in | |
# chrome through /etc/hosts for a distraction free workflow. | |
### | |
from bs4 import BeautifulSoup | |
from collections import defaultdict | |
from pathlib import Path | |
from shutil import chown, copy |
This file contains hidden or 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
(defmacro defn-memoise [name args & body] | |
(with-syms [$cache $fun] | |
~(def ,name (let [,$cache @{} | |
,$fun (fn ,name ,args ,;body)] | |
(fn [& lst] | |
(if (nil? (,$cache lst)) | |
(set (,$cache lst) (,$fun ;lst)) | |
(,$cache lst))))))) |
This file contains hidden or 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
#!/usr/bin/env -S julia -t auto | |
# | |
# Metropolis-within-Gibbs sampler for a poisson regression | |
# | |
# y_i ~ poisson(λ_i) | |
# λ_i = exp(X_i' β) | |
# β_j ~ normal(0, 5) | |
# | |
### |
This file contains hidden or 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
# Analytical dirichlet model with flat priors --- see BDA3 ch23. | |
### | |
using Distributions, Plots, StatsBase | |
""" | |
bayes_hist(x) | |
Bayesian parametric histogram using the Freedman-Diaconis rule for | |
number of bins. |
This file contains hidden or 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 Distributions, LinearAlgebra, LogExpFunctions | |
function gaussians(μ, Σ) | |
@views [MvNormal(μ[:, i], Σ[:, :, i]) for i in 1:size(μ, 2)] | |
end | |
function E_step!(Y, γ, π, μ, Σ) | |
dists = gaussians(μ, Σ) | |
lpi = log.(π) |
This file contains hidden or 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
#!/usr/bin/env Rscript | |
# | |
# Gaussian mixture model fit with the expectation-maximization algorithm | |
### | |
library(mclust) | |
library(mvtnorm) | |
set.seed(4323) |
This file contains hidden or 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
#!/usr/bin/env Rscript | |
library(cmdstanr) | |
library(dplyr) | |
options(mc.cores = parallel::detectCores() - 1) | |
load("./day5.rda") | |
# Actor list |
This file contains hidden or 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
data/ | |
stan/* | |
!stan/*.stan | |
.DS_Store | |
.Rhistory | |
.Rprof.user | |
\#*\# | |
.\#* |
This file contains hidden or 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
# Makefile template for Rmarkdown projects | |
# | |
# Includes implicit rules to generate pdf and html versions of Rmd | |
# files as well as several commands for development workflows. | |
# | |
# Invoke `make help` to get started. | |
# | |
# By default, Make will compile the pdf versions of all Rmd files | |
# found in the current working directory. | |
# |
This file contains hidden or 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
/* | |
* Copyright (c) 2020, Joshua Krusell | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining | |
* a copy of this software and associated documentation files (the | |
* "Software"), to deal in the Software without restriction, including | |
* without limitation the rights to use, copy, modify, merge, publish, | |
* distribute, sublicense, and/or sell copies of the Software, and to | |
* permit persons to whom the Software is furnished to do so, subject to | |
* the following conditions: |
NewerOlder