Galerkin

Routines for constructing estimates of dynamical quantities on trajectory data using Galerkin expansion.

@author: Erik

pyedgar.galerkin.compute_FK(basis, h, r=None, lag=1, dt=1.0, return_coeffs=False)[source]

Solves the forward Feynman-Kac problem Lg=h on a domain D, with boundary conditions g=b on the complement of D. To account for the boundary conditions, we solve the homogeneous problem Lg = h - Lr, where r is the provided guess.

Parameters:
  • traj_data (list of arrays OR single numpy array) – Value of the basis functions at every time point. Should only be nonzero for points on the domain.
  • h (list of 1d arrays or single 1d array) – Value of the RHS of the FK formula. This should only be nonzero at points on the domain, Domain.
  • r (list of 1d arrays or single 1d array, optional) – Value of the guess function. Should be equal to b every point off of the domain. IF not provided, the boundary conditions are assumed to be homogeneous.
  • lag (int) – Number of timepoints in the future to use for the finite difference in the discrete-time generator. If not provided, defaults to 1.
  • timestep (scalar, optional) – Time between timepoints in the trajectory data. Defaults to 1.
Returns:

  • g (list of arrays) – Estimated solution to the Feynman-Kac problem.
  • coeffs (ndarray) – Coefficients for the solution, only returned if return_coeffs is True.

pyedgar.galerkin.compute_adj_FK(basis, h, com=None, r=None, lag=1, dt=1.0, return_coeffs=False)[source]

Solves the Feynman-Kac problem L^t dagger g=h on a domain D, with boundary conditions g=b on the complement of D. Here L^t is the adjoint of the generator with respect to the provided change of measure. To account for the boundary conditions, we solve the homogeneous problem L^t g = h - L^t r, where r is the provided guess.

Parameters:
  • traj_data (list of arrays OR single numpy array) – Value of the basis functions at every time point. Should only be nonzero for points on the domain.
  • h (list of 1d arrays or single 1d array) – Value of the RHS of the FK formula. This should only be nonzero at points on the domain, Domain.
  • com (list of 1d arrays or single 1d array, optional) – Values of the change of measure against which to take the desired adjoint. If not provided, takes the adjoint against the sampled meaure
  • r (list of 1d arrays or single 1d array, optional) – Value of the guess function. Should be equal to b every point off of the domain. If not provided, the boundary conditions are assumed to be homogeneous.
  • lag (int) – Number of timepoints in the future to use for the finite difference in the discrete-time generator. If not provided, defaults to 1.
  • timestep (scalar, optional) – Time between timepoints in the trajectory data. Defaults to 1.
Returns:

  • g (list of arrays) – Estimated solution to the Feynman-Kac problem.
  • coeffs (ndarray) – Coefficients for the solution, only returned if return_coeffs is True.

pyedgar.galerkin.compute_bwd_committor(basis, guess_committor, stationary_com, lag=1)[source]

Calculates the backward into state A as a function of each point.

Parameters:
  • basis (list of trajectories) – Basis for the Galerkin expansion. Must be zero in state A and B
  • guess_committor (list of trajectories, optional) – The value of the guess function obeying the inhomogenous boundary conditions.
  • stationary_com (list of trajectories) – Values of the change of measure to the stationary distribution.
  • lag (int, optional) – Number of timepoints in the future to use for the finite difference in the discrete-time generator.
Returns:

bwd_committor (dynamical basis object) – List of trajectories containing the values of the backward_committor at each point.

pyedgar.galerkin.compute_change_of_measure(basis, lag=1)[source]

Calculates the value of the change of measure to the stationary distribution for each datapoint.

Parameters:
  • basis (list of trajectories) – Basis for the Galerkin expansion. Must be zero in state A and B
  • lag (int, optional) – Number of timepoints in the future to use for the finite difference in the discrete-time generator.
Returns:

change_of_measure (dynamical basis object) – List of trajectories containing the values of the change of measure to the stationary distribution at each point.

pyedgar.galerkin.compute_committor(basis, guess_committor, lag=1)[source]

Calculates the forward committor into state A as a function of each point.

Parameters:
  • basis (list of trajectories) – Basis for the Galerkin expansion. Must be zero in state A and B
  • guess_committor (list of trajectories, optional) – The value of the guess function obeying the inhomogenous boundary conditions.
  • lag (int, optional) – Number of timepoints in the future to use for the finite difference in the discrete-time generator.
Returns:

committor (dynamical basis object) – List of trajectories containing the values of the forward committor at each point.

pyedgar.galerkin.compute_correlation_mat(Xs, Ys=None, lag=1, com=None)[source]

Computes the time-lagged correlation matrix between two sets of observables.

Parameters:
  • Xs (list of trajectories) – List of trajectories for the first set of observables.
  • Ys (list of trajectories, optional) – List of trajectories for the second set of observables. If None, set to be X.
  • lag (int, optional) – Lag to use in the correlation matrix. Default is one step.
  • com (list of trajectories) – Values of the change of measure against which to compute the average
Returns:

K (numpy array) – The time-lagged correlation matrix between X and Y.

pyedgar.galerkin.compute_esystem(basis, lag=1, dt=1.0, left=False, right=True)[source]

Calculates the eigenvectors and eigenvalues of the generator through Galerkin expansion.

Parameters:
  • basis (list of trajectories) – List of trajectories containing the basis for the Galerkin expansion. This method works much better if the basis set is zero on states A and B, however this is not a necessity.
  • lag (int, optional) – Number of timepoints in the future to use for the finite difference in the discrete-time generator.
  • left (bool, optional) – Whether or not to calculate the left eigenvectors of the system.
  • right (bool, optional) – Whether or not to calculate the right eigenvectors of the system.
Returns:

  • eigenvalues (numpy array) – Numpy array containing the eigenvalues of the generator.
  • left_eigenvectors (list of trajectories, optional) – If left was set to true, the left eigenvectors are returned as a list of trajectories.
  • right_eigenvectors (list of trajectories, optional) – If right was set to true, the right eigenvectors are returned as a list of trajectories.

pyedgar.galerkin.compute_generator(Xs, Ys=None, lag=1, dt=1.0, com=None)[source]

Computes the matrix of inner product elements against the generator.

Parameters:
  • Xs (list of trajectories) – List of trajectories for the first set of observables.
  • Ys (list of trajectories, optional) – List of trajectories for the second set of observables. If None, set to be X.
  • lag (int, optional) – Lag to use in the correlation matrix. Default is one step.
  • dt (float, optional) – time per step of dynamics. Default is one time unit.
  • com (list of trajectories) – Values of the change of measure against which to compute the average.
Returns:

L (numpy array) – The approximation to the inner product <X, L Y>.

pyedgar.galerkin.compute_mfpt(basis, stateA, lag=1, dt=1.0)[source]

Calculates the mean first passage time into state A as a function of each point.

Parameters:
  • basis (list of trajectories) – Basis for the Galerkin expansion. Must be zero in state A.
  • state_A (list of trajectories) – List of trajectories where each element is 1 or 0, corresponding to whether or not the datapoint is in state A.
  • lag (int, optional) – Number of timepoints in the future to use for the finite difference in the discrete-time generator. If not provided, uses value in the generator.
  • timestep (scalar, optional) – Time between timepoints in the trajectory data.
Returns:

mfpt (list of trajectories) – List of trajectories containing the values of the mean first passage time at each timepoint.

pyedgar.galerkin.compute_stiffness_mat(Xs, Ys=None, lag=1, com=None)[source]

Computes the stiffness matrix between two sets of observables.

Parameters:
  • Xs (list of trajectories) – List of trajectories for the first set of observables.
  • Ys (list of trajectories, optional) – List of trajectories for the second set of observables. If None, set to be X.
  • lag (int, optional) – Lag to use in the correlation matrix. Default is one step. This is required as the stiffness is only evaluated over the initial points.
  • com (list of trajectories) – Values of the change of measure against which to compute the average
Returns:

S (numpy array) – The time-lagged stiffness matrix between X and Y.