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.

mathMB.randomdeviates.random_deviates_2d(fdist, x0, y0, num)[source]

Compute random deviates from arbitrary 2D distribution.

Uses acceptance/rejection method. Parameters

fdist

2d array of relative probability

x0

xaxis

y0

yaxis

num

number of points to choose

Outputs

x, y

vectors of length num