Code/data for cs2014
To actually run this code you need to get my gibbs branch of MCMC.jl:
Pkg.clone("git@github.com:spencerlyon2/MCMC.jl.git")
Pkg.checkout("MCMC", "gibbs")
You will also need a special version of the StateSpace.jl package:
#!/usr/bin/env python | |
import os | |
import urllib | |
from threading import Thread | |
from Queue import Queue | |
import pandas as pd | |
def hist_data_threaded(syms, max_threads=100, source='yahoo', | |
start='1/1/2010', end='12/31/2013'): |
# file: QuantMacro.jl | |
module QuantMacro | |
export Models #, other tools | |
include("models.jl") | |
end # module |
#Set up data partition | |
sudo mkdir /data | |
sudo chmod 777 /data | |
sudo "echo /dev/xvdb /data ext4 rw,user,exec,comment=cloudconfig 0 2 >> /etc/fstab" | |
sudo mount /data | |
#Install build environment | |
sudo sed -i "s/enabled=0/enabled=1" /etc/yum.repos.d/epel.epo | |
sudo yum -y update | |
sudo yum -y upgrade |
##### Install a lot of stuff first ##### | |
$sudo apt-get update | |
##install python | |
$ wget http://09c8d0b2229f813c1b93-c95ac804525aac4b6dba79b00b39d1d3.r79.cf1.rackcdn.com/Anaconda-2.0.1-Linux-x86_64.sh | |
$ sudo bash anaconda........sh | |
##install necessary libs | |
$ sudo apt-get install -y python-matplotlib python-tornado ipython ipython-notebook python-setuptools python-pip |
using Base.LinAlg: BlasChar, BlasInt, blas_int, chkstride1, chksquare | |
using Base: blasfunc | |
using Base.LinAlg.LAPACK: liblapack, @lapackerror | |
A = [1. 2 3 | |
4 5 6 | |
7 8 9] | |
B = diagm(randn(3)) | |
args = ('V', 'V', copy(A), copy(B)) |
Code/data for cs2014
To actually run this code you need to get my gibbs branch of MCMC.jl:
Pkg.clone("git@github.com:spencerlyon2/MCMC.jl.git")
Pkg.checkout("MCMC", "gibbs")
You will also need a special version of the StateSpace.jl package:
# load in the model and associated tools | |
require("../nk_model.jl") | |
require("../nk_model_tools.jl") | |
# load packages we use | |
import Gadfly | |
import PyPlot | |
using Distributions | |
using DataFrames |
The template is called example.tmpl
and it contains the lecture source as well as defines various blocks.
Each of the blocks has a default argument that is simply the content that is found in the current python only version of the site.
The cool thing is how we can use this system to easily generate lecture files for both languages, by only having to define the blocks for julia. This happens in example_jl.tmpl
.
Notice I don't do anything beyond filling in the blocks here. i.e. there is no actual exposition here -- just replacing the default block parameters with their julia equivalent.
The python script run_example.py
shows how we could load the template and evaluate it. If you have python run the file it will print out the python and julia versions of the file for you.
#!/usr/bin/env python | |
""" | |
simple example script for running notebooks and reporting exceptions. | |
Usage: `checkipnb.py foo.ipynb [bar.ipynb [...]]` | |
Each cell is submitted to the kernel, and checked for errors. | |
""" | |
import os,sys,time |
class AssetPrices(object): | |
""" | |
docstring | |
""" | |
def __init__(self, beta, P, s, gamma): | |
self.beta, self.gamma = beta, gamma | |
self.P, self.s = P, s | |
self.n = self.P.shape[0] | |
@property |