randomdeviates¶
Compute random deviates from arbitrary 1D and 2D distributions.
-
mathMB.randomdeviates.
random_deviates_1d
(x, f_x, num)[source]¶ Compute random deviates from arbitrary 1D distribution.
f_x does not need to integrate to 1. The function nomralizes the distribution. Uses Transformation method (Numerical Recepies, 7.3.2)
Parameters
- x
The x values of the distribution
- f_x
The relative probability of the value being in x and x+dx
- num
The number of random deviates to compute
Returns
numpy array of length num chosen from the distribution f_x.