Abstract
First passage time models describe the time it takes for a random process to exit a region of interest and are widely used across various scientific fields. Fast and accurate numerical methods for computing the likelihood function in these models are essential for efficient statistical inference of model parameters. Specifically, in computational cognitive neuroscience, generalized drift diffusion models (GDDMs) are an important class of first passage time models that describe the latent psychological processes underlying simple decision-making scenarios. GDDMs model the joint distribution over choices and response times as the first hitting time of a one-dimensional stochastic differential equation (SDE) to possibly time-varying upper and lower boundaries. They are widely applied to extract parameters associated with distinct cognitive and neural mechanisms. However, current likelihood computation methods struggle in common application scenarios in which drift rates dynamically vary within trials as a function of exogenous covariates (e.g., brain activity in specific regions or visual fixations). In this work, we propose a fast and flexible algorithm for computing the likelihood function of GDDMs based on a large class of SDEs satisfying the Cherkasov condition. Our method divides each trial into discrete stages, employs fast analytical results to compute stage-wise densities, and integrates these to compute the overall trial-wise likelihood. Numerical examples demonstrate that our method not only yields accurate likelihood evaluations for efficient statistical inference, but also considerably outperforms existing approaches in terms of speed.
Keywords: first passage time, drift diffusion model, attention, likelihood-based inference, numerical methods, Cherkasov condition
1. Introduction
First passage time models (also known as first hitting time models) are a fundamental class of stochastic process models that describe the time it takes for a random process to exit a region of interest. These models are widely used in various fields, including physics, finance, biology, and cognitive science, to analyze phenomena such as the time until a stock hits a particular price level, the time it takes for a neuron to fire, a survival time of a transplant patient, or the time to reach a decision barrier that triggers a choice in psychological experiments (Bhattacharya and Waymire 2021; Metzler et al. 2014; Gardiner 2009; Lee and Whitmore 2006). Accurately computing the density of the first passage time is crucial for the practical application of these models, such as in scientific hypothesis testing and parameter estimation. Since analytical solutions for many complex real-world first passage time models are unavailable, effective numerical methods are an indispensable part of the computational toolkit for applying these models. In this paper, we introduce a fast and flexible method for computing the first passage time density in a large class of models arising in cognitive neuroscience, mathematical psychology, and economics.
Consider a psychological experiment in which a subject must choose between two alternatives, A and B. The experimenter records both the choice and the time taken to make it. A common approach to modeling this behavior is through a stochastic process that starts at zero and evolves randomly over time until it first reaches or , where is the evidence threshold. The choice (A vs. B) is modeled by which boundary is hit ( vs. ) and the response time is modeled by the first hitting time (Fig. 1).
Fig. 1:

The simple DDM in the context of a canonical experiment in cognitive science, the dot-motion task. The DDM serves to represent the cognitive process underpinning the choices in this experiment. The task explicitly given to participants: Decide if the majority of dots on the screen are moving up or down. We show trajectories of the corresponding SDE, , in red, and example decision points as red stars. The first hitting times distributions , for the corresponding choices (up, down) are shown above the decision boundaries .
A widely used model for is a Brownian motion with drift
where is a standard Brownian motion. The drift rate quantifies the strength of the evidence that favors A over B and affects the joint distribution of the choice and the response time. Models such as this are often called drift diffusion models (DDMs) (Ratcliff and McKoon 2008; Fengler et al. 2022) and written in differential form, such as,
| (1) |
with the initial condition .
This basic DDM can be modified in a variety of ways to better model experimental data and test theories about the biological processes underlying decision making. For instance, the boundaries can be asymmetric and vary over time to reflect changing pressures to make a decision; the starting position can be nonzero or random, representing an initial decision bias; the drift rate towards the boundaries can depend on the presented options and vary over time; and the random process can have more complicated stochastic dynamics than Brownian motion (Fengler et al. 2022; Usher and McClelland 2001; Malhotra et al. 2018; Palestro et al. 2018; Evans et al. 2020). We adopt the terminology from Shinn et al. (2020) and call these models generalized drift diffusion models (GDDMs). Simple, computationally tractable versions of GDDMs have found widespread use in cognitive neuroscience and mathematical psychology (Ratcliff 1978; Ratcliff and McKoon 2008; Frank et al. 2015; Doi et al. 2020; Yartsev et al. 2018). While more complex versions of GDDMs have been proposed to encode a broader range of scientific hypotheses, their quantitative assessment and applications are currently limited due to computational challenges in parameter estimation (Fengler et al. 2022). In particular there do not exist fast algorithms for calculating the likelihood function of the parameters (i.e., the probability density of the hitting time on the boundary reached) in some of the more complex GDDMs that are currently of scientific interest (Krajbich et al. 2010; Ging-Jehli et al. 2025; Pagnier et al. 2024; Kuhn et al. 2025).
Computational speed is crucial in many cases for the following reason: As noted in Lee and Whitmore (2006), first passage time models commonly incorporate covariates that may vary across individuals and even across individual trials. This is particularly relevant in computational cognitive neuroscience, where the precise specification of the GDDM might change every time a subject makes a choice, i.e., in each experimental trial. An experiment with, say, 50 subjects, each completing 200 trials, might require evaluating the likelihoods of different versions of the GDDM to get the overall dataset likelihood. For instance, in equation (1) the drift rate might be different on every trial if the choices presented to subjects are different on every trial. The problem becomes even more difficult when the trial-specific drift rate can vary dynamically within a trial.
For a specific example, our original motivation to study this problem stems from attentional drift diffusion models (aDDMs)(Krajbich et al. 2010), which have been proposed as a generative model for investigating how visual attention influences decision making. In aDDMs, the drift rate in each trial is allowed to covary on a moment-by-moment basis, depending on the subject’s eye movements toward one choice option or another, which are also recorded in the experimental setup. The entire shape of changes dramatically on every trial. This model is a generic example of the general class of GDDMs where instantaneous within-trial dynamics can be based on exogenous covariates such as brain activity or eye gaze position, hence complicating the numerical procedures for computing the first passage time densities and further applications. On top of this, statistical inference tasks would still require repeated evaluations of the total dataset likelihood at different parameter values, both in frequentist and Bayesian frameworks. In particular, hierarchical Bayesian inference is widely employed in cognitive science to estimate both group- and subject-level parameters simultaneously (Wiecki et al. 2013; Fengler et al. 2022). The heavy reliance on iterative Markov chain Monte Carlo (MCMC) methods in this setting further intensifies the need for fast likelihood evaluations.
In this paper we introduce fast algorithms for accurately approximating the probability density of the hitting time in a class of GDDMs that have continuous lower and upper boundaries, and , and with dynamics that satisfy the Itô’s stochastic differential equation (SDE)
| (2) |
for possibly random and for functions and satisfying the so-called Cherkasov condition (Cherkasov 1957; Ricciardi 1976). Loosely speaking, the Cherkasov condition means that the complicated SDE in equation (2) can be transformed into a simpler SDE more akin to equation (1). A special case that includes many cases of practical interest, such as the aDDM, is when and depend only on and not on 1. There exist numerical approaches and software for approximating hitting time densities in models even more general than equation (2), but in many cases they are currently too slow for practical use in real-world psychological experiments.
Our approach shares some conceptual similarities to a line of previous work (Wang and Pötzelberger 1997; Novikov et al. 1999; Pötzelberger and Wang 2001; Wang and Pötzelberger 2007; Jin and Wang 2017). Both those methods and ours transform the problem into a canonical representation, subdivide time into discrete stages that allow for analytical approximations, compute the final approximation through integration over these stages, and then map the result back to the original problem. However, none of these earlier approaches are directly applicable to our setting or capable of statistical computation at the scale of the present work (see Section 3). In contrast, by leveraging accurate analytical results and numerical integration in a sequential manner, our semi-analytical-numerical approach achieves substantially higher computational efficiency. As shown in Section 5.4.1, it only requires microseconds for our method to evaluate a single likelihood value in a realistic aDDM example. These innovations and efficiency gains are crucial for practical likelihood-based inference in modern experimental settings.
The remainder of this article is structured as follows. Section 2 begins with a mathematical description of the GDDM. Section 3 summarizes previous work related to this paper, including other efforts to address the computational challenges in first passage time models. In Section 4, we introduce our proposed method for computing the first passage time density in certain GDDMs, starting with analytical results for simple DDMs, then combining them sequentially based on Markovian properties. We also apply variable transformations and piecewise linear approximations to extend the method to more complex GDDMs, including those that allow for position-dependent drift and diffusion terms as well as dynamic decision boundaries (Usher and McClelland 2001; Fengler et al. 2022; Ging-Jehli et al. 2025). Section 5 shows several numerical examples that demonstrate the speed and accuracy of our method for both likelihood computation and statistical inference tasks. Section 6 summarizes the present work, including its applicability and suggestions for future work. It is worth mentioning that while our examples are drawn from cognitive neuroscience and mathematical psychology, the method we propose is equally applicable to first passage time models in other fields. For instance, it could be extended to financial applications such as pricing double barrier options (Lin 1998), as well as other areas where first passage times play a critical role.
2. Drift Diffusion Model
Here we present a mathematical description of GDDMs. Let be a one-dimensional standard Brownian motion and let be a (weak) solution of the Itô’s stochastic differential equation (SDE) in equation (2) associated with , where is independent of . Let and be two continuous functions representing the upper and lower boundaries, respectively, satisfying and for all .
In this setting, we aim to study the joint distribution of the first exit time of from the time-dependent region () and the specific boundary exited (i.e., which choice is made). The first exit time is denoted as , and the boundary hit is denoted as , which takes values in the symbol set to represent which boundary is hit. The event of hitting the boundary at time models the participant’s decision to choose option at time . The event can never be observed in practice, so we do not explicitly discuss it below. If , then the probability density functions of discussed in this paper are technically sub-probability density functions that integrate to . This does not affect any of the calculations needed for likelihood-based inference.
We denote the sub-probability density functions
as the first passage time densities (FPTDs) on the upper boundary and lower boundary2, respectively, implicitly assuming throughout sufficient regularity conditions on the model for these densities to exist (see the sufficient conditions for density existence in Ferebee (1982); Strassen et al. (1967)). The marginal density of is thus given by . With this notation, we can write the joint probability density of () as
| (3) |
where is the indicator function of that is 1 if and 0 otherwise.
If we consider the possible truncation of the process at , then the first exit from the open interval () occurs either through the upper boundary before (i.e., the event ), through the lower boundary before (i.e., the event ), or does not occur before (i.e., the event ), in which case the process remains inside up to and reaches the truncation boundary . These three mutually exclusive outcomes give rise to three sub-probability densities:
: the FPTD on the upper boundary , truncated at .
: the FPTD on the lower boundary , truncated at .
: the density of the process’s position at time , provided that it has not hit either upper or lower boundary yet. We refer to as the non-passage density (NPD) at .
By the conservation of total probability we always have
for any . Define the non-passage probability (NPP) at to be
| (4) |
is useful in settings where the process is artificially stopped whenever . For instance, in some psychological experiments, subjects may be required to respond within a certain amount of time , otherwise the trial ends with the outcome “non-response” and the NPP is the probability of non-response.
The goal of this paper is to obtain a fast and accurate numerical approximation of the joint density in equation (3) and the NPP in equation (4). To this end, we develop fast numerical approximations of FPTDs and NPDs, the latter of which are needed for intermediate calculations in our approach.
As mentioned in the Introduction, we are motivated by practical problems for which we need to evaluate many different joint densities (3). We define to be the configuration of a GDDM, where is a representation for the distribution of , usually a probability density function or a point mass at a deterministic starting point . In statistical applications, will depend on unknown parameters and known covariates, some of which might vary within and across each trial. If the -the trial results in the observation (), then the contribution to the likelihood for that trial is . This is simply the FPTD on the boundary evaluated at time using the GDDM configuration for the -th trial. In experiments with a time limit, some trials might result in non-response, in which case the contribution to the likelihood is the NPP for that GDDM configuration, say . Consequently, denoting {a response on trial }, the likelihood function is then given by3
A usual experiment in the cognitive sciences, where GDDMs are ubiquitously applied, produces a dataset with thousands or tens of thousands of trials (across multiple subjects). Consequently, fast and accurate methods for evaluating FPTDs and NPPs are crucial for the practical use of likelihood-based inference in these models.
3. Related Work
We briefly review some commonly used computational methods for calculating the density or distribution of first passage times in GDDMs.
Analytic or semi-analytic methods.
For certain simple DDMs, analytic formulas for the first passage time densities or distributions can be derived, often in the form of infinite series. These methods are fast and accurate, but are typically applicable only for very specific cases. For example, they are available for the standard DDM where all parameters are constant (Navarro and Fuss 2009; Blurton et al. 2012; Gondan et al. 2014). More recently, Srivastava et al. (2017) used martingale theory to derive closed-form formulas that extend certain theoretical analyses to GDDMs.
The approach in this paper is based on numerically extending these fast special cases to much broader classes of GDDMs. Along this line, earlier works (Wang and Pötzelberger 1997; Novikov et al. 1999; Pötzelberger and Wang 2001; Wang and Pötzelberger 2007) computed NPPs, while Jin and Wang (2017), Ichiba and Kardaras (2011), and the present work target FPTDs, although Jin and Wang (2017) and Ichiba and Kardaras (2011) restrict attention to the special case of a one-sided boundary. The FPTD case is more challenging but also more useful for statistical inference since it directly gives the likelihood. A key limitation of many prior approaches (Wang and Pötzelberger 1997; Pötzelberger and Wang 2001; Wang and Pötzelberger 2007; Ichiba and Kardaras 2011; Jin and Wang 2017), is that they rely on Monte Carlo integration, which is infeasible for large-scale real-world applications.
Numerical solutions of governing equations.
These methods exploit the known connections between diffusion processes and partial differential equations (PDEs), called Kolmogorov equations (see the Chapter 8 of Weinan et al. (2021) for an introduction, and Chapter 5.7 of Karatzas and Shreve (2014) for a mathematically rigorous treatment). Both the Kolmogorov forward equation (KFE, also known as Fokker-Planck equation in physics) (Shinn et al. 2020; Diederich and Busemeyer 2003) and the Kolmogorov backward equation (KBE) (Voss and Voss 2008, 2007) have been exploited to derive the FPTDs. Moreover, the first passage time problem can be formulated into Volterra integral equations of renewal type (Smith 2000; Peskir 2002), where applications to DDMs (Smith and Ratcliff 2022; Paninski et al. 2008) have also been explored. In these works, numerical methods, particularly finite difference methods (Thomas 2013), have been developed to solve these equations, enabling the efficient computation of FPTDs in certain cases. Other numerical methods like discontinuous Galerkin methods have also been considered, see Patie and Winter (2008) and references therein. However, these approaches remain computationally expensive, especially in settings where the GDDM configuration differs across trials, including but not limited to cases with trial-specific covariates that vary dynamically over time. For a comprehensive review of these methods, we refer readers to Richter et al. (2023).
Stochastic simulation.
Methods that can sample from the hitting time distribution of the target GDDM can be used to approximate FPTDs via density estimation. Efficient methods for exact sampling are challenging; see Herrmann and Zucca (2020, 2022) and the references therein. If the goal is statistical inference, then these sampling algorithms can be incorporated into a variety of simulation-based inference (SBI) procedures; see Cranmer et al. (2020) for review and Fengler et al. (2021) for an SBI example with DDMs. Nevertheless, the Monte Carlo methods underlying SBI are computationally intensive and can become impractical for large datasets, particularly when involves high-dimensional parameters or covariates that vary dynamically over time and across trials.
4. Main Methods
In this section, we present our main algorithm for computing FPTDs and NPDs. We begin by studying a simple case where analytical results are known in Section 4.1 then generalize it to more complicated cases in Sections 4.2–4.5.
4.1. Single-stage Model
We consider the Brownian motion with drift
| (5) |
starting at . There are two linear absorbing boundaries
with , and, additionally, a truncation boundary at such that on . We name this the “single-stage model” as it is the building block of our method.
Hall (1997) derives the following analytical formulas4 for FPTDs and NPDs in the single-stage model for the special case when and : We define , then
-
The FPTD on the upper boundary is given by
(6) where .
-
Similarly, the FPTD on the lower boundary is given by
(7) where .
- Letting , the NPD at the vertical boundary is given by
(8)
For the single-stage model (5) with a nonzero starting point and a diffusion coefficient that does not equal 1, it is straightforward to obtain its FPTDs and NPD by some shifting and scaling: For notational convenience we further let denote the collection of all the boundary parameters, then we have
| (9) |
| (10) |
| (11) |
An illustration of the single-stage model is shown in Figure 2(a).
Fig. 2:

(a) A single-stage model is a GDDM with constant drift and two linear boundaries , starting at and truncated at . The process can hit one of and before , or hit neither. This results in three distinct sub-probability distributions, corresponding to these three outcomes, with their sub-probability densities plotted by red, purple, and green curves along the boundaries. Sample trajectories, colored to match their respective outcomes, are also displayed. The blue line represents the expected value of the process, given by . In a single-stage model the total area under the three sub-probability density curves sums to 1. (b) The integrated model extends the single-stage model by introducing random variability in the initial position . The expected value of the process in this model is given by , represented by the blue line. The density of , denoted by , is illustrated by the grey curve. We allow to be a sub-probability density function. In an integrated single-stage model, the total area under the three outcome sub-probability density curves sums to the area under the initial grey curve.
4.2. Integrated Single-stage Model
The single-stage model uses deterministically. If, instead, is random, then the corresponding FPTDs and NPDs can be obtained by taking the expectations of (9), (10), and (11) over the distribution of . We call this the integrated single-stage model. If the distribution of has a probability density function supported on , then FPTDs and NPDs for the integrated single-stage model are
| (12) |
An illustration of the integrated single-stage model when has a probability density function is shown in Figure 2(b). When is a discrete random variable, we abuse notation and allow to be a weighted sum of point masses, where () is a probability mass function on and is the Dirac delta generalized function, so that equation (12) still holds formally. For instance, when we have and similarly for and , so that a single-stage model can be viewed as a special case of the integrated single-stage model. We use the same definitions and formulas in equation (12) when is a sub-probability density function, and this usage forms the basis of our multi-stage model below.
4.3. Multi-stage Model
We define multi-stage models to be GDDMs with piecewise constant drift coefficient, piecewise constant diffusion coefficient, and continuous piecewise linear boundaries, which can be divided at their segment points such that each stage reduces to an integrated single-stage model. To be specific, a -stage model is a stochastic process
stopped by a continuous piecewise linear upper boundary , a continuous piecewise linear lower boundary and a vertical boundary , where is a piecewise constant drift function and is a piecewise constant diffusion function. Let be the segment points for , , and prior to , and define and . Then , , and can be defined as
for . Note that we must have and for to ensure the continuity of and . We denote the process during time interval to be the -th (integrated single) stage, which has a drift coefficient , diffusion coefficient , and boundary parameters , for . By the Markov property, the NPD in equation (12) from the ()-st stage becomes the initial position density of the -th stage. Since the process could have hit the upper or lower boundary in an earlier stage, the NPD is a sub-probability density function, which is why we allowed to be a sub-probability density function in the definition of the integrated single-stage model.
To compute the FPTDs and NPDs of a multi-stage model, we first divide the multi-stage model into several integrated single-stage models and then proceed sequentially: For the first stage, the initial position has the same distribution as that of the considered multi-stage model (deterministic or random). Starting from the second stage, the NPD from the previous stage becomes the initial position distribution of the current stage. The FPTDs of each stage correspond exactly to the FPTDs of the original multi-stage model over the corresponding time interval. An illustration of the sequential computation is presented in Figure 3. In settings with the possibility of non-response before , we can also compute the NPP at by integrating the final NPD. Specifically, recalling that the density of on the upper and lower boundaries is denoted as and , respectively, then we can write the whole sequential algorithm as Algorithm 1. A formal derivation of the validity of the algorithm uses the Markov property and the Chapman-Kolmogorov equation with each single-stage model behaving like a sub-probability Markov transition kernel from one stage boundary to the next. We give a concrete example illustrating the complete computation process of applying Algorithm 1 to a multi-stage model in Figure 4.
Fig. 3:

An illustration of the sequential computation from the -th stage to the ()-th stage in a multi-stage model. The -th stage (depicted on the left side of the figure) is an integrated single-stage model, where the density of its starting position is given by (represented by the grey curve). Within this stage, the functions (red curve), (purple curve), and (green curve) are obtained by integrating the formulas (9), (10), and (11) over , respectively. The resulting NPD then serves as the starting position distribution for the -th stage, facilitating the subsequent computation (depicted on the right side of the figure).
Fig. 4:

Example of applying the multi-stage algorithm to a GDDM with drift term , constant and linearly collapsing boundaries that collapse at . The process is divided into 3 single-stage models according to . The FPTDs can be computed sequentially from the early to the late stages, and are plotted along their respective boundaries. Example trajectories are shown with different colors representing which boundary the trajectory first hits (red indicates upper boundary, purple indicates lower).
For multi-stage models, Algorithm 1 is exact in the sense that the only error is the numerical error. We note, however, that equations (6) and (7) are singular at , which can lead to numerical overflow/underflow in Algorithm 1 if the observation time is very close to . In practical scenarios, this issue can usually be avoided via data post-processing that slightly inflates the value of any that happens too close to the beginning of a stage. This will have negligible impact on parameter estimation, particularly in cognitive scientific applications where any numerical corrections are going to lie well within the measurement error of participant reaction times.

4.4. Approximating with the Multi-stage Model
For GDDMs of the same form as the multi-stage model, but with boundaries that are not piecewise linear, it is natural to consider approximating the GDDM with a multi-stage model by approximating the boundaries and with continuous piecewise linear functions. Choosing time points that include any times when or changes values, we can define and to be the continuous piecewise linear functions that are linear on each interval (] and for which and for each . The original process with these new boundaries gives a multi-stage model that approximates the original GDDM. The FPTDs and NPDs of the approximating multi-stage model can be computed with Algorithm 1 and used as approximations of the FPTDs and NPDs for the original GDDM.
Define to be the hitting time of the process to the approximating boundaries. As the approximation gets increasingly fine, meaning , then it is straightforward to show that with probability one under mild regularity conditions on the boundaries (see the proof in Appendix A.1). Showing that the FPTDs also converge is beyond the scope of this paper and presumably requires additional regularity assumptions on the boundaries, such as continuous differentiability. We demonstrate in Sections 5.2 and 5.3 that this approximation method can perform remarkably well in practice.
4.5. Transformations
For GDDMs that cannot be directly approximated with a multi-stage model as in Section 4.4, a transformation into an equivalent GDDM that is amenable to approximation may be possible.
Consider a transform defined as
| (13) |
for , where is one-to-one, increasing, and differentiable with derivative for some is continuous, and for each : is one-to-one, increasing, and differentiable with derivative and inverse . The GDDM in the new coordinate system is
with the distribution of defined by the distribution of . If has density , then has density .
The assumptions on and ensure that and are continuous and that
Hence, the FPTDs of are related to the FPTDs of via
| (14) |
for , and the NPD of at is related to the NPD of at via
| (15) |
The NPP of at is simply the NPP of at . Consequently, any method for approximating the FPTDs and NPDs of the transformed GDDM can be used to approximate the FPTDs and NPDs of the original GDDM using equations (14) and (15). The trick is to find a transformation for which the resulting gives a GDDM that is amenable to approximation.
A particularly simple is standard Brownian motion, perhaps with a random starting point, i.e., equation (2) with and . A wide range of commonly used SDEs can be transformed into standard Brownian motion in this way, including geometric Brownian motion, the Ornstein-Uhlenbeck (O-U) process, and the Brownian bridge, among others. The question of whether a diffusion process can be transformed to a Brownian motion through transformation of the type in equation (13) was raised by Kolmogorov in Kolmogoroff (1931). Cherkasov gave a constructive proof of the necessary and sufficient condition for the existence of such a transformation in Cherkasov (1957), which is now commonly referred to as the Cherkasov condition in the literature. This was recast into a simpler form in Ricciardi (1976), and was later used in Ricciardi and Sato (1983) to obtain the one-sided first passage time density through the integral equation method. We present the Cherkasov condition from Ricciardi (1976) in Appendix A.2, and instead of focusing on the condition itself, we provide specific examples of the transformation from diffusion processes to Brownian motion that are common in practical applications.
DDMs with nonlinear drift.
One simple but important subclass of models that fits this transformation is
| (16) |
with possibly nonlinear time-dependent drift term . The SDE (16) can be solved via a direct integration:
and consequently, through transformation (in this case , so we still use ) we have
| (17) |
The right hand side of (17) is a Brownian motion with initial position . We illustrate the approximate FPTD computation for this example in Section 5.2.
Ornstein-Uhlenbeck model.
The nonstationary Ornstein-Uhlenbeck (O-U) process is defined by the following stochastic differential equation:
| (18) |
where are constants. When it models the “mean-reverting” phenomenon as the process tends towards over time, and it will converge to its stationary distribution as goes to infinity. This process is used, for instance, in physics to model the velocity of a particle under friction, in finance to capture mean-reverting behavior of interest rates and volatility (Gardiner 2009), and in cognitive science to model evidence accumulation and neural dynamics (Usher and McClelland 2001; Brunton et al. 2013).
The solution of (18) is given by Gardiner (2009)
The stochastic integral can be viewed as a timechanged Brownian motion (Doob 1942):
| (19) |
where
is another standard Brownian motion defined by the above stochastic integral. We perform the transformation and so that the transformed process becomes
which is a Brownian motion with initial position .
In Section 5.3, we use this transformation and adopt the procedures in this section to compute the FPTDs of the O-U process. Additionally, for parametric models like the O-U process, we can also study their “multi-stage” versions with piecewise constant parameters. Our Algorithm 1 naturally admits generalization to these models, where the stage breakpoints comprise both the original parameter breakpoints and the segmentation points introduced to approximate the nonlinear transformed boundaries.
Even if the original model has simple boundaries, the transformed model could have complicated boundaries that make approximations based on the multi-stage model less accurate or risk numerical overflow/underflow if an interpolation knot point is placed too close to a reaction time of interest. For instance, the time transformation in the O-U process is exponential and might lead to time dilation issues if one is interested in the FPTDs at large decision times.
4.6. Algorithm Summary and Implementation
The complete process of approximating and/or is as follows:
If necessary, use the methods in Section 4.5 to mathematically transform the GDDM into a representation with constant or piecewise constant and .
If necessary, use the strategy in Section 4.4 to approximate the upper and lower boundaries with piecewise linear functions, so that the approximate model is a multi-stage model.
Use Algorithm 1 in Section 4.3 to calculate the FPTD or the NPP of the multi-stage model.
If necessary, use the methods of Section 4.5 to transform the resulting FPTD from the multi-stage model back into the FPTD of the original GDDM.
In our implementation, all numerical integrations in equation (12) as used by Algorithm 1 are performed with Gauss-Legendre quadrature (see Chapter 5.5 of Sauer (2011) for an introduction). This approach offers higher accuracy with fewer integrand evaluations compared to alternative methods, such as the trapezoidal rule. We specifically benefit from this in our method because our integrands consist of (truncated) infinite series, which are expensive to evaluate. It also means that each within the algorithm needs only to be represented at a small number of predetermined quadrature points. The choice of quadrature order provides a natural trade-off between speed and accuracy: higher orders increase the number of quadrature points and hence the computational cost, but also yield greater precision. Details of the implementation of Algorithm 1 regarding quadrature are in Appendix A.3.1.
There are several other important practical aspects of Algorithm 1 that contribute to its efficiency, which we discuss in detail in Appendix A.3. In our implementation, the core functionality is written in Python, while performance-critical components are optimized using Cython (Behnel et al. 2011), leveraging both the flexibility of Python and the high efficiency of C. OpenMP parallelization is supported to compute likelihoods for different trials independently, thereby accelerating the computation on large datasets. Our code, along with usage examples, including the numerical examples presented in Section 5, will be released as an open-source Python package upon publication for reproducibility. Additionally, our code will be integrated into the HSSM package (Fengler et al. 2025) for hierarchical Bayesian inference of GDDMs.
5. Numerical Examples
In this section, we provide several numerical examples to demonstrate the effectiveness of our method. In Examples 5.1, 5.2, and 5.3, we compute exact or approximate FPTDs using Algorithm 1 and verify the results by comparing them with simulated data. In Section 5.4, we demonstrate the efficiency of Algorithm 1 for likelihood computation, highlighting its speed relative to previous methods and its applicability to statistical inference.
It is worth mentioning that accurately simulating first passage times of stochastic processes is itself a challenging problem (see Tuerlinckx et al. (2001) for a discussion regarding Brownian motion). The usual approach, which we have also adopted, is to discretize the SDE (16) according to the Euler-Maruyama scheme: let … be a temporal grid, simulate according to the distribution of , then proceed as
| (20) |
to simulate an approximate sample path of , where the random variable is distributed as , and all ’s are independent. Such a simulation will, of course, be biased due to the unavoidable discretization error. Then, the first passage time data is the first time such that . However, even if we could simulate exactly on the discrete grid , this would not sample exactly, as it is possible for to cross the barrier between grid points and without exceeding the barrier at either of these grid points.
In our experiments, we simply use a very small step size and a large sample size to reduce the approximation error. More advanced techniques, such as Brownian bridge interpolation, are also commonly used to address this issue (see chapters 6–7 of Glasserman (2004) for a general introduction), however for the purposes of this work, the simulation data serves as a sanity-check more than an object of independent interest.
5.1. FPTDs for GDDMs with Piecewise Constant Drift
We consider a GDDM with piecewise constant drift
constant diffusion and linear collapsing boundaries:
starting at . This is a generic example of a multi-stage model with the same drift terms for all trials.
We use our Algorithm 1 to compute the FPTDs on the upper boundary and lower boundary and compare them with the normalized histogram obtained from 50,000 Monte Carlo samples. The results are shown in Figure 5. The FPTD exhibits corners at all breakpoints of . Despite this complexity, our result visually shows excellent agreement with the empirical densities.
Fig. 5:

Plots of FPTDs and histogram for Example 5.1: a GDDM with piecewise constant drift. First passage times on the upper boundary are displayed on the positive -axis and those on the lower boundary are displayed on the negative -axis so that the whole plot is a valid probability density function.
5.2. FPTDs for GDDMs with Nonlinear Drift and Boundaries
Consider the GDDMs in equation (16) with possibly nonlinear time-dependent drift term and boundaries , . Following the transform discussed in Section 4.5, we can write the transformed boundaries as
and work with the transformed model . We approximate and by piecewise linear functions and use Algorithm 1 to evaluate the FPTD of the approximate multi-stage model. This can apply to any nonlinear drift and boundaries.
We show this case via a GDDM with a sinusoidal drift
constant diffusion , and boundaries
starting at . The upper boundary is the survival function of a Weibull(5, 3) distribution, and is its reflection about the -axis. The choice of a Weibull distribution is guided by relevant examples in prior work (Fengler et al. 2021; Ging-Jehli et al. 2025).
The original boundaries, and the transformed boundaries with their piecewise linear approximations are shown in Figure 6(a) and Figure 6(b), respectively. The computed approximate FPTDs and the histogram consisting of 50,000 samples are displayed in Figure 6(c). The approximate FPTD and the histogram agree well.
Fig. 6:

Example 5.2: a GDDM with sinusoidal drift and Weibull survival boundaries. (a) and (b) illustrate the GDDM before and after transformation. The expected value of the process (blue curves) is transformed from a sinusoidal function to a constant zero. In (b), red dots on the upper boundary and purple dots on the lower boundary mark the knot points used to form piecewise linear boundary approximations. These knots are selected via adaptive linear interpolation (see Appendix A.3 for a detailed description). (c) displays first passage times: those on the upper boundary appear on the positive -axis, while those on the lower boundary appear on the negative -axis, forming a valid probability density function.
To quantitatively justify the approximation, we conduct a one-sample Kolmogorov-Smirnov (KS) test. The null hypothesis is that the sampled first passage time data are distributed according to the computed approximate FPTDs. As shown in Table 1a, the KS test does not suggest rejecting even for sample sizes as large as 100,000. Even though our method of simulating first passage times introduces discretization errors, we believe that these results demonstrate the high accuracy of the FPTD approximation.
Table 1:
Results of the one-sample Kolmogorov-Smirnov tests for different data sizes.
| #Data | 10000 | 20000 | 50000 | 100000 |
|---|---|---|---|---|
| -value | 0.778 | 0.703 | 0.498 | 0.499 |
| (a) Example 5.2: a GDDM with sinusoidal drift and Weibull survival boundaries | ||||
| #Data | 10000 | 20000 | 50000 | 100000 |
| -value | 0.449 | 0.473 | 0.179 | 0.357 |
| (b) Example 5.3: an Ornstein-Uhlenbeck model | ||||
5.3. FPTDs for Ornstein-Uhlenbeck Models
Consider the Ornstein-Uhlenbeck model in equation (18) with boundaries and . According to the transformation given in Section 4.5, the transformed boundaries are given by
We illustrate this case with an example that uses random initial condition . We set the model parameters as , and the original boundaries to be
We follow the procedures described in Section 4.6: interpolate the transformed boundaries sufficiently fine, compute the approximate transformed FPTDs by Algorithm 1, and obtain the original FPTDs by relation (14). Plots of the FPTDs and statistical test results are shown in Figure 7 and Table 1b, respectively. From the results we conclude that our method effectively computes the FPTDs of the O-U model (18).
Fig. 7:

Plots of FPTDs and histogram for Example 5.3: an Ornstein-Uhlenbeck model. First passage times on the upper boundary are displayed on the positive -axis and those on the lower boundary are displayed on the negative -axis so that the whole plot is a valid probability density function.
5.4. Practical Statistical Computing for aDDMs
In the following examples, we show the effectiveness and efficiency of our method for computing the likelihood and inferring parameters for aDDMs. The aDDM incorporates visual attention as a key factor underlying the decision process behind simple choice behavior. It adjusts the drift rate based on instantaneous attention within a given experimental trial, adopting different values depending on whether the participant fixates on choice options A or B at time . Let be the process taking values in {A, B} representing the participant’s visual fixation at time , and let and denote the participant’s numerical ratings of their preferences for options A and B, respectively. The aDDM corresponds to the following SDE (conditioned on ) (Krajbich et al. 2010),
| (21) |
where
is a parameter that reflects the discounting of the non-fixated option, and parametrizes the overall magnitude of the drift. Note that is a piecewise constant function as in the multi-stage model of Section 4.3, but that it will generally be different on each experimental trial, both because a participant’s visual fixation process will generally be different on each trial and because the options presented to the participant can change across trials.
In an experimental setting, a participant’s fixation trajectory is captured using an eyetracker, while the participant’s preference ratings and are collected prior to the choice experiment; together, these can be viewed as known covariates. Because those covariates drive time-varying drift functions, the configuration of the GDDM will be different on each experimental trial. Letting denote the configuration on the -th trial, then the likelihood of is
| (22) |
depends on unknown parameters (e.g. and ) that are shared by all trials, as well as on the trial-specific known visual fixation trajectory and ratings for the subject’s -th trial.
Here, we simulate a collection of visual fixation trajectories , preference ratings and the corresponding dataset of choices and reaction times from a prescribed aDDM model with drift parameters , constant diffusion and symmetric linear collapsing boundaries
starting at . The fixation trajectory on each trial was sampled from a gamma process to mimic the switching of attention in psychological experiments, and the ratings are sampled from a discrete uniform distribution on {1, 2, 3, 4, 5}. The average number of fixations per trial in our simulation is 3.45.
5.4.1. Likelihoods for aDDM given a Dataset
We evaluate the performance of Algorithm 1 for computing likelihoods of the parameters at their true values given the dataset . We compare the speed of our methods with PyDDM (Shinn et al. 2020), a prominent and highly optimized library which we use as a benchmark on speed for the KFE approach (Section 3). When using PyDDM, we can choose the finite difference discretization parameters and which determine the fineness of the temporal and spatial meshes, and as , the numerical solution converges to the true solution of the underlying KFE governing the diffusion process. We test Algorithm 1 with varying quadrature orders and compare its speed-accuracy trade-off against the KFE method evaluated with different choices of and . The results are shown in Figure 8.
Fig. 8:

Speed-accuracy trade-off for Algorithm 1 (blue) and the KFE method as implemented in PyDDM (red solid and dashed). Algorithm 1 performance is shown for increasing quadrature order from 10 to 35. KFE performance is shown for decreasing space-time discretization () from 0.05 to 0.001. In all cases, we used the corresponding method to compute the FPTDs for all trials: , where and the parameters in are those that generated the data. CPU time in each case is the total time to compute FPTDs for all 50,000 trials. The FPTDs can be combined to give the trialnormalized negative log-likelihood (see equation (22)). Since the aDDM in this example corresponds exactly to a multi-stage GDDM, we used Algorithm 1 with a high quadrature order (200 quadrature points per stage) to obtain reference values for and (defined below). Relative errors for Algorithm 1 (blue line, vertical axis) are reported against this reference value of . In four trials the KFE implementation (with these ) gave FPTDs of zero, yielding an infinite approximation of . To provide a more meaningful sense of error for KFE, we also calculated the likelihood excluding those trials, namely , where the “valid” are the 49,996 trials for which KFE gave strictly positive FPTD approximations. The solid red line compares the KFE approximation of to the reference value of . The error plateaus because KFE is forced to exclude the trials where its approximation fails. The dashed red line compares the KFE approximation of to the reference value of . Although this is the wrong reference value for the target problem, it illustrates that the KFE approximation continues to improve as the discretization gets finer.
Figure 8 demonstrates that our method outperforms the KFE method by more than three orders of magnitude at a given target accuracy level. Moreover, our method is more numerically stable when evaluating trials with small likelihoods. PyDDM returned a likelihood of zero for several trials, complicating its use for likelihood-based methods.
The speedup of our method for aDDMs largely stems from its ability to progress in large time steps aligned with saccade times, leading to extremely fast single trial computation speed. The accurate analytical formulas in equations (6)–(8) and the high-order efficient quadrature rules in equation (A3) further contribute to our method’s speed. In contrast, the KFE method requires much finer time discretization in the backward Euler scheme and therefore substantially more floatingpoint operations to attain comparable accuracy.
5.4.2. Statistical Inference of aDDM Parameters
Here we conduct parameter recovery studies for the parameters in both the frequentist and Bayesian settings. We use the maximum likelihood estimator (MLE)
as the frequentist approach. In the Bayesian framework, we place a prior on the parameters and approximate the posterior density
using Markov chain Monte Carlo (MCMC). For both approaches we use Algorithm 1 to evaluate the likelihood. The true and estimated parameters are shown in Table 2.
Table 2:
True values, point estimates and interval estimates of aDDM parameters. The maximum likelihood estimates are reported together with component-wise nonparametric pivotal bootstrap confidence intervals based on 1000 resamples. The optimization is carried out using the trust region method. For the Bayesian approach, we report the posterior means and 95% Bayesian credible intervals. The MCMC sampling was performed using the Metropolis-Hastings algorithm with burn-in iterations followed by draws. The MLE, posterior means and medians (not reported) coincide up to three decimal places. Note that all true parameter values lie within their corresponding 95% confidence intervals and credible intervals.
| True | MLE | 95% confidence interval | posterior mean | 95% Bayesian credible interval | |
|---|---|---|---|---|---|
| 0.7 | 0.697 | [0.690, 0.705] | 0.697 | [0.690, 0.704] | |
| 0.5 | 0.502 | [0.497, 0.507] | 0.502 | [0.497, 0.507] | |
| 2.1 | 2.104 | [2.093, 2.116] | 2.103 | [2.092, 2.115] | |
| 0.3 | 0.304 | [0.300, 0.309] | 0.304 | [0.300, 0.308] | |
| −0.2 | −0.196 | [−0.205, −0.188] | −0.196 | [−0.205, −0.188] |
For maximum likelihood estimation, the numerical optimization takes around 1 minute when run with 32 threads, a computation time that is readily achievable even on a standard desktop computer. For Bayesian inference, an MCMC run with draws completes in 10 hours. In contrast, because a single round of accurate likelihood evaluation with the KFE approach alone requires more than 3 hours, the numerical optimization would take days or more likely weeks, and Bayesian methods would be entirely out of reach. This illustrates that our method enables fast and accurate parameter recovery which no previous methods are capable of.
6. Discussion
In this paper, we propose a novel numerical method for computing the first passage time densities (FPTDs), non-passage densities (NPDs), and non-passage probabilities (NPPs) of a general class of drift diffusion models (DDMs) with two time-dependent boundaries. We utilize analytical formulas for certain single-stage models, which are then flexibly combined via numerical quadrature to accommodate a multi-stage framework. We then generalize to prominent, but previously computationally-intractable models in cognitive science (Krajbich et al. 2012, 2010) and beyond. Our method beats current alternatives by over three orders of magnitude on speed of execution in relevant application scenarios, while maintaining desired accuracy, as shown in Section 5.4.
The benefits over existing approaches are especially notable for the likelihood computation of GDDMs with trial-specific covariates such as the aDDM. Despite strong scientific interest, applications of aDDMs have been constrained by computational challenges. Current approaches to inference in aDDMs rely on unjustified computational simplifications, the so-called time-averaged drift approximations (TADA); see, e.g., (Lombardi and Hare 2021; Molter et al. 2019). The TADA replaces the time-varying drift rate in a single trial of the aDDM with the constant drift rate that is simply the temporal average of the aDDM drift rate on that trial. Although the TADA enables fast parameter inference using analytic formulas, it is not a well-specified statistical model, since the drift rate on a trial depends on the decision time on that trial. In parallel work (Liu et al. 2025), we show that maximum likelihood estimators based on the TADA likelihood are not consistent for the corresponding aDDM parameters. This further illustrates the importance of developing practical computational tools for the complex GDDMs of interest in cognitive neuroscience and other fields.
Our focus here is fast likelihood evaluation. For statistical inference it is often useful to also have likelihood gradients. Since the quadrature points used in our implementation of Algorithm 1 are fixed, the algorithm is inherently end-to-end differentiable by automatic differentiation software. In future work we hope to implement Algorithm 1 in an automatic differentiation package such as JAX (Bradbury et al. 2018) to allow the use of gradient-based statistical inference methods, such as gradient descent for maximum likelihood estimation and Hamiltonian Monte Carlo for Bayesian inference. Strategies like GPU parallelization and parallel numerical integration could be used to gain even further speed-ups, which might be important in practice when using MCMC for inference in large hierarchical Bayesian models with GDDM likelihoods.
Our approach for multi-stage approximation should be generalizable to broader classes of SDEs than the ones considered here if they admit analytic formulas for FPTDs and NPDs in simple cases and if they have the appropriate Markov structure. If analytic formulas cannot be found, the multi-stage approximation might still be useful if accurate approximations of single-stage FPTDs and NPDs can be constructed by other methods, such as SBI.
There are several important mathematical questions that we leave for future work relating to regularity conditions for the existence of FPTDs, regularity conditions for the convergence of approximate multi-stage FPTDs under increasingly fine partitioning, and accuracy of numerical approximations for infinite series truncation, piecewise linear approximation of boundaries, and numerical quadrature. Despite these unresolved issues we believe our algorithms will find immediate use in the psychological and cognitive sciences and will improve the state-of-the-art for statistical inference of GDDMs.
Acknowledgements.
This work was supported by the National Institute of Mental Health (grants P50 MH119467-01 and P50 MH106435-06A1), the Office of Naval Research (MURI Award N00014-23-1-2792), and the Brainstorm Program at the Robert J. and Nancy D. Carney Institute for Brain Science. S.L. was additionally supported by the JBB Endowed Graduate Fellowship in Brain Science.
Appendix A
A.1. Proof of Almost Sure Convergence of First Passage Times under Refined Boundary Approximations
In this section, we establish a continuity result, which serves as the mathematical foundation of approximating the first passage times on curved boundaries by first passage times on their piecewise linear approximations, as described in Section 4.4. We first consider the simplified setting of a Brownian motion hitting a single upper boundary.
Theorem 1 Let be a one-dimensional Brownian motion on a probability space (), and let be a function on that is Hölder continuous with exponent 1/2, satisfying . Suppose that a sequence of continuous functions () converges uniformly to on compact subsets of . Define the first passage times as
Then, converges to almost surely.
Proof of Theorem 1 Define
We prove the desired result in three steps. We first prove that lim . Fix . For any , the function is continuous and attains its minimum on , i.e., when . Since uniformly on , there exists such that for all we have for . Thus, we have that for all and . This implies for . Taking gives lim .
Next, we prove that lim . Fix . By the definition of , we know that for any , there exists and , such that . Since , there exists such that for all we have . Thus, there exists a such that for . This implies for . Taking gives lim . Hence lim .
Finally, we prove that a.s.. The inequality is immediate, so it suffices to show that . Without loss of generality, we assume that is almost surely finite, since for any where , we trivially have .
Take where , then there exist such that for . By the strong Markov property of , we know that is also a Brownian motion. Let be the Hölder semi-norm of , then we have for . Hence, we have
when . By the continuity of and we have , so for .
However, this would imply
| (A1) |
Yet, the law of the iterated logarithm states that
so equation (A1) holds with probability 0. So .
Combining the above three steps, we obtain
from a.s., we conclude that a.s.. □
Returning to the two-boundary setting, and adopting the notation in Section 4.4, the piecewise linear interpolations of the Hölder-1/2 continuous boundaries and , denoted by and respectively, converge to and uniformly on compact subsets of as the interpolation grid is refined (see p35 of De Boor (1978)). Consequently, let and denote the approximate one-sided first passage times, and and their exact counterparts, then we can invoke Theorem 1 to conclude that the and converge almost surely to and on their respective boundaries. Since , it follows that a.s.
A.2. Transformation of a Diffusion Process to a Brownian Motion
Here, we present the Cherkasov condition as outlined in Ricciardi (1976), which provides the necessary and sufficient conditions for the existence of the transformation (13) that converts a diffusion process into a Brownian motion.
Theorem 2 (Ricciardi (1976)) Let be a diffusion process defined on the interval satisfying the SDE (2). If there exists a pair of functions and such that
| (A2) |
then there exists a coordinate transformation of the form (13) such that , the image of under this transformation, has the same dynamics with a standard Brownian motion. This transformation is given by
We take the Ornstein-Uhlenbeck process (18) as an example. Here and , and the Cherkasov condition (A2) reads
We can take . Correspondingly, the transformation is given by . This is the same as the transformation given in Section 4.5. Verifying the Cherkasov condition for general diffusion processes requires analyzing equation (A2) on a case-by-case basis.
A.3. Fast Implementation
In this section, we discuss some practical aspects of our algorithm that contribute to its fast execution, including important details about numerical integration and function representation that are glossed over in the description of Algorithm 1. We present Algorithm 1′, the practical version of Algorithm 1 to conclude this section.
If , then we can halt Algorithm 1 after the evaluation of in the -th stage. Also, note that evaluations of and can be skipped unless they are needed for the final output, since only is propagated across stages.
Formulas (6), (7) and (8) are approximated by truncating the infinite sum to a desired accuracy. The truncation criteria can be used as a way to balance speed and accuracy.
Piecewise linear approximations of the transformed boundaries in Section 4.5 are realized via adaptive linear interpolation, which balances accuracy and computational efficiency by dynamically adjusting both the number and position of interpolation points based on the function’s variability.
More specifically, we adopt the following procedure in our numerical examples (Sections 5.2, 5.3 and A.4.1): we initialize a knot set containing all stage endpoints in the original model, construct a piecewise linear interpolant through the corresponding boundary values, and iteratively refine the knot set by inserting additional knots at locations where the current interpolant attains its largest absolute deviation from the true boundary on a fine evaluation grid. The refinement terminates once this maximum deviation falls below a prescribed tolerance on every subinterval. The tolerance controls the fineness of the resulting interpolation grid.
To compute the likelihood given a dataset, we simply iterate Algorithm 1 over all data. Additional dataset-level speedups can be achieved using the following strategies:
When multiple observations share the same GDDM configuration, a single pass of Algorithm 1 suffices to evaluate their likelihoods simultaneously, eliminating redundant computations. This idea underlies the speedups achieved by many previous methods (e.g., KFE-based approaches). However, such methods slow down considerably when GDDMs vary across trials, whereas our approach adapts seamlessly to both homogeneous and heterogeneous settings while maintaining high computational efficiency.
The computation of each configuration in a dataset is independent of each other, rendering the problem “embarrassingly parallelizable” across configurations — we can distribute the dataset over multiple threads, and since no communication is needed between the sub-tasks, the computational time should ideally be inversely proportional to the number of threads, up to the point where the number of threads equals the number of configurations. Consequently, models such as the aDDM, where each trial has a distinct configuration, can benefit substantially from this form of parallelization. We repeat the timing experiment for Algorithm 1 described in Section 5.4.1 with multiple threads and report the results in Table A1, which demonstrate that our method can easily be further accelerated through parallelization.
Fig. A1:

At each vertical boundary between two stages, probability transfer occurs through a set of precomputed quadrature points—green dots on the output boundaries and grey dots on the input boundaries. The function , evaluated at the quadrature points along the vertical boundary at (denoted as in Algorithm 1′), encapsulates the necessary information for integrating over the probability measure of the starting position , to facilitate computations in the next stage.
A.3.1. Detailed Implementation of the Quadrature
The -point Gauss-Legendre quadrature is given by
| (A3) |
where are the quadrature weights, are the quadrature points on the reference interval . The formula (A3) is exact for polynomials of degree up to . w and can be computed by formulas involving Legendre polynomials but are usually tabulated to great accuracy.
Table A1:
Evaluation times for the aDDM likelihood (22) with 50,000 trial data, using Algorithm 1 under different thread counts.
| # Threads | 1 | 2 | 4 | 8 | 16 | 32 |
|---|---|---|---|---|---|---|
| Time(s) | 5.547 | 2.698 | 1.369 | 0.760 | 0.424 | 0.264 |

To apply formula (A3) to our algorithm, at each stage , we only need to track the density at precomputed quadrature points on each vertical boundary. We then proceed to the next stage by computing the transitional densities from the current quadrature points to the quadrature points on the next vertical boundary (see Figure A1). Regarding the order of quadrature, the functions in equations (6) and (7) are observed to exhibit a more rapid growth of derivatives compared to those in equation (8), hence the integrand in the final stage is less regular than in the earlier stages. Therefore, we typically employ a quadrature rule of equal or higher order in the final stage. In other words, if we let denote the quadrature order for integration in the -th stage, then when lies in the -th stage, we can choose for to achieve more efficient computation.
Here, we present Algorithm 1′, which incorporates numerical integration via (A3) into Algorithm 1. Note that different initial treatments are needed for discrete and continuous , as if is discrete, we only need to directly use formulas (9), (10) and (11), and there is no need for integration in the first stage. In cases where is a mixture of discrete and continuous components, we handle each part accordingly. However, we omit this case in Algorithm 1′ for brevity, as its treatment follows naturally from the discrete and continuous cases.
In Algorithm 1′, we denote the abstract process of acquiring of order as gausslegendre , and the symbol represents the Hadamard (element-wise) product for vectors. Assuming constant time complexity for evaluating the single-stage FPTDs and NPD , the overall time complexity of Algorithm 1′ is .
A.4. Error Analyses of Algorithm 1′
There are three sources of error that contribute to the overall approximation error of the FPTDs and NPDs produced by Algorithm 1′:
Truncating the infinite sums in the single-stage formulas (6), (7) and (8) introduces a controllable truncation error whose magnitude depends on the chosen truncation criterion. Empirically, we observe that the series usually converge numerically with very few terms for that is not too large.
Algorithm 1 evaluates several integrals when propagating NPD across stages and when marginalizing over random starting positions. Approximating these integrals via Gauss-Legendre quadrature (A3) induces a numerical integration error that decreases as the quadrature order is increased.
For general GDDMs with non-piecewise-linear boundaries, the approximation of the original boundaries by their piecewise linear interpolants (Section 4.4) on a time partition introduces an approximation error that goes down as the partition is refined.
The truncation criterion for the infinite series, the quadrature order, and the fineness of the time partition used to interpolate the boundaries can all be tuned to balance computational cost and accuracy. Empirically, we observe that for multi-stage models, using a moderate number of series terms (about 10) together with a moderate Gauss-Legendre quadrature order (about 20–30), Algorithm 1′ already achieves a high accuracy that is more than sufficient for practical purposes. For GDDMs with non-piecewise-linear boundaries, the overall error is typically dominated by the boundary approximations.
A.4.1. A Numerical Study of Errors
Here we illustrate, through a simple example, how boundary approximation and numerical integration impacts the resulting FPTD. We consider a standard Brownian motion
starting at , and study its first passage time to the two square root boundaries
where .
To obtain reference values for the FPTDs, we apply the time change , which transforms the original problem into a first passage time problem for the (unstable) Ornstein-Uhlenbeck process
where
is another standard Brownian motion. Under this transformation, the two absorbing boundaries become constant:
The reference FPTDs are then obtained by solving the KFE governing the transformed problem using a highly accurate spectral element method.
In this example, we take . Following the procedure in Section 4.6, we approximate the boundaries using adaptive piecewise linear interpolation with tolerance . The tolerance controls the fineness of the resulting approximation; we then compute the corresponding approximate FPTDs using Algorithm 1′ at different quadrature orders. We compare these outputs to the reference FPTDs, and the results are displayed in Figure A2 and Table A2.
From Figure A2, we see that the approximate FPTDs closely match the reference FPTDs and are consistent with the simulation results. From Table A2, the total variation distance between the approximate FPTD and the reference FPTD function decreases monotonically as is reduced and as the quadrature order increases, indicating that finer boundary approximations and higher quadrature order lead to systematically more accurate FPTDs.
Fig. A2:

Plots of FPTDs and histogram for a standard Brownian motion hitting two square root boundaries. First passage times on the upper boundary are displayed on the positive -axis and those on the lower boundary are displayed on the negative -axis so that the whole plot is a valid probability density function. The blue dashed line shows the FPTDs produced by Algorithm 1′ with piecewise linear interpolation tolerance and quadrature order for all , the red solid line shows the reference FPTDs obtained from solving KFE to very high accuracy, and the histogram is estimated from simulated first passage time data generated using Euler-Maruyama scheme (20) with step size .
Table A2:
Errors of the FPTDs produced by Algorithm 1′ measured relative to the reference FPTDs. The reported error is the total variation distance between the two density functions, computed over a uniform grid of 1000 time points on [].
| Tolerance | |||||
|---|---|---|---|---|---|
| # Stages | 11 | 32 | 89 | 259 | 577 |
| TV distance | 1.849 × 10−3 | 5.297 × 10−4 | 5.292 × 10−5 | 7.113 × 10−6 | 2.397 × 10−6 |
| (a) We fix the quadrature order and consider a sequence of decreasing interpolation tolerances , which yields increasingly fine piecewise linear boundary approximations and thus multi-stage models with more stages. We then apply Algorithm 1′ to each approximation and report the resulting errors. | |||||
| Quadrature order | 10 | 15 | 20 | 25 | 30 |
| TV distance | 1.482 × 10−3 | 2.959 × 10−4 | 6.446 × 10−5 | 5.319 × 10−5 | 5.292 × 10−5 |
| (b) We approximate the boundaries using adaptive piecewise linear interpolation with , and then apply Algorithm 1′ with a sequence of increasing quadrature orders (taken to be the same across all stages in this experiment). We report the resulting errors. As increases, the errors initially decrease and then plateau since boundary approximation error dominates. | |||||
Footnotes
Competing interests. The authors declare no competing interests.
In the cognitive science context, the terminology “DDM” is typically adopted to denote these models that directly integrate noisy accumulating evidence. The more general model in equation (2), including some examples shown later in this paper (e.g., the Ornstein-Uhlenbeck model), fall within the GDDM framework.
Note that “first passage time density on the upper (lower) boundary” is sometimes interpreted as the density of when only considering one upper boundary (lower boundary ). In this case . These quantities represent different aspects compared to our definition of the FPTD on the upper and lower boundaries and should not be confused.
The statistical model for here is a mixed distribution consisting of a continuous part supported on (response) and a point mass at (no response). Mixed likelihoods of this form are common in survival analysis, for example see the Section 2.2 of Lawless (2011).
Another work along this direction is Anderson (1960). We adopt the results in Hall (1997) since they are simpler and were shown to agree with those of Anderson (1960). Equation (9), (10), and (11) have been slightly rewritten for use in this paper, compared to their original form in Hall (1997).
Data Availability.
The code supporting this study will be released as a package and made publicly available at https://github.com/RiverFlowsInYou98/efficient-fpt upon publication.
References
- Anderson TW (1960) A modification of the sequential probability ratio test to reduce the sample size. The Annals of Mathematical Statistics pp 165–197 [Google Scholar]
- Behnel S, Bradshaw R, Citro C, et al. (2011) Cython: The best of both worlds. Computing in Science & Engineering 13(2):31–39 [Google Scholar]
- Bhattacharya RN, Waymire EC (2021) Random walk, Brownian motion, and martingales. Springer, New York [Google Scholar]
- Blurton SP, Kesselmeier M, Gondan M (2012) Fast and accurate calculations for cumulative first-passage time distributions in Wiener diffusion models. Journal of Mathematical Psychology 56(6):470–475 [Google Scholar]
- Bradbury J, Frostig R, Hawkins P, et al. (2018) JAX: composable transformations of Python+NumPy programs. URL http://github.com/jax-ml/jax
- Brunton BW, Botvinick MM, Brody CD (2013) Rats and humans can optimally accumulate evidence for decision-making. Science 340(6128):95–98. 10.1126/science.1233912, URL http://dx.doi.org/10.1126/science.1233912 [DOI] [PubMed] [Google Scholar]
- Cherkasov I (1957) On the transformation of the diffusion process to a Wiener process. Theory of Probability & Its Applications 2(3):373–377 [Google Scholar]
- Cranmer K, Brehmer J, Louppe G (2020) The frontier of simulation-based inference. Proceedings of the National Academy of Sciences 117(48):30055–30062 [DOI] [PMC free article] [PubMed] [Google Scholar]
- De Boor C (1978) A practical guide to splines, vol 27. springer, New York [Google Scholar]
- Diederich A, Busemeyer JR (2003) Simple matrix methods for analyzing diffusion models of choice probability, choice response time, and simple response time. Journal of Mathematical Psychology 47(3):304–322 [Google Scholar]
- Doi T, Fan Y, Gold JI, et al. (2020) The caudate nucleus contributes causally to decisions that balance reward and uncertain visual information. ELife 9:e56694. 10.7554/eLife.56694 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Doob JL (1942) The Brownian movement and stochastic equations. Annals of Mathematics 43(2):351–369 [Google Scholar]
- Evans NJ, Trueblood JS, Holmes WR (2020) A parameter recovery assessment of time-variant models of decision-making. Behavior research methods 52(1):193–206 [DOI] [PubMed] [Google Scholar]
- Fengler A, Govindarajan LN, Chen T, et al. (2021) Likelihood approximation networks (lans) for fast inference of simulation models in cognitive neuroscience. Elife 10:e65074. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Fengler A, Bera K, Pedersen ML, et al. (2022) Beyond drift diffusion models: Fitting a broad class of decision and reinforcement learning models with hddm. Journal of Cognitive Neuroscience 34(10):1780–1805. 10.1162/jocn_a_01902, URL http://dx.doi.org/10.1162/jocn_a_01902 [DOI] [PubMed] [Google Scholar]
- Fengler A, Xu P, Aisulu O, et al. (2025) Hssm: A widely applicable toolbox for hierarchical Bayesian neurocognitive modeling. URL https://github.com/lnccbrown/HSSM
- Ferebee B (1982) The tangent approximation to one-sided Brownian exit densities. Zeitschrift für Wahrscheinlichkeitstheorie und verwandte Gebiete 61(3):309–326 [Google Scholar]
- Frank MJ, Gagne C, Nyhus E, et al. (2015) fmri and eeg predictors of dynamic decision parameters during human reinforcement learning. Journal of Neuroscience 35(2):485–494. 10.1523/JNEUROSCI.2036-14.2015 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Gardiner CW (2009) Stochastic methods: a handbook for the natural and social sciences. Springer, Berlin, Heidelberg [Google Scholar]
- Ging-Jehli NR, Cavanagh JF, Ahn M, et al. (2025) Basal ganglia components have distinct computational roles in decision-making dynamics under conflict and uncertainty. PLOS Biology 23(1):e3002978. 10.1371/journal.pbio.3002978, URL http://dx.doi.org/10.1371/journal.pbio.3002978 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Glasserman P (2004) Monte Carlo methods in financial engineering, vol 53. Springer, New York [Google Scholar]
- Gondan M, Blurton SP, Kesselmeier M (2014) Even faster and even more accurate first-passage time densities and distributions for the Wiener diffusion model. Journal of Mathematical Psychology 60:20–22 [Google Scholar]
- Hall W (1997) The distribution of Brownian motion on linear stopping boundaries. Sequential analysis 16(4):345–352 [Google Scholar]
- Herrmann S, Zucca C (2020) Exact simulation of first exit times for one-dimensional diffusion processes. ESAIM: Mathematical Modelling and Numerical Analysis 54(3):811–844 [Google Scholar]
- Herrmann S, Zucca C (2022) Exact simulation of diffusion first exit times: algorithm acceleration. Journal of Machine Learning Research 23(138):1–20 [Google Scholar]
- Ichiba T, Kardaras C (2011) Efficient estimation of one-dimensional diffusion first passage time densities via monte carlo simulation. Journal of applied probability 48(3):699–712 [Google Scholar]
- Jin Z, Wang L (2017) First passage time for brownian motion and piecewise linear boundaries. Methodology and Computing in Applied Probability 19(1):237–253 [Google Scholar]
- Karatzas I, Shreve S (2014) Brownian motion and stochastic calculus, vol 113. springer, New York [Google Scholar]
- Kolmogoroff A (1931) Über die analytischen methoden in der wahrscheinlichkeitsrechnung. Mathematische Annalen 104:415–458 [Google Scholar]
- Krajbich I, Armel C, Rangel A (2010) Visual fixations and the computation and comparison of value in simple choice. Nature neuroscience 13(10):1292–1298 [DOI] [PubMed] [Google Scholar]
- Krajbich I, Lu D, Camerer C, et al. (2012) The attentional drift-diffusion model extends to simple purchasing decisions. Frontiers in psychology 3:193. 10.3389/fpsyg.2012.00193 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Kuhn M, Palermo EH, Pagnier G, et al. (2025) Computational phenotyping of effortbased decision making in unmedicated adults with remitted depression. Biological Psychiatry: Cognitive Neuroscience and Neuroimaging 10(6):607–615 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Lawless JF (2011) Statistical models and methods for lifetime data. John Wiley & Sons, Hoboken, NJ [Google Scholar]
- Lee MLT, Whitmore G (2006) Threshold regression for survival analysis: Modeling event times by a stochastic process reaching a boundary. Statist Sci 21(1):501–513 [Google Scholar]
- Lin XS (1998) Double barrier hitting time distributions with applications to exotic options. Insurance: Mathematics and Economics 23(1):45–58 [Google Scholar]
- Liu S, Fengler A, Frank MJ, et al. (2025) Timeaveraged drift approximations are inconsistent for inference in drift diffusion models. arXiv preprint arXiv:251210250 [Google Scholar]
- Lombardi G, Hare T (2021) Piecewise constant averaging methods allow for fast and accurate hierarchical bayesian estimation of drift diffusion models with time-varying evidence accumulation rates. PsyArxiv [Google Scholar]
- Malhotra G, Leslie DS, Ludwig CJ, et al. (2018) Time-varying decision boundaries: insights from optimality analysis. Psychonomic bulletin & review 25(3):971–996 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Metzler R, Redner S, Oshanin G (2014) Firstpassage phenomena and their applications, vol 35. World Scientific, Singapore [Google Scholar]
- Molter F, Thomas AW, Heekeren HR, et al. (2019) Glambox: A python toolbox for investigating the association between gaze allocation and decision behaviour. PloS one 14(12):e0226428. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Navarro DJ, Fuss IG (2009) Fast and accurate calculations for first-passage times in Wiener diffusion models. Journal of mathematical psychology 53(4):222–230 [Google Scholar]
- Novikov A, Frishling V, Kordzakhia N (1999) Approximations of boundary crossing probabilities for a Brownian motion. Journal of Applied Probability 36(4):1019–1030 [Google Scholar]
- Pagnier GJ, Asaad WF, Frank MJ (2024) Double dissociation of dopamine and subthalamic nucleus stimulation on effortful cost/benefit decision making. Current Biology 34(3):655–660 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Palestro JJ, Weichart E, Sederberg PB, et al. (2018) Some task demands induce collapsing bounds: Evidence from a behavioral analysis. Psychonomic bulletin & review 25(4):1225–1248 [DOI] [PubMed] [Google Scholar]
- Paninski L, Haith A, Szirtes G (2008) Integral equation methods for computing likelihoods and their derivatives in the stochastic integrate-and-fire model. Journal of Computational Neuroscience 24:69–79 [DOI] [PubMed] [Google Scholar]
- Patie P, Winter C (2008) First exit time probability for multidimensional diffusions: A pde-based approach. Journal of computational and applied mathematics 222(1):42–53 [Google Scholar]
- Peskir G (2002) On integral equations arising in the first-passage problem for Brownian motion. Journal of Integral Equations and Applications 14(4):397–423 [Google Scholar]
- Pötzelberger K, Wang L (2001) Boundary crossing probability for Brownian motion. Journal of applied probability 38 (1):152–164 [Google Scholar]
- Ratcliff R (1978) A theory of memory retrieval. Psychological review 85(2):59. 10.1037/0033-295x.85.2.59 [DOI] [Google Scholar]
- Ratcliff R, McKoon G (2008) The diffusion decision model: theory and data for two-choice decision tasks. Neural computation 20(4):873922. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Ricciardi L, Sato S (1983) A note on the evaluation of first-passage-time probability densities. Journal of Applied Probability 20(1):197–201 [Google Scholar]
- Ricciardi LM (1976) On the transformation of diffusion processes into the Wiener process. Journal of Mathematical Analysis and Applications 54(1):185–199 [Google Scholar]
- Richter T, Ulrich R, Janczyk M (2023) Diffusion models with time-dependent parameters: An analysis of computational effort and accuracy of different numerical methods. Journal of Mathematical Psychology 114:102756 [Google Scholar]
- Sauer T (2011) Numerical analysis. AddisonWesley Publishing Company, Boston [Google Scholar]
- Shinn M, Lam NH, Murray JD (2020) A flexible framework for simulating and fitting generalized drift-diffusion models. ELife 9:e56938. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Smith PL (2000) Stochastic dynamic models of response time and accuracy: A foundational primer. Journal of mathematical psychology 44(3):408–463 [DOI] [PubMed] [Google Scholar]
- Smith PL, Ratcliff R (2022) Modeling evidence accumulation decision processes using integral equations: Urgency-gating and collapsing boundaries. Psychological review 129(2):235. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Srivastava V, Feng SF, Cohen JD, et al. (2017) A martingale analysis of first passage times of time-dependent Wiener diffusion models. Journal of mathematical psychology 77:94–110 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Strassen V, et al. (1967) Almost sure behavior of sums of independent random variables and martingales. In: Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability, Univ. of California Press; Berkeley, CA, pp 315–343 [Google Scholar]
- Thomas JW (2013) Numerical partial differential equations: finite difference methods, vol 22. Springer Science & Business Media, New York [Google Scholar]
- Tuerlinckx F, Maris E, Ratcliff R, et al. (2001) A comparison of four methods for simulating the diffusion process. Behavior Research Methods, Instruments, & Computers 33:443–456 [DOI] [PubMed] [Google Scholar]
- Usher M, McClelland JL (2001) The time course of perceptual choice: the leaky, competing accumulator model. Psychological review 108(3):550. [DOI] [PubMed] [Google Scholar]
- Voss A, Voss J (2007) Fast-dm: A free program for efficient diffusion model analysis. Behavior research methods 39(4):767–775 [DOI] [PubMed] [Google Scholar]
- Voss A, Voss J (2008) A fast numerical algorithm for the estimation of diffusion model parameters. Journal of Mathematical Psychology 52(1):1–9 [Google Scholar]
- Wang L, Pötzelberger K (1997) Boundary crossing probability for Brownian motion and general boundaries. Journal of Applied Probability 34(1):54–65 [Google Scholar]
- Wang L, Pötzelberger K (2007) Crossing probabilities for diffusion processes with piecewise continuous boundaries. Methodology and Computing in Applied Probability 9:21–40 [Google Scholar]
- Weinan E, Li T, Vanden-Eijnden E (2021) Applied stochastic analysis, vol 199. American Mathematical Soc., Providence, RI [Google Scholar]
- Wiecki TV, Sofer I, Frank MJ (2013) Hddm: Hierarchical Bayesian estimation of the drift-diffusion model in python. Frontiers in neuroinformatics 7:14. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Yartsev MM, Hanks TD, Yoon AM, et al. (2018) Causal contribution and dynamical encoding in the striatum during evidence accumulation. Elife 7:e34929. 10.7554/elife.34929 [DOI] [PMC free article] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Data Availability Statement
The code supporting this study will be released as a package and made publicly available at https://github.com/RiverFlowsInYou98/efficient-fpt upon publication.
