Skip to content

Instantly share code, notes, and snippets.

@deanmalmgren
deanmalmgren / random_numbers.py
Created July 14, 2014 19:49
random numbers in python distributions
"""Pipe the output of this script to another program to look at the CDF of the values. For example,
python random_numbers.py 1000 | sort -n | awk '{print $1, 1-(NR-1)/1000}' | xmgrace -
"""
import sys
import random
n = int(sys.argv[1])
for i in xrange(n):
@deanmalmgren
deanmalmgren / .gitignore
Last active August 29, 2015 14:03
bootstrapping: comparing sample means
sample_a.dat
sample_b.dat
@deanmalmgren
deanmalmgren / .gitignore
Last active August 29, 2015 14:03
how often is A better than B?
sample_a.dat
sample_b.dat
@deanmalmgren
deanmalmgren / README.md
Created September 9, 2014 13:56
statistical significance of number of CEOs hired internally

When I saw this on twitter, it really made me wonder whether the reported statistics had any significance. Based on the numbers reported, I wrote a quick little program to estimate the 95% confidence interval of the percent of CEOs hired internally. Alongside each regions name is the lower and upper cutoff on the 95% confidence interval.

[unix]$ python simulate.py
          USA/Canada	0.679	0.859
      Western Europe	0.625	0.854
               Japan	0.897	1.000
        Other mature	0.565	0.826
               China	0.710	0.968
Brazil, Russia, India	0.517	0.828
@deanmalmgren
deanmalmgren / README.md
Last active August 29, 2015 14:11
elongated dice analysis
@deanmalmgren
deanmalmgren / README.md
Last active August 29, 2015 14:15
scialog pre-conference network

This is a quick visualization of the Scialog pre-conference network. Orange nodes are theorists, blue nodes are experimentalists, and yellow circles are both experimentalists and theorists. For simplicity, this only displays the bidirectional links between pairs of scientists where the thickness of the line joining two scientists corresponds with how strongly they know each other.

To run this in development, just use python's simple server:

python -m SimpleHTTPServer
@deanmalmgren
deanmalmgren / after.dat
Last active September 22, 2015 15:05
issue for msp-boxes?
1.0 0.022566380334 0.04 0.0245276407981 0.029769291226 0.0536675041929 0.0268831375565 0.0421124148346 0.0320871215252 0.0444774273755 0.0444774273755 0.0186396379746 0.0363831094317 0.029769291226 0.0105892274179 0.0348216114596 0.0134713615846 0.0194822293602 0.0320871215252 0.029769291226 0.0363831094317 0.0308824682094 0.0444774273755 0.0682274642961 0.021983276081 0.0277777777778 0.0421124148346 0.0444774273755 0.0238353731866 0.0171625207348 0.0381007372999 0.0320871215252 0.0209064363614 0.0363831094317 0.0320871215252 0.0381007372999 0.0231827458604 0.0471451211741 0.04 0.021983276081 0.0238353731866 0.029769291226 0.0209064363614 0.0260468863234 0.00918543875722 0.00721809760087 0.0348216114596 0.0252633672918 0.0138953290753 0.029769291226
0.022566380334 1.0 0.0252633672918 0.029769291226 0.0141178336851 0.0182460947032 0.0287373176349 0.0471451211741 0.0348216114596 0.0214307586872 0.0333953686704 0.0186396379746 0.0363831094317 0.0231827458604 0.0130732739486 0.0231827458604 0.0333953686704 0.0333
@deanmalmgren
deanmalmgren / gist:1790480
Created February 10, 2012 16:01
merge work from mercurial repository ./X/path/to/dir into repository ./Y/path/to/dir
# from the bash prompt...
# starting from the directory that contains repositories X and Y, use 'hg convert --filemap' to find
# extract the content from path/to/dir in repository X and put it into a temporary repository TMP
echo 'include "path/to/dir"' > filemap.txt
hg convert --filemap.txt ./X ./TMP
# enter repository Y and do a "force pull" to pull in the changes from the temporary repository TMP
cd ./Y
hg pull -f ../TMP

This is a simple gist to illustrate the peculiar behavior with django 1.5 and DEBUG=False when running locally (and in production?...haven't gotten that far yet).

@deanmalmgren
deanmalmgren / 01.make
Last active December 18, 2015 18:39
brew install meld does not work
python tools/install_paths \
libdir=/usr/local/Cellar/meld/1.7.2/lib/meld \
localedir=/usr/local/Cellar/meld/1.7.2/share/locale \
helpdir=/usr/local/Cellar/meld/1.7.2/share/gnome/help/meld \
sharedir=/usr/local/Cellar/meld/1.7.2/share/meld \
< bin/meld > bin/meld.install
python tools/install_paths \
libdir=/usr/local/Cellar/meld/1.7.2/lib/meld \
localedir=/usr/local/Cellar/meld/1.7.2/share/locale \
helpdir=/usr/local/Cellar/meld/1.7.2/share/gnome/help/meld \