Skip to content

randvars⚓︎

Classes of random variables.

GaussRV ⚓︎

Bases: RV_with_mean_and_cov

Gaussian (Normal) multivariate random variable.

LaplaceParallelRV ⚓︎

Bases: RV_with_mean_and_cov

A NON-elliptical multivariate version of Laplace (double exponential) RV.

LaplaceRV ⚓︎

Bases: RV_with_mean_and_cov

Laplace (double exponential) multivariate random variable.

This is an elliptical generalization. Ref: Eltoft (2006) "On the Multivariate Laplace Distribution".

RV ⚓︎

Bases: NicePrint

Class to represent random variables.

__init__(M, **kwargs) ⚓︎

Initalization arguments:

  • M <int> : ndim
  • is0 <bool> : if True, the random variable is identically 0
  • func <func(N)> : use this sampling function. Example: RV(M=4,func=lambda N: rng.random((N,4))
  • file <str> : draw from file. Example: RV(M=4,file=dpr.rc.dirs.data/'tmp.npz')

The following kwords (versions) are available, but should not be used for anything serious (use instead subclasses, like GaussRV).

  • icdf <func(x)> : marginal/independent "inverse transform" sampling.
    Example: RV(M=4,icdf = scipy.stats.norm.ppf)
  • cdf <func(x)> : as icdf, but with approximate icdf, from interpolation.
    Example: RV(M=4,cdf = scipy.stats.norm.cdf)
  • pdf <func(x)> : "acceptance-rejection" sampling. Not implemented.

RV_with_mean_and_cov ⚓︎

Bases: RV

Generic multivariate random variable characterized by mean and cov.

This class must be subclassed to provide sample(), i.e. its main purpose is provide a common convenience constructor.

__init__(mu=0, C=0, M=None) ⚓︎

Init allowing for shortcut notation.

sample(N) ⚓︎

Sample N realizations. Returns N-by-M (ndim) sample matrix.

Examples:

>>> plt.scatter(*(UniRV(C=randcov(2)).sample(10**4).T))

StudRV ⚓︎

Bases: RV_with_mean_and_cov

Student-t multivariate random variable.

Assumes the covariance exists, which requires degreee-of-freedom (dof) > 1+ndim. Also requires that dof be integer, since chi2 is sampled via Gaussians.

UniParallelRV ⚓︎

Bases: RV_with_mean_and_cov

Uniform multivariate random variable.

Has a parallelogram-shaped support, as determined by the cholesky factor applied to the (corners of) the hypercube.

UniRV ⚓︎

Bases: RV_with_mean_and_cov

Uniform multivariate random variable.

Has an elliptic-shape support. Ref: Voelker et al. (2017) "Efficiently sampling vectors and coordinates from the n-sphere and n-ball"