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
import PIL.Image | |
import matplotlib | |
matplotlib.use("Agg") | |
import numpy as np | |
import pylab as pl | |
def make_color_maps(): | |
x=np.arange(0.,1.,0.01) | |
z=np.zeros_like(x) | |
R=list(zip(x,z,z)) |
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 | |
print "This script has been moved to https://github.com/joezuntz/plot" |
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 numpy import sqrt,exp,log,pi | |
import numpy as np | |
import pymc | |
#Example script showing how to fit | |
#Generate some fake data to fit. | |
#Use fixed mean and variance | |
true_mu = 2.4 |
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
import os | |
import pymc | |
database_file = "mc.pickle" | |
number_samples = 1000 | |
a = pymc.Normal("a",mu=0, tau=1) | |
b = pymc.Normal("b",mu=0, tau=1) | |
mu = a+b | |
c = pymc.Normal("c", mu=mu, tau=1, observed=True, value=0.5) | |
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
Here are some short programming maxims for new science PhD students, to correct the most egregious errors made by people | |
trained in science but not in programming. Some from http://www.theexclusive.org/2012/08/principles-of-research-code.html and http://arkitus.com/PRML/ | |
- There is no tax on variable name length - make them as long as you like. | |
- People will come to your code not knowing your nomenclature. | |
- Don't write programs, write functions. |
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
#Needs Python Wikipedia Robot Framework | |
import wikipedia | |
import sys | |
p=wikipedia.Page('en','List_of_towns_in_England') | |
town_pages=p.linkedPages()[7:-9] | |
class LatLonError(ValueError): | |
pass |
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
diff --git a/emcee/utils.py b/emcee/utils.py | |
index c5685d3..0aa63c7 100644 | |
--- a/emcee/utils.py | |
+++ b/emcee/utils.py | |
@@ -163,19 +163,25 @@ if MPI is not None: | |
F = _function_wrapper(function) | |
# Tell all the workers what function to use. | |
+ requests = [] | |
+ |
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
diff --git a/emcee/utils.py b/emcee/utils.py | |
index ca5fc30..0f33d2a 100644 | |
--- a/emcee/utils.py | |
+++ b/emcee/utils.py | |
@@ -160,17 +160,23 @@ if MPI is not None: | |
self.wait() | |
return | |
- F = _function_wrapper(function) | |
+ if function is not self.function: |
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
int point_in_polygon(int n, float *vertx, float *verty, float testx, float testy) | |
{ | |
int i, j, c = 0; | |
for (i = 0, j=n-1; i < n; j = i++) { | |
if ( ((verty[i]>testy) != (verty[j]>testy)) && | |
(testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) ) | |
c = !c; | |
} | |
return c; | |
} |
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
import numpy as np | |
def simulate_schechter_distribution(self, alpha, L_star, L_min, N): | |
""" | |
Generate N samples from a Schechter distribution, which is like a gamma distribution | |
but with a negative alpha parameter and cut off on the left somewhere above zero so that | |
it converges. | |
If you pass in stupid enough parameters then it will get stuck in a loop forever, and it | |
will be all your own fault. |
OlderNewer