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
"""A minimal implementation of a dense neural net with an arbitrary | |
number of layers, backpropagation, and a few different activation functions.""" | |
import numpy as np | |
# Activation and cost functions (with gradients) | |
def sigmoid(x): | |
y = 1.0 / (1.0 + np.exp(-x)) | |
return y, y * (1.0 - y) |
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
"""example of converting a numpy array to a C++ valarray and back in cython | |
using copies. | |
Compile with `python setup.py build_ext --inplace` | |
Example | |
------- | |
>>> import cpptest, numpy as np | |
>>> x = np.array([0., 1., 2.]) |
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
"""sncosmo Source implementing the "dm15" model from Sako et al (2008). | |
Example:: | |
>>> import sncosmo | |
>>> import dm15source | |
>>> model = sncosmo.Model(source='dm15') | |
>>> model.set(z=0.5, t0=55000., amplitude=1e-10, dm15=0.9) | |
>>> model.bandmag('sdssi', 'ab', 55011.5) | |
24.661108429127694 |
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
# Split MIRI transmissions into separate files. Original file was | |
# http://ircamera.as.arizona.edu/MIRI/ImPCE_TN-00072-ATC-Iss2.xlsx | |
# saved as CSV. | |
import numpy as np | |
data = np.loadtxt("ImPCE_TN-00072-ATC-Iss2.csv", skiprows=2) | |
bands = ("F560W F770W F1000W F1280W F1130W F1500W F1800W F2100W F2550W" | |
.lower().split()) |
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
// Doing the operation: | |
// | |
// | a a a a | | y | | |
// x * A * y = [ x x x x ] | a a a a | | y | | |
// | a a a a | | y | | |
// | a a a a | | y | | |
// | |
// with SIMD intrinics (specifically AVX). | |
// | |
// adapted from https://gist.github.com/rygorous/4172889 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 matplotlib import rc | |
from daft import PGM, Node, Plate | |
rc("font", family="serif", size=12) | |
rc("text", usetex=True) | |
pgm = PGM([7.65, 5.3], origin=[0., -0.2], observed_style='inner') |
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 ellipsoid_dist_sq(x, ell): | |
"""Return the square of each point's distance from the ellipsoid center, | |
relative to ellipsoid boundary. | |
Refered to in Feroz, Hobson & Bridges (2009) as the Mahalanobis distance. | |
Parameters | |
---------- | |
x : `~numpy.ndarray` | |
Points, array with shape (npoints, ndim). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder