Skip to content

PathEnsemble

PathEnsemble

Bases: ABC

Abstract base class of path ensembles.

Attributes:

  • weighted (bool) –

    True if the paths carry masses that encode growth information (required by unbalanced solvers). Otherwise the masses returned by :meth:sample are the snapshot-size ratios (ones for snapshots of equal sizes).

fit(dist, push=None, generator=None) abstractmethod

Build what the ensemble needs from the snapshots.

Parameters:

  • dist (list of torch.Tensor, length nsnaps) –

    dist[k] has shape (n_k, ndim), on a common device and dtype.

  • push (callable or None, default: None ) –

    Reference dynamics: push(x, k) returns the positions at t_{k+1} of points x of shape (m, ndim) at t_k. None is the identity (plain PFM).

  • generator (Generator or None, default: None ) –

    Optional RNG for reproducible sub-sampling.

Returns:

moments(n_paths=None, generator=None)

First two moments of the path nodes.

Empirical moments of :meth:sample (normalized by the number of paths). Ensembles fitted on exact laws override this with the exact moments.

Parameters:

  • n_paths (int or None, default: None ) –

    Number of paths passed to :meth:sample.

  • generator (Generator or None, default: None ) –

    Optional RNG for reproducible sampling.

Returns:

  • means ( torch.Tensor of shape (nsnaps, ndim) ) –

    Mean of the nodes at every snapshot time.

  • covs ( torch.Tensor of shape (nsnaps, nsnaps, ndim, ndim) ) –

    covs[j, k] is the covariance between the nodes at times j and k.

sample(n_paths=None, generator=None) abstractmethod

Return paths and their masses.

Parameters:

  • n_paths (int or None, default: None ) –

    Number of paths. If None, the ensemble's default.

  • generator (Generator or None, default: None ) –

    Optional RNG for reproducible sampling.

Returns:

  • paths ( torch.Tensor of shape (n_paths, nsnaps, ndim) ) –

    Paths in trajectory-first layout, as expected by the interpolants.

  • masses ( torch.Tensor of shape (n_paths, nsnaps) ) –

    Mass of every path at every snapshot time.