Created
October 9, 2019 20:30
-
-
Save chelseaparlett/2deb9a0372f4b3849da746c5271a9343 to your computer and use it in GitHub Desktop.
This file contains 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 randomPrior(): | |
'''randomly chooses a type of distribution then randomly selects | |
parameters based on limitations of said distribution''' | |
possPriors = {"Cauchy": {"loc": [-100,100], "scale": [0,100]}, | |
"Normal": {"mean": [-100,100], | |
"sd": [0,100]}, | |
"InverseGamma": {"a": [0,100], "b":[0,100]}, | |
"Gamma": {"a": [0,100], "b":[0,100]}, | |
"Poisson": {"lambda": [0,100]}} | |
prior = np.random.choice(list(possPriors.keys()), size = 1) | |
string = prior[0].upper() + "(" #CAPS name and first paren | |
selected = possPriors[prior[0]] | |
for item in selected: #for each parameter | |
param = int(np.random.uniform(selected[item][0],selected[item][1])) #lazy uniform sampling | |
string = string + str(param) + "," | |
string = string[:-1] #get rid of last comma | |
string += ")!" #close paren | |
return(string) | |
print(randomPrior()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment