{'fraction_non_alphanumeric': 0.0373041262267527, 'fraction_numerical': 0.016103670769397605, 'mean_word_length': 4.095593313993645, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Residence time in presence of moving defects and obstacles

We discuss the properties of the residence time in presence of moving defects or obstacles for a particle performing a one dimensional random walk. More precisely, for a particle conditioned to exit through the right endpoint, we measure the typical time needed to cross the entire lattice in presence of defects. We find explicit formulae for the residence time and discuss several models of moving obstacles. The presence of a stochastic updating rule for the motion of the obstacle smoothens the local residence time profiles found in the case of a static obstacle. We finally discuss connections with applicative problems, such as the pedestrian motion in presence of queues and the residence time of water flows in runoff ponds.


Introduction
The characterization of transport regimes in presence of obstacles and irregular patterns is a classical problem of fluid dynamics [1,2], which is also relevant to a number of biological [3] and engineering [4,5] applications. For instance, a careful design of the shape and the location of the obstacles in microfluidic channels was observed to enhance the mixing of fluid flows [6]. Moreover, crowding effects, generated by obstacles of different size and shape, turn out to significantly affect the transport properties by even altering the sign of the fluxes, as recently reported, e.g., in active matter numerical experiments [7,8].
From the perspective of statistical mechanics, the subject is particularly rich and may be tackled from different routes. One first important question, for instance, concerns the study of anomalous diffusions resulting from the presence of obstacles [9,10]. The onset of anomalous transport stemming from the motion of intruders in a host matrix of slowly moving particles was studied in [11]. The inclusion of flower shape obstacles in billiards was considered in [12] in order to highlight the fractal structure of the diffusion coefficient as a function of control parameters. Another interesting research line concerns the derivation of the hydrodynamic limit of interacting particle systems in an inhomogeneous environment. In [13] it was shown that a detailed characterization of the inhomogeneities at the microscopic level is necessary to determine the structure of the macroscopic diffusion laws in the hydrodynamic limit. Furthermore, in the framework of Zero Range Processes, the inclusion of local defects proved to be a mechanism able to give rise to condensation phenomena in the hydrodynamic limit [14].
The investigation of inhomogeneous random walks continues to be a core topic in statistical mechanics, see e.g. [15] for a general review of the subject.
In this work we study the residence time in a random walk on a one-dimensional lattice in presence of local inhomogeneities. The walker is conditioned to exit through the right endpoint of the lane. Our approach permits explicit computations that nicely complement the classical literature based on the gambler's ruin problem. We consider both symmetric and asymmetric random walks, and discuss the residence time in presence of defects, represented by lattice sites on which the hopping probabilities of the walker are perturbed by a bias. In particular, analytical formulae for the residence time are obtained for random walks with static defects as well as in presence of defects following a stochastic updating rule.
By exploiting the theory of absorbing Markov chains, we succeed, to a certain general extent, to express the residence time of the conditioned random walk in terms of quantities evaluated in the non conditioned walk: the mean number of visits on the generic site of the lattice and the right exit probability. Thus, we dwell on the derivation of analytic formulae for these two quantities and use them to write explicit formulae for the residence time in presence of static defects. The prominent effect of the inclusion of a defect obeying a stochastic dynamics is the smoothing of the local residence time profiles. Our analysis, supported by numerical simulations, also shows that the presence of a stochastic defect may induce a decrease of the residence time. Moreover, for certain distributions of the defect, the residence time turns out to be invariant with respect to the sign of the bias acting on the defect.
Our results are also amenable to a variety of applications. We discuss, in particular, the use of our formalism in the modelling of pedestrians forming queues and also outline useful links with hydrogeological problems. In both cases, we show that the results found in those contexts by means of sophisticated models can be recovered to some extent in the framework of our one dimensional random walk model through a suitable choice of the parameters.
In addition, we show in the Appendix how our results on the stationary local residence time profile connect with the stationary fugacity profiles of arbitrary Zero Range Processes subject to specific injection rates at the boundaries.
Our work is organized as follows. In Sec. 2, we introduce the theoretical set-up for the computation of the residence time, based on the fundamental matrix, and define the main quantities of interest. In Sec. 3 we apply our formalism to both symmetric and asymmetric random walks and obtain explicit formulae in presence of static defects. In Sec. 4 we study the residence time problem in presence of moving defects which follow a stochastic updating rule. The discussion of relevant applications and our conclusions are deferred to Sec. 5, while the analogy with Zero Range Processes is outlined in the Appendix A.

Model and quantities of interest
The problem discussed above is approached in this paper via a one-dimensional model based on a simple random walk. At each side of the lattice an absorbing site is present. We shall first consider a completely general simple random walk and then we will specialize our discussion to particular models describing the effect of static or moving defects.
We thus consider a one-dimensional simple random walk on {0, 1, . . . , L}, called lane. Each element of the lane will be called site. The sites 0 and L are absorbing, so that when the particle reaches one of them the walk is stopped. They will be called, respectively, the left and right exit of the lane. The sites 1, . . . , L − 1 are called transient.
Time t = 0, 1, 2, . . . is discrete and at each time the walker jumps from a transient site i to site j with probability p ij . We assume p ij = 0 if |i−j| = 0 or |i−j| ≥ 2 and p ij > 0 otherwise. Moreover, we shall use the notation p ii+1 = p i and p ii−1 = q i , for any i = 1, . . . , L − 1. We will obviously have that p i + q i = 1. In other words, at each time the walker jumps from the transient site i to its left neighbor i − 1 with probability q i or to its right neighbor i + 1 with We denote by X(t) the position of the walker at time t and by P i and E i the probability associated to the process and the related expected value operator for the walk started at X(0) = i, with i = 1, . . . , L − 1.

Residence time
The residence time is defined by starting the walk at site 1 and computing the typical time that the particle takes to reach the site L provided the walker reaches L before 0. More precisely, we denote by τ = inf{t > 0 : X(t) ∈ {0, L}} the duration of the walk and define the residence time, as where we conditioned to the event RE meaning that the particle exits the lane through the right exit in L. We shall compute the residence time following ideas differing from the approaches already developed in [17][18][19]. In particular, we shall exploit several properties of the fundamental matrix of absorbing Markov chains [16] that will allow us in Section 3 to derive remarkable explicit formulae.
Given a site i, the number of visits n i = |{t > 0 : X(t) = i}| to i counts the number of times that the walker visits the site i. Its mean value for the walk started at site j can be computed using the fundamental matrix, indeed one has that E j [n i ] = N ji , see [16,Theorem 3.2.4]. The mean number of visits of the walker started at 1 conditioned to the event that it exits the lane in L, namely, E 1 [n i |RE], is called local residence time at i. Since, for the walker started at 1, τ = L−1 i=1 n i , the residence time can be written as sum of the local residence times, namely, which proves (2.4).
Using the equality (2.4) the residence time computation can be reduced to the computation of properties of the non conditioned random walk, indeed (2.5)

Mean number of visits
Since, as mentioned above, E 1 [n i ] = N 1i , in order to compute the mean number of visits of the walker at the generic transient site i, we have to compute the first raw of the fundamental matrix, which, we recall, is the inverse of the tridiagonal matrix I−Q given in (2.1). This can be done in several different ways, here we follow the approach proposed in [20], which will show to be very powerful to deduce the explicit formulae that we shall derive in Section 3. Moreover, this approach will also allow an elegant derivation of the analogy that we shall discuss in the Appendix A.
First we note that from [20, equation (1. 2)] the determinant of the matrix I − Q is equal to the last term θ L−1 of the sequence θ i defined by the following recursive equations We borrow from [20] also the definition of the sequence φ i given through the recursive equations The sequences θ i and φ i are not independent, indeed, [20, Lemma 2] states that In particular, since from (2.6) θ 1 = 1, comparing (2.8) and (2.7) both for i = 1, we get Equations (2.10) and (2.7) can be combined to derive a set of recursive equations for N 1j . Indeed, using (2.7) for i = 1 and (2.10) for i = 1, 2, we have Using (2.7) for i = L − 1, and (2.10) for i = L − 1, L − 2, we get Now, we consider (2.7) for i = L − 2, . . . , 2 and multiply it for a suitable coefficient to obtain Exploiting (2.10) for i = L − 1, L − 2, . . . , 1, we get The derivation of equations (2.13) is the key point of our computation: the recursive equations for θ i and φ i , thanks to the introduction of N 1i , have been recast in a form which can be easily solved once it is rewritten in the form of a current conservation law. Indeed, by exploiting the fact that p i + q i = 1, we rewrite the whole set of equations (2.11)-(2.13) as (2.14) Thus, the recursive equations (2.13), together with the boundary equations (2.11) and (2.12), allow to find the mean visit number profile N 1i for i = 1, . . . , L − 1.
We denote by c the conserved quantity defined by equations (2.14) and solve by induction the first L − 1 equations (2.15) 1 We remark that here, and in the following, we shall always adopt the convention that the sum and the product symbols mean, respectively, 0 and 1 when the index corresponding to the first element is greater than the one corresponding to the last one.
ResidenceTime˙RW˙Defect.tex -28 luglio 2021 The last equation p L−1 N 1L−1 = c of the set of equations (2.14) can be then used to set the value of the constant c, indeed, from We remark that, summing N 1i for i = 1, . . . , L − 1, one can use (2.15) to compute the total length of the walk that, in the gambler's ruin language, is the duration of the game. It is a straightforward exercise to show that for the symmetric walk, namely, p i = q i = 1/2 for i = 1, . . . , L − 1, one finds c = 1/L and N 1i = 2 − 2i/L, so that the duration of the walk is The computation is more involved in the homogeneous driven case, i.e., p i = p and q i = q for i = 1, . . . , L − 1 with p = q. In such a case one finds c = (

Right exit probability
The probability of absorption by one particular absorbing state is a classical topic both in the gambler's ruin problem [17,21] and in the absorbing Markov chains literature. Adopting the gambler's ruin point of view, we let t i = 1 − P i [RE] be the probability that the walker started at i exits the lane at 0, namely, the probability that the gambler with initial fortune i is eventually ruined, and we note that We just mention that the same set of equations can be found taking the absorbing Markov chain point of view, indeed we let R be the (L−1)×1 column vector collecting the probability to jump from any transient site to L, i.e., R i1 = 0 if i = 1, . . . , L − 2 and R L−11 = p L−1 . Moreover, we consider the (L − 1) × 1 column vector B such that B i1 = P i [RE] is the probability that the walker started at site i ends its walk in L. From [16, Theorem 3.3.7] we have that B = N R, so that Thus, the computation of the right exit probability is reduced to that of the last column of the fundamental matrix. A computation similar to the one performed in Section 2.2 yields the recursive equations for B i1 analogous to (2.17). Now, we come back to the study of the recursive equations (2.17), which can be rewritten in the more compact form To solve (2.19) we first note that the sequences s i = 1 and r i = i k=1 L−1 r=k p r /q r are solutions of the recursive equations, but do not satisfy the boundary conditions (recall the footnote 1). The statement is trivial for s i , while it requires some effort for r i : which is equal to r i as q i + p i = 1. Thus, exploiting the recursive linearity of the equation Finally, recalling that t i is the probability that the walker started at i exits the lane at 0, we have that the right exit probability is given by In this section we suppose that all the sites 1, . . . , L − 1 share the same behavior, i.e., they are regular, save for one site called defect [17,18]. The defect site is the site 2 ≤ d ≤ L − 2.
More precisely, we assume that p i = p and q i = q = 1 − p for all i = 1, . . . , L − 1 such that i = d and p d =p and q d =q = 1 −p. We shall also writep = p + andq = q − , with ∈ (−p, q) called bias. We will call symmetric the case in which p = q and driven that in which p = q. In the driven case p − q is called drift.
Note that, if = 0 the defect is not present and the classical gambler ruin problem is recovered. The case = −p cannot be considered, because it would mean that the walker is reflected to the left with probability one by the defect and, hence, it would never reach the right-end exit in L. The case = p is meaningful, but rather extreme, indeed, in such a case, the defect pushes the walker to the right with probability one and this means that, once the walker started at 1 has overcome the defect, it will never come back to the part of the lane on the left of the defect. In any case this case is not covered by our study.

The symmetric case
We start by computing c given in (2.16). In the first factor all the terms cancel but the one associated with the defect and the last term q L−1 at the denominator. The sum in the second factor behaves similarly if s ranges from 0 to d − 1. On the other hand, for the remaining L − 2 − (d − 1) terms corresponding to s ranging from d to L − 2, the ratio results equal to 1/q L−1 . Thus, we have To compute the mean number of visits profile (2.15) we use similar arguments, but we have to distinguish three cases. We get The following step is the computation of the right exit probability. From (2.21), distin-ResidenceTime˙RW˙Defect.tex -28 luglio 2021 9 0:45 guishing two different cases, we have (3.24) In view of computing the residence time, we now use (2.4) to give an explicit expression of the local residence time profile: (3.25) Finally, (2.3) is used to compute the residence time (3.26) The leading term for L large, uniformly in the choice of the other parameters d and , is L 2 /3. Thus, the presence of the defect does not affect for large L the diffusive character of the walk. Finally, it is worth noting that equation (3.26), in the case = 0, reduces to the residence time for the symmetric model in absence of defect, namely, for the gambler's ruin problem. Indeed we get Γ = (L 2 − 1)/3 as also shown in [18,Section IV.A].
Note that the model presented and analyzed so far is analogous to the one studied by Ciallella et al. in [17]. Fig. 3.1 shows the dependence of the residence time Γ on the defect site position d in a symmetric random walk, computed through the use of formula (3.26).
In particular, Fig. 3.1 shows that the behavior of the residence time as a function of the defect site d is analogous to that already observed in [17]. In fact, the residence time is maximized or minimized by the position of the defect, depending on the sign of , and it is not affected by the defect intensity when d coincides with the central site of the lattice.

The driven case
We start by computing c given in (2.16). In the first factor all the terms contribute with the ratio p/q but the one associated with the defect, which isp/q, and the last term q L−1 at the denominator. The sum in the second factor behaves similarly if s ranges from 0 to d − 1. On the other hand, for the remaining L − 2 − (d − 1) terms corresponding to s ranging from d to L − 2, the ratio results equal to (p/q) L−2−s (1/q).
In order to make the following formulae more compact and legible, we will use the shorthand notation A = q p andĀ =q p .
With this convention, we have which, after some algebra, yields To compute the mean number of visits profile (2.15) we use similar arguments, but we have to distinguish three cases. We get (3.28) Note that, due to the presence of the term 1/q in the front factor, the second case is not simply a particularization of the first one. The following step is the computation of the right exit probability. Although not strictly necessary to derive the expression of the residence time, we first compute the front factor appearing in (2.21): Distinguishing two different cases, from (2.21) we have 3) we compute the residence time that we report here without adopting the shorthand notations A andĀ. We have ) . (3.31) The leading order in L, uniformly in the choice of the other parameters d and , is L/|p − q|. Thus, the presence of the defect does not affect the ballistic character of the drifted conditioned walk. It is interesting to remark that this behavior, due to the right conditioning, is conserved also for q > p, where in a not conditioned walk we would expect an exponential behavior with L of the mean first hitting time to L. Fig. 3.2 shows the behavior of the residence time Γ in a driven random walk as a function of the defect site d. In particular, two cases have been distinguished, both with positive drift (p − q > 0): the first with < 0 and the second with > 0.  In particular, in the system characterized by p > q and < 0 it can be noted that for small values of the drift there are intervals of the defect position where the residence time is larger than in the symmetric walk case, despite the drive towards the right exit of the lattice (see Fig.3.2, left panel). In both cases ( > 0 and < 0), an increasing value of the drift yields a weaker dependence of the residence time on the position of the defect. In all the cases reported in Fig. 3.2, the residence times have been computed using formula (3.31).

Models with one stochastic defect
In the present work, we are interested in studying the effect of different dynamics of the defect on the mean number of visits and on the local and total residence times. Thus the model with static and fixed defect is modified yielding four different versions. The first two are obtained by assuming that the defect is fixed in space, but it is active ( = 0) or not ( = 0) according to a certain stochastic rule (Models A and B). In the other two, the position of the defect is chosen according to a certain probability distribution over the lattice sites (Models C and D). All the models will be described more in detail and the analytical results obtained in the previous sections are used to derive the mean number of visits and the local and total residence times. These models will be recast as a random walk without defects or with a single static defect through a suitable choice of parameters.
Model A: the defect placed at site d is kept fixed during the random walk, but it is active with probability ψ at each time step. It is immediate to prove that this model generates a behavior which is equivalent to the model with a single static defect at site d, where the defect site is characterized by modified jump probabilities, namelyp = p+ψ andq = q −ψ .
Model B: the defect placed at site d is kept fixed during the random walk, but it is active for a random number of time steps (defect is attached to the lattice), sampled from a Poisson distribution of parameter λ A and non-active for a random number of time steps (defect is detached from the lattice), sampled from a Poisson distribution of parameter λ D [22]. This model generates an average behavior which is equivalent to that of the fixed and static defect model, where the defect site is characterized by jump probabilitiesp = p + λ A λ A +λ D andq = q − λ A λ A +λ D . Model C: the defect position is sampled uniformly over the lattice sites at each time step. This model generates a behavior which is equivalent to that of a driven random walk with jump probabilitiesp = p + L andq = q − L , evolving through a lattice with no defects.
Model D: the defect position is sampled at random from a discrete triangular distribution over the lattice sites at each time step. The triangular distribution is characterized by its mode d and its support [d − a, d + a], with d − a ≥ 2 and d + a ≤ L − 2. This model generates a behavior which is equivalent to that of a non-homogeneous random walk with jump probabilitiesp(i) = p + β i andq(i) = q − β i , where β i is the probability to find the defect at site i.
For Models A and B we shall use results provided in Section 3.1 if the walk is symmetric and those of Section 3.2 if the walk is driven. For Model C we use results of Section 3.2 particularized to the case of no defect. Finally, for Model D we will use the general results of Section 2.   Notice that the mean number of visits and local residence times have been computed using formulae (3.23) and (3.25) respectively. The lattice has a odd length to account for the possibility of properly defining a central site. It can be observed that adding a stochastic dynamics to the defect results in a reduction of the amplitude of the jump discontinuity in the mean number of visits and in the local residence times profiles. Another remarkable effect of the defect is that on the local residence times (see Fig. 4.3, right panels). In fact, the values of the local residence times and the amplitude of the jump discontinuity are remarkably higher when d = 26 than when d = 76. Recalling equation 2.3, it can be seen that this behavior is in agreement to that of Γ as a function of d in Fig. 3.1 when > 0, where the asymmetric effect of the defect position on the total residence time is stronger on the left half of the lattice than it is on the right half. In general, residence times for Model A and B behave exactly as those in the fixed and static defect model, except for a proper scaling of Γ due to the reduced effectiveness of the defect site (whose intensity is diminished by a factor of ψ or λ A λ A +λ D for Model A and B respectively). In Fig. 4.5 the effect of the motion of the defect in terms of mean number of visits and local residence times is reported, comparing the model with fixed and static defect with Models C and D. The mean number of visits and local residence times corresponding to the fixed and static defect model and to Model C have been computed through formulae (3.23), (3.25), (3.28) and (3.30) respectively. The profiles for Model D have been obtained through the general formulae (2.15) and (2.4) where (2.21) has been used for the right-exit probability.
In this case, the main effect of the defect motion on the mean number of visits and on the local residence times is to smooth out the profiles and produce a transition from the discontinuous piecewise-linear behavior of the model with fixed defect to the continuous, smooth profile related to Model C, where the defect can be found uniformly at random in every site of the lattice. In particular, taken Model D, the case a = 0 ideally coincides with the model with fixed defect, since the defect has probability 1 to be placed in a specific site. A noticeable aspect is the effect of the defect motion on the residence time Γ. It can be observed that, independently of the value of (with > 0) and from the width of the triangular distribution (parameterized by the width normalized to the lattice length, namely a/L), the residence time in presence of a moving defect is always shorter than that of the system with fixed defect, at least when the center d of the distribution coincides with the central lattice site or it is placed at its left, see left and central panels in Fig. 4.6. When > 0 and the center of the distribution is placed in the right half of the lattice, there is only a finite interval of values of a/L for which the residence time in presence of the moving defect is shorter than the corresponding for the fixed defect, as can be seen from the right panel in Fig. 4.6.
The most important observation about this model is the residence time invariance with respect to the sign of when Γ is a function of the defect motion (to be intended as the triangular distribution spread a). In fact, the behavior of Γ shown in Fig. 4.6 is also obtained for < 0, except for the fact that the behavior observed for d = 25 in the case > 0 is recovered for d = 75 and < 0 and vice-versa. This symmetry with respect to the central site of the lattice for different signs of is of the same nature of that shown in Fig. 3.1 and can be traced back to the effects of the hopping probabilities p k and q k on formulae (2.15), (2.16) and (2.21). More specifically, this result can be explained as follows: defect moving around the central lattice site and having positive intensity will increase the local residence time in the sites to the right of the center and decrease it in those to the left; on the other hand, defect moving around the central lattice site and with negative intensity will have the opposite effect. In these two systems, the local residence times will be distributed differently (in particular, they will be symmetric with respect to the lattice center) but they will sum up to the same value of Γ.
These remarkable results on the behavior of such a system have been tested against computer simulations (see Fig. 4.6, central panel, for the residence times resulting from simulations). In particular, a random walk on the line algorithm has been implemented which takes into account the dynamics of the defect site. A large enough number (15 · 10 6 ) of walks have been simulated and averages over the resulting set of trajectories have been computed. As shown in the central panel of Fig. 4.6, an optimal agreement between simulations and theory is obtained for all the tested values of and a.

Discussion and conclusions
We have studied the residence time in the framework of a simple random walk on a 1D lattice that we called lane. By using the theory of absorbing Markov chains we have first derived the expression (2.5), in which the residence time is written in terms of the probability that the walker started at a generic site i exits the lane through the right exit at L and the mean number of visits that the walker pays at site i. For these building bricks we have found general expressions, in Sections 2.2 and 2.3, which are valid for any choice of the left an right jump probabilities, q k and p k , defining the walk.
These results have then been used in Section 3 to write the residence time in the case of a homogeneous walk with a single static defect. In particular, in Sections 3.1 and 3.2, we have derived explicit expressions for the residence time in the symmetric and in the driven case. Those expressions revealed to be very useful in the following sections to study cases in which a defect dynamic is considered. In particular we have shown that adding a dynamic to the defects induces a smoothing of the observable behaviors that present abrupt jumps in the case of a static defect.
Although the simple random walk is a very basic model, we have seen how it can provide general interesting insights for the residence time behavior, such as the large L behavior. One of the interesting features of studying simplified models is the fact that they can help to shed some light on the behavior of much more complex systems. We want to discuss two interesting cases coming from two very different applicative contexts.
We first consider the crowd dynamics problem introduced in the paper [23]: pedestrians move from the left to the right through a rectangular corridor avoiding other pedestrians which form vertical queues, namely, queues orthogonal with respect to the direction of motion of the passing pedestrians. The model introduced in this paper is very complicated, many parameters accounting for the several interaction acting on the pedestrians are considered, and it is used to study in detail the different effects that enter in the computation of the residence time, i.e., the mean time needed by the passing pedestrian to cross the corridor. In particular the authors compute the quantity I pas , which is defined as the ratio between the residence time in absence of queues and the residence time in presence of queues. In particular, in [23, Fig. 8], the authors study its behavior as a function of the parameter φ, which is the parameter weighting the repulsive force that the passing pedestrians exert on the queuing ones.
In our simplified modelling, the walker can be thought as the passing pedestrian and the effect of the queuing pedestrians on it can be reduced to the presence of the defect site. Our model can be thought as a sort of effective model for the passing pedestrian problem with the parameter , associated with the defect, containing all the informations on the interactions conditioning the motion of the passing pedestrians. For instance, coming back to [23, Fig. 8], it is possible to use our explicit formula (3.31) for the residence time in the driven case to fit the data of [23,Fig. 8] assuming that the effective is related to the parameter φ by the very general function If we consider, in our model, p = 0.55 and q = 0.45, from the extreme data in the picture we have thatā = 0.2230 andb = 0.4152. Performing the best fit we find α = 6.043 and c = 1.074. The comparison between our prediction and the data in [23] is depicted in Fig.5.7.  Fig. 8]. Dotted line with empty circles represents the data to be fitted, while the solid line is the analytical I pas as a function of (φ) obtained by using formula (3.31) for the residence times and fitting the parameters in formula (5.32).
Equation (5.32) gives the effective value, as a function of the parameter φ, of the decrease in probability that the passing pedestrian crosses the queue when it reaches it. It is worth nothing that this result is robust in the sense that the fitting parameters α and c appear to depend poorly on the choice of the left and right jumping probabilities p and q in the simple random walk model.
Another relevant application of the residence time idea is related to stormwater runoff ponds design. Water running off from residential and urban areas, possibly after severe meteorological events like storms and heavy rainfalls, is known to drain and transport lots of different pollutants, which may result in a serious threat for water or marine ecosystems. To prevent drained pollutants to reach delicate water ecosystems, natural and artificial ponds are used to accelerate the deposition and absorption of undesired substances and components. As it has been demonstrated [24], residence times of the water flow inside the ponds are of crucial impact on their effectiveness. In particular, the higher the residence time, the higher is the pond efficiency in terms of deposition of pollutants [25]. Different design strategies, aimed at increasing the efficacy of the ponds, have been proposed. For instance, the installation of baffles, underwater berms or surface islands, acting as obstacles to the water flow, can increase significantly the residence time [26,27].
Design aspects, like the maximization of the residence time, are studied in the literature by means of fluidodynamic approaches [26]. It is very interesting to remark that the qualitative behavior of those results can be interpreted by using our random walk model. We analyze, for instance, the results discussed in [26] where a rectangular pond is considered and the water inlet and outlet are placed symmetrically on the shortest sides of the pond. In particular we focus on the results reported in [26,Fig. 5], where RTD curves are plotted versus time in five cases: pond with no baffle (case 1), pond with an island placed at one quarter of pond length from the inlet (case 5), pond with an island placed at one tenth of pond length from the inlet (case 6), pond with a subsurface bern placed at one quarter of pond length from the inlet (case 7), pond with a subsurface bern placed at half pond length from the inlet (case 8). Those curves have been found by solving numerically suitable fluidodynamic equations.
These geometries are compatible with our 1D model, since the islands and the berns act symmetrically along the direction parallel to the shortest sides of the pond, namely, the direction orthogonal to the main water motion.
Data in [26,Fig. 5] show that the residence time in case 5 is larger than that in case 6, which, on turn, is larger than the residence time in case 1. This is precisely what we observe in our random walk driven model discussed in Section 3.2. Indeed, if one focuses on any of the curves with larger drift plotted in the left panel of Fig. 3.2, one can see that the residence time increases when a defect is placed at the site 10 (one tenth of the length of the lane) and increases even more when it is placed at the site 25 (one fourth of the length of the lane). The random walk model does not appear to be completely effective when berns are considered. Indeed, data in [26,Fig. 5] show that the residence time in case 7 (very similar to the one measured in case 5) is larger than that in case 8, which, on turn, is larger than the residence time in case 1. The fact that the residence time in case 7 is larger than that in case 1 is compatible with our results plotted in the left panel of Fig. 3.2. On the other hand, based on our analysis, we would have expected that the residence time in case 8 would have been very similar to the one measured in case 7, but this seems not to be the case.
Summarizing, we have developed a rather complete theory of the residence time for the random walk in presence of defects. In particular, we have found explicit expressions in the case of a single defect, both in the symmetric and in the driven case. We have discussed our results in the framework of our abstract model and we have also shown how they can help, to some extent, to understand the behavior of much more complex systems.

A. Analogy with the stationary occupation number profile
We consider a system of many independent particles performing a random walk on 1, . . . , L− 1 in continuous time. We suppose particles move with rate one according to the jump probabilities introduced in Section 2. Moreover, particles are introduced with rate α at site 1 and δ at site L − 1.
This system can be recast as a Zero Range Process with open boundaries and intensity function associated with site i equal to the number of particles occupying such a site [28,29].
The mean value of particles occupying each site of the lane 1, . . . , L − 1 at stationarity satisfy a set of recursive equation identical to equations (2.14) provided we choose α = 1 and δ = 0. See, for instance, [30, equation (13)], where the equations are reported for a case in which the jump probabilites are spatially homogeneous, or [29, equation (14)], where the equations are again reported for a case in which the jump probabilites are spatially homogeneous but the presence of a defect site is taken into account. The generalization of the formulae in [29,30] to the case of arbitrary jumping probabilities is straightforward.
Thus, we can conclude that the mean number of visits profile of a random walk with two absorbing site coincides with the stationary occupation number profile of the independent particles Zero Range Process with same jumping probabilities and inlet rate 1 on the left-end of the lane and 0 on the right-end of the lane.
In [29] the stationary occupation number profile has been explicitly computed in the symmetric case discussed here in Section 3.1 for the defect at the center of the lane. Indeed,