API Reference

mcrand.distribution(pdf, bounds, max_sample=100000, *args)

Generator of random numbers following the given probability density function.

Parameters:
pdf : func

the probability density function.

  • Input parameters:
    • x : float
      the evaluation point
    • *args : tuple
      extra parameters
  • Output parameters:
    • y : float
bounds : tuple of floats

lower and upper limit

max_sample : int

the quantity of random numbers to return

*args : args

extra arguments for the pdf

Returns:
random_numbers : numpy.ndarray

collection of random numbers following the given pdf.

Notes

pdf is expected to be a probability density function therefore it must be positively defined in the range specified.

mcrand.sample(pdf, x0, xf, shape, *args)

Generator of random numbers following the given probability density function.

Parameters:
pdf : func

the probability density function

x0 : float

the lower limit

xf : float

the upper limit

shape : int or tuple of ints

the shape of the generated random numbers array

*args : args

extra arguments for the pdf

Returns:
random_numbers : numpy.ndarray

collection of random numbers following the given pdf with the specified shape.

mcrand.uniform_integration(f, limits, N, *args)

MonteCarlo integration of multidimensional functions.

Parameters:
f : func

integration function. input parameters: * x : numpy.ndarray

the evaluation point, n-dimensional vector

  • *args : tuple
    extra parameters

output parameters: * y : float

limits : list of tuple

a list containing the lower and upper limits of integration for each dimension as tuple with two ints (low, high).

N : int

number of points used

*args : args

extra arguments for the evaluation function

Returns:
integral : float

the result of the integral

error : float

the standard deviation