Skip to content

Instantly share code, notes, and snippets.


Abraham Flaxman aflaxman

View GitHub Profile
aflaxman / gist:287370
Created Jan 26, 2010
networkx-osm import open street map data as a networkx graph
View gist:287370
Read graphs in Open Street Maps osm format
Based on from brianw's osmgeocode, which is based on from
comes from Graphserver: and is copyright (c)
2007, Brandon Martin-Anderson under the BSD License
We couldn’t find that file to show.
""" Class for holding species occurrence data, and associated covariates"""
import csv
class Data:
def __init__(self, fname='data.csv'):
self.raw_data = [d for d in csv.DictReader(open(fname))]
self.seen = []
self.unseen = []
self.cov = {}
""" Generate graphs from the spatial preferential attachment model,
and animate them"""
from pymc import runiform, rnormal
from networkx import DiGraph, draw
from pylab import clf, axis, savefig
from numpy import maximum, minimum
def perturb(x, e):
from pylab import *
import random
index_set = [[i,j] for i in range(9) for j in range(9)]
def solve(T):
""" Find a solution to T, if possible
T is a 9x9 array, with blank cells set to -1
T is changed to the solution, returns 'success' or 'failure'
from pymc import *
def test(a0, b0):
# use non-informative priors
x = rbinomial(10, .5, 10)
a = Uniform('a', lower=-1000, upper=1000, value=a0)
b = Normal('b', mu=0, tau=.01, value=b0)
def theta(a=a, b=b):
""" Script to remake some uncommunicative info graphics I've seen in the news"""
from pylab import *
# Eli Sander's article "Tax the Filthy Rich"
y = [2116.906, 787.162, 356.570, 72.858]
y2 = [38.400]
""" script to visualize some random graphs that are nice to draw"""
import networkx as nx
import pylab as pl
n = 100 # number of vertices
rc = .25 # critical radius for geometric graph
rr = .05 # repel radius for hard-core model
p = .25 # edge percolation probability
import pymc as pm
import numpy as np
# FIXME: Need to store duplicates too, when jumps are rejected. That means some mechanism
# for making sure the history is full-rank needs to be employed.
class HistoryCovarianceStepper(pm.StepMethod):
_state = ['n_points','history','tally','verbose']