Skip to content

hssm.likelihoods

The hssm.likelihoods submodule exports a few likelihood functions. These functions are already used in the model building process for some supported models, such as ddm, ddm_sdv, and full_ddm, so you typically would not have to deal with them. However, they can be helpful if you want to use them to build a model yourself in PyMC. Please checkout the this tutorial for more details.

hssm.likelihoods

Likelihood functions and distributions that use them.

Modules:

  • analytical

    pytensor implementation of the Wiener First Passage Time Distribution.

  • blackbox

    Black box likelihoods written in Cython for "ddm" and "ddm_sdv" models.

Functions:

  • logp_ddm

    Compute analytical likelihood for the DDM model with sv.

  • logp_ddm_bbox

    Compute blackbox log-likelihoods for ddm models.

  • logp_ddm_sdv

    Compute the log-likelihood of the drift diffusion model f(t|v,a,z).

  • logp_ddm_sdv_bbox

    Compute blackbox log-likelihoods for ddm_sdv models.

  • logp_full_ddm

    Compute blackbox log-likelihoods for full_ddm models.

hssm.likelihoods.logp_ddm

logp_ddm(
    data: np.ndarray,
    v: float,
    a: float,
    z: float,
    t: float,
    err: float = 1e-15,
    k_terms: int = 20,
    epsilon: float = 1e-15,
) -> np.ndarray

Compute analytical likelihood for the DDM model with sv.

Computes the log-likelihood of the drift diffusion model f(t|v,a,z) using the method and implementation of Navarro & Fuss, 2009.

Parameters:

  • data (ndarray) –

    data: 2-column numpy array of (response time, response)

  • v (float) –

    Mean drift rate. (-inf, inf).

  • a (float) –

    Value of decision upper bound. (0, inf).

  • z (float) –

    Normalized decision starting point. (0, 1).

  • t (float) –

    Non-decision time [0, inf).

  • err (float, default: 1e-15 ) –

    Error bound.

  • k_terms (int, default: 20 ) –

    number of terms to use to approximate the PDF.

  • epsilon (float, default: 1e-15 ) –

    A small positive number to prevent division by zero or taking the log of zero.

Returns:

  • ndarray

    The analytical likelihoods for DDM.

hssm.likelihoods.logp_ddm_bbox

logp_ddm_bbox(data: np.ndarray, v, a, z, t) -> np.ndarray

Compute blackbox log-likelihoods for ddm models.

hssm.likelihoods.logp_ddm_sdv

logp_ddm_sdv(
    data: np.ndarray,
    v: float,
    a: float,
    z: float,
    t: float,
    sv: float,
    err: float = 1e-15,
    k_terms: int = 20,
    epsilon: float = 1e-15,
) -> np.ndarray

Compute the log-likelihood of the drift diffusion model f(t|v,a,z).

Using the method and implementation of Navarro & Fuss, 2009.

Parameters:

  • data (ndarray) –

    2-column numpy array of (response time, response)

  • v (float) –

    Mean drift rate. (-inf, inf).

  • a (float) –

    Value of decision upper bound. (0, inf).

  • z (float) –

    Normalized decision starting point. (0, 1).

  • t (float) –

    Non-decision time [0, inf).

  • sv (float) –

    Standard deviation of the drift rate [0, inf).

  • err (float, default: 1e-15 ) –

    Error bound.

  • k_terms (int, default: 20 ) –

    number of terms to use to approximate the PDF.

  • epsilon (float, default: 1e-15 ) –

    A small positive number to prevent division by zero or taking the log of zero.

Returns:

  • ndarray

    The log likelihood of the drift diffusion model with the standard deviation of sv.

hssm.likelihoods.logp_ddm_sdv_bbox

logp_ddm_sdv_bbox(data: np.ndarray, v, a, z, t, sv) -> np.ndarray

Compute blackbox log-likelihoods for ddm_sdv models.

hssm.likelihoods.logp_full_ddm

logp_full_ddm(data: np.ndarray, v, a, z, t, sz, sv, st)

Compute blackbox log-likelihoods for full_ddm models.