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
{ | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "# Setting MNIW Priors #\n\nFor an autoregressive model with $k$ lags and parameters $(A,\\Sigma)$, for each time $t$ if we write the vector of lagged observations as $\\tilde{y} \\triangleq (y_{t-1}, y_{t-2}, \\ldots, y_{t-k})$ then we can write the generative model as\n$y | \\tilde{y},A,\\Sigma \\sim \\mathcal{N}(A \\tilde{y}, \\Sigma)$\nso that the likelihood is\n\n$$ p(y|\\tilde{y},A,\\Sigma) \\propto \\exp \\left\\{ -\\frac{1}{2}(y-A\\tilde{y})^T \\Sigma^{-1} (y-A\\tilde{y}) \\right\\}. $$\n\nThe natural conjugate prior over $(A,\\Sigma)$ is the Matrix-Normal-Inverse-Wishart (MNIW) with hyperparameters $(\\nu_0,S_0,M_0,K_0)$, where $(\\Sigma,A) \\sim \\text{MNIW}(\\nu_0,S_0,M_0,K_0)$ if\n\n$$ \\Sigma \\sim \\text{InvWishart}(\\nu_0,S_0) $$\n$$ A | \\Sigma \\sim \\text{MN}(M_0,\\Sigma,K_0). $$\n\nTherefore to set a prior over $(\\Sigma,A)$ we must choose the hyperparameters $(\\nu_0,S_0,M_0,K_0)$. |
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
#!/usr/bin/env python | |
from __future__ import division | |
import sys | |
from dateutil.parser import parse | |
from dateutil.relativedelta import relativedelta | |
from datetime import datetime | |
from collections import OrderedDict | |
# from https://en.wikipedia.org/wiki/Year |
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
from __future__ import division | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from matplotlib import rc, rcParams | |
np.random.seed(0) | |
rc('font',**{'family':'sans-serif','sans-serif':['Arial'],'size':16}) | |
def myboxplot(boxdata,pointdata): |
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
from __future__ import division | |
import numpy as np | |
from matplotlib import pyplot as plt | |
import pyhsmm | |
from pyhsmm.util.text import progprint_xrange | |
obs_hypparams = dict(mu_0=np.zeros(2),sigma_0=np.eye(2),kappa_0=0.05,nu_0=4) | |
### generate data |
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
#include "bar.h" | |
void blah(int sz, double *x) { | |
for (int i=0; i<sz; i++) { | |
x[i] = (double) 2*i; | |
} | |
} |
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
from __future__ import division | |
from sympy import MatrixSymbol, Matrix, latex, simplify | |
import baker | |
def SymmetricMatrix(name,n): | |
J = Matrix(MatrixSymbol(name,n,n)) | |
for i in range(n): | |
for j in range(i): | |
J[i,j] = J[j,i] | |
return J |
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
from __future__ import division | |
import baker | |
from pylab import * | |
def rand_psd(n): | |
a = randn(n,n) | |
return a.dot(a.T) | |
def ssor_split(J): | |
# NOTE: J = L + D + U |
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
function A = grid(n,m) | |
if ~exist('m','var'), m=n; end | |
A = kron(eye(n),path(m)) + kron(path(n),eye(m)); | |
end |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer