Utilities
This contains some utilities for defining 1D quadrules used to estimate the integral over the residual
Solve SDE
- class svise.sdeint.solve_sde(sde: SDELearner, x0: Tensor, t_eval: Tensor, **kwargs)[source]
Wraps torchsde.sdeint to solve the approximate posterior over the drift + diffusion function in the sde
- Parameters:
sde (SDELearner) – some SDE
x0 (Tensor) – intial conditions
t_eval (Tensor) – batch of time stamps
**kwargs – kwargs passed onto the torchsde solver
- Returns:
sde solution samples
- Return type:
Tensor
Euler Maruyama integration
- class svise.utils.EulerMaruyama(f: Callable, L: Callable | Tensor, Q: Tensor, t_span: Tuple, x0: Tensor, dt: float)[source]
Performs euler-maruyama integration of an SDE
- Parameters:
f (Callable) – (float, (bs, d)) -> (bs,d) drift function computes a batch of drift values
L (Union[Callable, Tensor]) – Union[(float, (bs, d)) -> (bs, d, S), (d,S)] diffusion function computes a batch of diffusion values
Q (Tensor) – (S,S) diffusion matrix of Brownwian motion
t_span (Tuple) – integration time window
x0 (Tensor) – (bs,d) initial batch of samples from initial condition
dt (float) – integration time step
Solve Lyapunov spectral
- class svise.utils.solve_lyapunov_spectral(D: Tensor, Q: Tensor, RHS: Tensor)[source]
Solves the lyapunov equation, XK^T + KX^T = RHS, using the spectral decomposition of K
- Parameters:
D (Tensor) – (…, n) array of eigen values
Q (Tensor) – (n,n)
RHS (Tensor) – (n,n) right hand side
- Returns:
(n,n) solution
- Return type:
Tensor
Solve Lyapunov diagonal
- class svise.utils.solve_lyapunov_diag(K_diag: Tensor, RHS_diag: Tensor)[source]
Solves the lyapunov equation XK^T + KX^T = RHS in the case that K and RHS are diagonal (order(N) operations)
- Parameters:
K_diag (Tensor) – (n,) diagonal of K
RHS_diag (Tensor) – (n,) diagonal of RHS
- Returns:
(n,n) matrix solution
- Return type:
Tensor
Skew symmetric matrix exp
- class svise.utils.SkewSymMatrixExp(d: int)[source]
This module computes the matrix exponential of a skew symmetric matrix along with its gradient In testing this is about 10x-100x faster than autograd
- forward(S_vec: Tensor, return_grad: bool = False)[source]
- Computes matrix exp given n(n-1)/2 input vector
self ([TODO:parameter]): [TODO:description] S_vec (Tensor): batch of flattened n(n-1)/2 Tensor defining skew sym matrices return_grad (bool): flag indicating whether to return output or output and grad
- Returns:
exp(S_vec) or (exp(S_vec), grad(exp(S_vec)))
- Return type:
Union[Tensor, Tuple[Tensor, Tensor]]