Skip to content

Instantly share code, notes, and snippets.

View seekshreyas's full-sized avatar
🐼
\_(*|*)_/

Shreyas seekshreyas

🐼
\_(*|*)_/
  • DocuSign
  • San Francisco, CA
View GitHub Profile
@seekshreyas
seekshreyas / StripTags
Created November 10, 2013 11:40
Strip HTML tags from a string in Python
# reference: http://stackoverflow.com/questions/753052/strip-html-from-strings-in-python
# To strip html tags
class MLStripper(HTMLParser):
def __init__(self):
self.reset()
self.fed = []
def handle_data(self, d):
self.fed.append(d)
def get_data(self):
return ''.join(self.fed)
from pylab import *
from scipy.stats import uniform, binom, expon, beta
true_gamma = 0.5
N = 600
T = 15
data = zeros((2, N), dtype=float)
event_times = data[0,:]
event_times[:] = uniform(0,15).rvs(N)
@seekshreyas
seekshreyas / retroDesign.py
Created June 22, 2020 05:26 — forked from chums2020/retroDesign.py
Translates Gelman's retrodesign function from R to Python
from scipy.stats import t
def retroDesign(A, s, alpha=0.05, df=1000000, n_sims=10000):
"""
:param A: the hypothesized true effect size
:param s: standard error
:param alpha: confidence level
:param df: degree of freedom
@seekshreyas
seekshreyas / keybase.md
Created December 29, 2017 09:50
Keybase Identity

Keybase proof

I hereby claim:

  • I am seekshreyas on github.
  • I am seekshreyas (https://keybase.io/seekshreyas) on keybase.
  • I have a public key ASDhDWEcjCEebaj7xzxHfy3A3SIzkrhTsPJZwTehkaXg7Qo

To claim this, I am signing this object:

@seekshreyas
seekshreyas / ka_bnet_numpy.py
Created August 29, 2017 06:08 — forked from kohlmeier/ka_bnet_numpy.py
Bayes net example in Python with Khan Academy data
#!/usr/bin/env python
from numpy import asmatrix, asarray, ones, zeros, mean, sum, arange, prod, dot, loadtxt
from numpy.random import random, randint
import pickle
MISSING_VALUE = -1 # a constant I will use to denote missing integer values
def impute_hidden_node(E, I, theta, sample_hidden):
@seekshreyas
seekshreyas / pmml_bayesnet.ipynb
Created August 25, 2017 20:22 — forked from rtbs-dev/pmml_bayesnet.ipynb
Bayesian Network Models in PyMC3 and NetworkX
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@seekshreyas
seekshreyas / ajaxListener.js
Created April 12, 2017 21:21 — forked from icodejs/ajaxListener.js
JS: Listen to ajax calls from Javascript
var open = window.XMLHttpRequest.prototype.open,
send = window.XMLHttpRequest.prototype.send,
onReadyStateChange;
function openReplacement(method, url, async, user, password) {
var syncMode = async !== false ? 'async' : 'sync';
console.warn(
'Preparing ' +
syncMode +
' HTTP request : ' +
@seekshreyas
seekshreyas / probab
Created November 13, 2013 08:14
Probability problem
var probability = function(a,b, num_games){
if (a === num_games) return 1;
if (b === num_games) return 0;
return 0.5*probability(a+1, b, num_games) + 0.5*probability(a,b+1, num_games)
}