Skip to content

Instantly share code, notes, and snippets.

View dheerajrajagopal's full-sized avatar

Dheeraj Rajagopal dheerajrajagopal

View GitHub Profile
@dheerajrajagopal
dheerajrajagopal / wilson.py
Created July 2, 2012 06:39
python code to find the wilson interval
#! /usr/bin/env python
import math
def wilson( total, correct):
z = 1.96 # can be changed to a suitable value you want.
p = float(correct) / total
center = (p + 1 / 2.0 / total * z * z) / (1 + 1.0 / total * z * z)
d = z * math.sqrt((p * (1 - p) + 1 / 4.0 / total * z * z) / total) / (1 + 1.0 / total * z * z)
t = (center, d)
@dheerajrajagopal
dheerajrajagopal / WeightedPageRank.py
Created June 12, 2012 05:51
Weighted PageRank Python (PageRank courtesy: diogojc)
import numpy as np
from scipy.sparse import csc_matrix
import random
def column(matrix, i):
return [row[i] for row in matrix]
def pageRank(G, s = 0.85, maxerr = .001):
"""
Computes the pagerank for each of the n states.
@dheerajrajagopal
dheerajrajagopal / pagerank.py
Created May 2, 2012 05:11 — forked from diogojc/pagerank.py
python implementation of pagerank
import numpy as np
from scipy.sparse import csc_matrix
def pageRank(G, s = .85, maxerr = .001):
"""
Computes the pagerank for each of the n states.
Used in webpage ranking and text summarization using unweighted
or weighted transitions respectively.