Skip to content

Instantly share code, notes, and snippets.

@ganeumann
ganeumann / bigdraws.py
Created December 3, 2017 14:43
Simulate VC portfolios, calculate percent above benchmarks
import numpy as np
def vcdraws(alpha,n):
# prob density distribution = 1/3 0x, 1/3 1x, 1/3 power law with alpha=alpha
# returns list of n draws from the distribution
pn=np.random.randint(0,3, size=n)
td = powerlaw.Power_Law(xmin=1.0, parameters=[alpha])
return [td.generate_random(1)[0] if pn[i]==2 else pn[i] for i in range(n)]
def vcportdraws(alpha,portsize,runs):
@ganeumann
ganeumann / basicmcs.py
Created December 2, 2017 03:30
Monte Carlo Simulation of the Basic Model
import numpy as np
def pickaportfolio(n):
# possible outcomes, from Fred's post
# portfolios of size n
# returns the mean of a single random portfolio
possible_outcomes = [0,0,0,0,1,1,1,3,3,10]
# pick n random elements from the list and take the mean of the outcome
return np.mean(np.random.choice(possible_outcomes,n))
@ganeumann
ganeumann / chartxceedbenchmark.py
Last active April 8, 2021 16:38
Probability of Exceeding Return Chart
import numpy as np
def vcdist(alpha):
# generates one pick from the VC distribution
# prob density distribution = 1/3 0x, 1/3 1x, 1/3 power law with alpha=alpha
# returns one draw from the distribution as a float
pn=np.random.randint(0,3)
if pn==2:
td = powerlaw.Power_Law(xmin=1.0, parameters=[alpha])
return td.generate_random(1)[0]
Verifying that +ganeumann is my openname (Bitcoin username). https://onename.com/ganeumann