Utility Functions

Util functions for rodeo.

rodeo.utils.add_sqrt(sqrt_A, sqrt_B)[source]

Transforms the square roots of matrices A and B into the square root of their sum.

Parameters:
  • sqrt_A (ndarray(n_dim, n_dim)) – The square root of matrix A.

  • sqrt_B (ndarray(n_dim, n_dim)) – The square root of matrix B.

Returns:

The square root of the sum of matrices A and B.

Return type:

(ndarray(n_dim, n_dim))

rodeo.utils.first_order_pad(ode_fun, n_vars, n_deriv)[source]

Returns the W matrix, and a function for finding the initial value for given \(\theta\).

Parameters:
  • ode_fun (Callable) – ODE function.

  • n_vars (int) – Number of variables.

  • n_deriv (int) – Number of upper derivatives to use.

Returns:

  • W (ndarray(n_var, 1, n_deriv)): W matrix defining the left hand side of the ODE.

  • ode_init (Callable): A function that helps setting up the initial state space mean.

Return type:

(tuple)

rodeo.utils.multivariate_normal_logpdf(x, mean, cov)[source]

Using eigendecomposition to compute multivariate normal logpdf.

Parameters:
  • x (ndarray(p)) – Observations.

  • mean (ndarray(p)) – Mean of the distribution.

  • cov (ndarray(p, p)) – Symmetric positive (semi)definite covariance matrix of the distribution.

Returns:

The logpdf of the multivariate normal.

Return type:

(float)

rodeo.utils.mvncond(mu, Sigma, icond)[source]

Calculates A, b, and V such that \(y[!icond] | y[icond] \sim \operatorname{Normal}(A y[icond] + b, V)\).

Parameters:
  • mu (ndarray(2*n_dim)) – Mean of y.

  • Sigma (ndarray(2*n_dim, 2*n_dim)) – Covariance of y.

  • icond (ndarray(2*nd_dim)) – Conditioning on the terms given.

Returns:

  • A (ndarray(n_dim, n_dim)): For \(y \sim \operatorname{Normal}(\mu, \Sigma)\) such that \(y[!icond] | y[icond] \sim \operatorname{Normal}(A y[icond] + b, V)\) Calculate A.

  • b (ndarray(n_dim)): For \(y \sim \operatorname{Normal}(\mu, \Sigma)\) such that \(y[!icond] | y[icond] \sim \operatorname{Normal}(A y[icond] + b, V)\) Calculate b.

  • V (ndarray(n_dim, n_dim)): For \(y \sim \operatorname{Normal}(\mu, \Sigma)\) such that \(y[!icond] | y[icond] \sim \operatorname{Normal}(A y[icond] + b, V)\) Calculate V.

Return type:

(tuple)

rodeo.utils.solve_var(V, B)[source]

Computes \(X = V^{-1}B\), where \(V\) is a variance matrix.

Parameters:
  • V (ndarray(n_dim1, n_dim1)) – Variance matrix \(V\).

  • B (ndarray(n_dim1, n_dim2)) – Matrix \(B\).

Returns:

Matrix \(X = V^{-1}B\).

Return type:

(ndarray(n_dim1, n_dim2))