Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ColCarroll
ColCarroll / pymc3_3.5.0.ipynb
Created July 10, 2018 21:50
Excitement for 3.5.0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ColCarroll
ColCarroll / pymc3_usage.csv
Created December 22, 2017 16:30
This is data from PyPI, using the bigquery sql:
wk yr file_version num
37 2016 3.0.rc1 1437
38 2016 3.0.rc1 500
39 2016 3.0.rc1 603
40 2016 3.0.rc1 625
41 2016 3.0.rc1 333
41 2016 3.0rc2 1387
42 2016 3.0rc2 603
42 2016 3.0.rc1 160
43 2016 3.0rc2 592
@ColCarroll
ColCarroll / Ecological Inference with Pymc3.ipynb
Created August 15, 2017 01:06
ecological_inference_edits
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ColCarroll
ColCarroll / Cfunction.py
Created November 26, 2013 21:06
A class for playing with numerical integrals and derivatives.
class Cfunction:
"""
A class for numeric calculus experiments
"""
def __init__(self, fcn, eps=0.001):
self.fcn = fcn
self.__eps = eps
self.integral = lambda x: self.integrate(0, x) # Indefinite integral
self.derivative = self._derivative() # f'(x)
@ColCarroll
ColCarroll / graph_clusters.R
Last active August 3, 2017 22:34
Graph clustering demo in R
sparse_matrix <- function(size, sparsity){
# Returns a <size> by <size> symmetric matrix
# with the desired sparsity percent
sparse <- matrix(
rbinom(size * size, 1, sparsity),
ncol = size,
nrow = size
)
sparse[lower.tri(sparse)] <- 0
sparse <- sparse + t(sparse)
get_psu_sample <- function(){
nodeinfo <- read.table("http://www.stat.psu.edu/~dhunter/Rnetworks/nodal.attr.txt", head=T)
nodeinfo <<- cbind(1:nrow(nodeinfo),nodeinfo)
names(nodeinfo)[1] <<- "id"
myedges <<- read.table("http://www.stat.psu.edu/~dhunter/Rnetworks/edgelist.txt")
}
network_example <- function(){
require(network)
@ColCarroll
ColCarroll / rReadTable.R
Last active December 18, 2015 15:58
A demonstration for pulling data from a wikipedia table and cleaning the specific highest mountain table.
tryAsInteger = function(node) {
val = xmlValue(node)
ans = as.integer(gsub(",", "", val))
if(is.na(ans))
val
else
ans
}
scrapeTable <- function(theurl = "http://en.wikipedia.org/wiki/List_of_highest_mountains"){