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
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 |
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 | |
# -*- 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 |
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
__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"}) |
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
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) |
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
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: |
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 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(): |