Skip to content

Instantly share code, notes, and snippets.

def plot_ccdf(data):
"""
Plot the complementary cumulative distribution function
(1-CDF(x)) based on the data on the axes object.
Note that this way of computing and plotting the ccdf is not
the best approach for a discrete variable, where many
observations can have exactly same value!
"""
# Note that, here we use the convention for presenting an
# empirical 1-CDF (ccdf) as discussed
@danjamker
danjamker / edgeswap.py
Created May 10, 2016 12:10 — forked from gotgenes/edgeswap.py
Edge swap graph.
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Copyright (c) 2011-2012 Christopher D. Lasher
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
@danjamker
danjamker / Clean.py
Created July 4, 2014 16:03
Gist for parsing the HTML file of acrynms from http://www.netlingo.com/acronyms.php into a CSV
__author__ = 'danielkershaw'
import urllib2
import BeautifulSoup
import csv
def main():
response = urllib2.urlopen('http://www.netlingo.com/acronyms.php')
html = response.read()
soup = BeautifulSoup.BeautifulSoup(html)
div = soup.find("div", {"class": "list_box3"})
def neighborhood(self, iterable):
iterator = iter(iterable)
prev = None
item = iterator.next() # throws StopIteration if empty.
for next in iterator:
yield (prev,item,next)
prev = item
item = next
yield (prev,item,None)
@danjamker
danjamker / LineClean
Created July 2, 2014 16:14
Line Clean Function
tmp = WhitespaceTokenizer().tokenize(line)
t = []
#concatonate singe letter togeater e.g. N A M E would be NAME
con = ""
for word in tmp:
if len(word) == 1:
con += word
else:
from sys import stdout
from time import sleep
def printOnline(s, text):
if s == int(text):
stdout.write("(%d)," % int(text))
else:
stdout.write(text+",")
def printLine():