Skip to content

Instantly share code, notes, and snippets.

@jdmaturen
jdmaturen / gist:4163044
Created November 28, 2012 18:22
maxgif id samples
6An
80P
2lf
1c6
7zS
1U6
2de
2yZ
2a2
6I8
burp:~ jd$ curl --referer http://t.co/ -is i.imgur.com/7RsFUmL.jpg
HTTP/1.1 302 Moved Temporarily
Server: cloudflare-nginx
Date: Wed, 14 Aug 2013 18:58:01 GMT
Content-Type: text/html
Content-Length: 165
Connection: keep-alive
Location: http://imgur.com/7RsFUmL
CF-RAY: 9dfdfc465cb0707
@jdmaturen
jdmaturen / sbg.py
Last active May 1, 2020 19:43
Implementation of the shifted beta geometric (sBG) model from "How to Project Customer Retention" (Fader and Hardie 2006) http://www.brucehardie.com/papers/021/sbg_2006-05-30.pdf Apache 2 License
"""
Implementation of the shifted beta geometric (sBG) model from "How to Project Customer Retention" (Fader and Hardie 2006)
http://www.brucehardie.com/papers/021/sbg_2006-05-30.pdf
Apache 2 License
"""
from math import log
@jdmaturen
jdmaturen / bg_nbd.py
Created October 16, 2013 05:36
Implementation of the beta-geometric/NBD (BG/NBD) model from '"Counting Your Customers" the Easy Way: An Alternative to the Pareto/NBD Model' (Fader, Hardie and Lee 2005) http://brucehardie.com/papers/018/fader_et_al_mksc_05.pdf and accompanying technical note http://www.brucehardie.com/notes/004/
"""
Implementation of the beta-geometric/NBD (BG/NBD) model from '"Counting Your Customers" the Easy Way: An Alternative to
the Pareto/NBD Model' (Fader, Hardie and Lee 2005) http://brucehardie.com/papers/018/fader_et_al_mksc_05.pdf and
accompanying technical note http://www.brucehardie.com/notes/004/
Apache 2 License
"""
from math import log, exp
import numpy as np
@jdmaturen
jdmaturen / vacuum.py
Last active December 28, 2015 02:09
Vacuum up Crunchbase
"""
Get a bunch of Crunchbase data, but respect the API limits.
Author JD Maturen
Apache 2 License
"""
import logging
from random import random
import sys

On the relative value of startup stock

How do you compare the potential value of different stage companies? And as a company progresses what is the appropriate amount of stock to give new employees?

Using data from Crunchbase and Yahoo Finance we can calculate the average value created per company broken down by how much money they have raised. From this we can then compute relative returns at the different stages, e.g. $1M raised, $10M, $100M, etc.

tl;dr

For this exercise we'll calibrate relative to expected return from a company that's raised $1M.

@jdmaturen
jdmaturen / nps.py
Created October 30, 2014 22:26
Two methods of estimating confidence and error in NPS results. One uses the beta distribution as the conjugate prior to the Bernoulli distribution. The other uses the central limit theorem and standard error calculation. The latter can also correct for finite population size.
import math
import numpy as np
from scipy.stats import beta
def nps_beta_dist(sample_size, promoters, detractors, confidence=95):
"""
Confidence range of NPS score. NPS score is defined as the percent of promoters
minus the percent of detractors. See also http://en.wikipedia.org/wiki/Net_Promoter
@jdmaturen
jdmaturen / example_output
Last active August 29, 2015 14:16
From an individual box's viewpoint probabilistically limit the global concurrency of requests of a given actor based on observed local concurrency, the cluster size, and a set threshold.
burp-2:foo jd$ python probabilistic_strategy.py 1000 16 64
request_count: 1000 cluster_size: 16 threshold: 64
probability of being quotad at a given local concurrency:
1 0.015070684079
2 0.07629533815
3 0.202571187171
4 0.378831226431
mean observed global concurrency limit: 64.033

Heads or Tails Extended

In fact, only 2 out of 2,862 broad domestic stock funds were able to outperform their peers consistently over five years, according to one measure: performance in the top quartile of funds over five consecutive 12-month periods ended in March 2014. That translates to just 0.07 percent of the funds, which means that more than 99.9 percent of funds fell short of that feat.

Repeat those double flips five times and you’ll find the probability of a mutual fund ending up in the top quartile five times in a row through chance: 0.098 percent. (We’re flipping the coin twice for each year of mutual fund performance.) That’s a bigger probability than the 0.07 percent scored by the actual funds. This means that if mutual fund managers had just flipped coins, roughly three of them — not two — would have been expected to end up in the top quartile for five years in a row.

Indeed:

>>> 100 * .25 ** 5

Keybase proof

I hereby claim:

  • I am jdmaturen on github.
  • I am jdmaturen (https://keybase.io/jdmaturen) on keybase.
  • I have a public key whose fingerprint is A95A 6A67 8A9C 7701 272D 7CBD 126A 7513 766A 6932

To claim this, I am signing this object: