This file contains hidden or 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
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): |
This file contains hidden or 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
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)) |
This file contains hidden or 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
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] |
This file contains hidden or 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
Verifying that +ganeumann is my openname (Bitcoin username). https://onename.com/ganeumann |