1 year ago
#372791
peaceful breeze
Generating random variables given the distribution and list or array of parameters
I would like to create a function that will take the probability distribution and the list or array of parameters (in order) and return a random variable of this distribution and parameters. If I know that the distribution has two input parameters, for instance, then the following function will return what I wish.
def rv(dist, paras):
return dist(paras[0], paras[1])
For example, for a standard normal variable we have
In [1]: import numpy as np
In [2]: rv(np.random.normal, [0,1])
Out[2]: -0.2985108994386439
However, I would like to extend this to a more general case, where the number of parameters can be arbitrary. Can someone offer me guidance on how to do this?
python
probability-distribution
0 Answers
Your Answer