Modeling

Creating a Model

dive.model(t: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], Vexp: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], method: str = 'regularization', r: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None, bkgd_var: str = 'Bend', n_gauss: int = 1, alpha: float | None = None, delta_prior: tuple[float, float] = (1, 1e-06), tau_prior: tuple[float, float] = (1, 0.0001)) dict

Creates a model for sampling.

The PyMC model, the DEER data, and additional parameters are all stored in a dictionary.

Parameters:
  • t (ArrayLike) – The time-domain axis of the DEER data.

  • Vexp (ArrayLike) – The experimental signal of the DEER data.

  • method (str, default="regularization") – The method (regularization, regularization_NUTS, or gaussian) to use.

  • r (ArrayLike, optional) – The distance axis of the DEER data. If none given, a distance axis will be automatically generated.

  • bkgd_var (str, default="Bend") – The background parameterization to use. Options are “Bend” and “k”.

  • n_gauss (int, default=1) – The number of gaussians to use. Ignored if the method is a regularization method.

  • alpha (float, optional) – The fixed value for the regularization parameter. If not set, alpha will be allowed to vary.

  • delta_prior (tuple of float, default=(1, 1e-6)) – The alpha and beta parameters of the gamma distribution of the prior for delta. Only used in the regularization models.

  • tau_prior (tuple of float, default=(1, 1e-4)) – The alpha and beta parameters of the gamma distribution of the prior for tau. Only used in the regularization models.

Returns:

model – Returns a dictionary containing the PyMC model, the DEER data, and additional parameters.

Return type:

dict

PyMC Models

dive.regularizationmodel(t: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], Vexp: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], K0: ndarray, L: ndarray, LtL: ndarray, r: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], delta_prior: tuple[float, float] = (1, 1e-06), tau_prior: tuple[float, float] = (1, 0.0001), tau_gibbs: bool = True, delta_gibbs: bool = True, bkgd_var: str = 'Bend', alpha: float | None = None, all_NUTS: bool = False) Model

Generates a nonparametric PyMC model.

The model is for a DEER signal over time vector t (in µs) given data in Vexp. It uses Tikhonov regularization for P with regularizaton parameter alpha and uses an exponential background.

Model parameters:

P distance distribution vector (nm^-1) tau noise precision (inverse of noise variance) delta smoothing hyperparameter (= alpha^2/sigma^2) lamb modulation amplitude Bend background decay value at end of time interval V0 overall amplitude

Parameters:
  • t (ArrayLike) – The time-domain axis of the DEER data.

  • Vexp (ArrayLike) – The experimental signal of the DEER data.

  • K0 (np.ndarray) – The dipolar kernel matrix.

  • L (np.ndarray) – The regularization operator matrix.

  • LtL (np.ndarray) – The regularization operator matrix multiplied with its transpose.

  • r (ArrayLike) – The distance axis of the DEER data. If none given, a distance axis will be automatically generated.

  • delta_prior (tuple of float, default=(1, 1e-6)) – The alpha and beta parameters of the gamma distribution of the prior for delta. Only used in the regularization models.

  • tau_prior (tuple of float, default=(1, 1e-4)) – The alpha and beta parameters of the gamma distribution of the prior for tau. Only used in the regularization models.

  • tau_gibbs (bool, default=True) – Whether or not to sample tau with the Gibbs sampling method.

  • delta_gibbs (bool, default=True) – Whether or not to sample delta with the Gibbs sampling method.

  • bkgd_var (str, default="Bend") – The background parameterization to use. Options are “Bend” and “k”.

  • alpha (float, optional) – The fixed value for the regularization parameter. If not set, alpha will be allowed to vary.

  • all_NUTS (bool, default=False) – Whether or not to sample all parameters with the NUTS sampling method.

Returns:

model_pymc – A PyMC Model object representing a nonparametric DEER model.

Return type:

pm.Model

dive.multigaussmodel(t: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], Vexp: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], K0: ndarray, r: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], n_gauss: int = 1, bkgd_var: str = 'Bend') Model

Generates a parametric PyMC model.

The model is for a DEER signal over time vector t (in µs) given data in Vexp. It uses a multi-Gaussian distribution for P with n_gauss gaussians and uses an exponential background.

Model parameters:

r0 distance(s) of mean of gaussian(s) (nm) w width of gaussian(s) (nm) a relative amplitudes of gaussians (when multiple) tau noise precision (inverse of noise variance) lamb modulation amplitude Bend background decay value at end of time interval V0 overall amplitude

Parameters:
  • t (ArrayLike) – The time-domain axis of the DEER data.

  • Vexp (ArrayLike) – The experimental signal of the DEER data.

  • K0 (np.ndarray) – The dipolar kernel matrix.

  • r (ArrayLike) – The distance axis of the DEER data. If none given, a distance axis will be automatically generated.

  • n_gauss (int, default=1) – The number of gaussians to use.

  • bkgd_var (str, default="Bend") – The background parameterization to use. Options are “Bend” and “k”.

Returns:

model_pymc – A PyMC Model object representing a parametric DEER model.

Return type:

pm.Model