Skip to content

Instantly share code, notes, and snippets.

David W. Hogg davidwhogg

Block or report user

Report or block davidwhogg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
davidwhogg / Galah-demo.ipynb
Created Jul 18, 2018 — forked from adrn/Galah-demo.ipynb
View Galah-demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
curl -O
curl -O
curl -O
curl -O
curl -O
curl -O
curl -O
curl -O
curl -O
import numpy as np
from scipy.interpolate import interp1d
def weighted_median(xs, ws=None):
if ws is None:
ws = np.ones_like(xs)
totalw = np.sum(ws)
sindx = np.argsort(xs) # expensive
cs = np.cumsum(ws[sindx]) / totalw
symcumsum = 0.5 * (cs + np.append(0., cs[0:-1]))
View hoggsumexp
import numpy as np
def hoggsumexp(qns, dqn_dams, diag=False):
# purpose:
- Computes L = log(sum(exp(qns, axis=-1))).
- Also computes its M-dimensional gradient components dL / da_m.
# input
- qns: ndarray of shape [n1, n2, n3, ..., nD, N]
View make random hashes for M-S DSE Summit
import numpy as np
def int_string(x, base, digits):
xx = x + 0
str = ""
for i in range(digits):
str = (xx % base).__str__() + str
xx /= base
return str
davidwhogg /
Last active Aug 29, 2015
testing Hogg's linear algebra beliefs
import numpy as np
import scipy.linalg as la
# create data matrix and design matrices A (for sinusoids) and B (for nuisances) and M (for both)
y = np.random.normal(size=(100)) # data
A = np.random.normal(size=(2, 100)) # components we care about
B = np.random.normal(size=(10, 100)) # nuisance components
M = np.vstack((B, A))
C = np.diag(0.25 * np.ones(100))
Cinv = np.diag(4.00 * np.ones(100))
View gist:11275291
import numpy as np
import time as tt
def main():
timing = np.array([])
log2N = np.arange(6) + 8
for N in 2 ** log2N:
uu = np.random.normal(size=(N, N+2))
matrix =, uu.T)
print matrix.shape
View gist:4719653
<img width="20" height="20" align="absmiddle" src="" class="emoji" alt=":nyantocat:">
davidwhogg /
Created Nov 15, 2012 — forked from dfm/
Get some stars.

First install the Python module:

pip install casjobs

Then set the environment variables:

export CAS_DR9_WSID="1234567890" # get yours here:
davidwhogg / gist:3875572
Created Oct 11, 2012
I don't really know what a gist is, but here is one
View gist:3875572
echo Hello World
You can’t perform that action at this time.