probnum icon indicating copy to clipboard operation
probnum copied to clipboard

Initialization of Gaussian random variables

Open JonathanWenger opened this issue 5 years ago • 2 comments

Currently when initializing a normal random variable one cannot simply specify a Cholesky factor of the covariance but has to pass a covariance as well.

import numpy as np
from probnum.random_variables import Normal

Normal(mean=np.zeros(5), cov_cholesky=np.eye(5))
# TypeError: __init__() missing 1 required positional argument: 'cov'

Normal(mean=np.zeros(5), cov=np.eye(5), cov_cholesky=np.eye(5))
# <(5,) Normal with dtype=float64>

The desired behaviour as discussed in the software meeting is to only allow construction with either a covariance, a cholesky factor, a diagonal vector of singular values and an orthogonal matrix or a vector of eigenvalues and an orthogonal matrix.

This avoids inconsistencies between covariance and matrix root at the expense of having to compute the full covariance via a matrix-matrix multiplication. This behavior is also consistent with tensorflow.

One way to implement this would be to use @classmethods (from_cholesky, from_svd, from_eigendecomposition) and an __init__(mean, cov, random_state).

JonathanWenger avatar Oct 20 '20 16:10 JonathanWenger

I can try to do this. I might have some Normal questions though.

How many of those do we want? I'd need a from_cholesky. Is there demand for from_svd or from_eigen(decomposition)? If not, I'll only do the cholesky/matrix-square-root.

pnkraemer avatar Nov 20 '20 16:11 pnkraemer

We need from_svd as well for LinearOperators where one can compute the SVD but not the cholesky decomposition.

JonathanWenger avatar Nov 20 '20 17:11 JonathanWenger