The location of the first maximum in the first sojourn of a Dyck path

For Dyck paths (nonnegative symmetric) random walks, the location of the ﬁrst maximum within the ﬁrst sojourn is studied. Generating functions and explicit resp. asymptotic expressions for the average are derived. Related parameters are also discussed.


Introduction
In the recent paper [8], the distribution of the time at which a Brownian motion is maximal before its first-passage time was studied.
We undertake a related study, by investigating the discrete cousins, namely Dyck paths (nonnegative lattice paths, returning to the x-axis).These celebrated combinatorial objects, enumerated by Catalan numbers 1   N +1 2N N , when their length is 2N , are known by many names, including also Dyck words, nonnegative symmetric random walks, etc.They are also important in Computer Science, since they code planar trees (and binary trees), see e.g.[1].
We find an explicit form of the generating function F (z, u), where the coefficient of z n u k is the number of Dyck paths of length n such that the first maximum within the first sojourn occurs at time (=step) k.From it, we compute the expectation explicitly and asymptotically.It is roughly 1/4 of the length of the walk.
We also compute the average height of the first sojourn, explicitly and asymptotically.(The average height of the whole path has been known for a long time.) For reason of comparison, we also investigate the location of the first maximum of the whole path, which is roughly at 1/2 of the length of the walk.
In a final section, we show how to extend these results from the first sojourn to the r-th sojourn.The parameters here are based on assuming all Dyck paths with at least r sojourns to be equally likely.Most of the old computations can be used and only have to be adapted slightly.

Generating functions
We study the parameter position of the first maximum during the first sojourn of a Dyck path of length n, which we denote by R. Since this parameter makes no sense for the empty path, we assume that n ≥ 1.

Lemma 1
The generating function F (z, u) where z marks the length of the Dyck path and u the parameter R, is given by where Proof.Let ϕ h,i (z) be the generating function of paths of height ≤ h, ending at level i.We are in particular interested in C h (z) = ϕ h,h (z); such a path clearly has height = h.The following system of equations is easy to obtain (see, e.g., [5] for similar calculations): Solving the system with Cramer's rule produces the form .
For the rest of the proof, we consider the decomposition according the the first occurrence of the height h of the first sojourn (for this part, z is replaced by zu, to count the position where this happens) which is equivalent to the announced statement.✷ Theorem 1 The average value R N of the parameter R, assuming that all b N = 1 N +1

2N
N Dyck paths of length 2N are equally likely, is given by where d(k) denotes the number of (positive) divisors of the integer k.
Proof.We differentiate the function F (z, u) w.r.t.u, followed by u := 1, which is (apart from normalization) the generating function of the averages R N : With the substitution z = v/(1 + v 2 ), this expression becomes nicer: The last step was done by partial decomposition and a few rearrangements.Now note that To read off coefficients, we observe that this can be justified either by the Lagrange inversion formula or formal residue calculus.Now, since we have contributions only for even n = 2N , we can continue: The final formula follows from simplifying the first sum.✷

Asymptotics
In the paper [1] we find the procedure how to compute asymptotics of such sums.(See also [3].) We use the following approximation where x = k/ √ N , and it holds for |k| ≤ N 1 2 +ε , and for other values of k, the expression is negligible (exponentially small).Maple could produce this expansion, and more terms would be available.In [7], a procedure is described how to obtain such an approximation efficiently.
A key ingredient to the asymptotics is now the sum This can be attacked with the Mellin transform.Writing again x = 1/ √ N , it becomes a harmonic sum in the notation of [2]; The asymptotics of S can be recovered by computing residues of S * x −s (at s = 1 and s = 0): The final asymptotic formula for the average R N of the parameter R follows from this by multiplying by (N + 1), and taking care of the first two explicit terms, for which Stirling's formula applies.Most of this can be done by Maple.The final result is Theorem 2 The average value R N of the parameter R when considering all Dyck paths of lengths 2N to be equally likely, is given by with more terms being available if necessary.(Smaller terms in (3.1) translate into smaller terms in (3.2); we computed actually more terms and stopped at an arbitrary moment to display them, as they become more and more involved.) So, roughly, we expect the parameter to be about 1/4 of the length of the Dyck path.
Higher moments could also be computed, by higher derivatives of F (z, u), but we did not do it, because the expressions become complicated.

The height of the first sojourn
The height of Dyck paths has been studied for some 35 years: De Bruijn, Knuth and Rice [1] showed that the average height is asymptotic to √ πN − 3 2 (it is one less than the height of the corresponding planar tree).
However, it does not seem that the height of the first sojourn has been studied.Thus, we briefly address this here.Let A h (z) be the generating function of Dyck words of height ≤ h, and B h (z) be the generating function of Dyck words where the first sojourn has height ≤ h.Then, by the fundamental decomposition of Dyck words w.r.t. the first return to the origin, Now, it is known (and easy to derive via the system (2.1)) that . Consequently, again with the substitution z = v/(1 + v 2 ).The generating function of Dyck words where the height of the first sojourn is > h, is then The generating function of the averages (apart from normalization by b N ) is obtained by summing this up over h ≥ 0, viz.

Now we must look at the coefficient of z
The average height of the first sojourn of a Dyck path of length 2N is given by A similar computation as before evaluates this asymptotically: Theorem 4 The average height of the first sojourn of a Dyck path of length 2N is asymptotic to It is interesting to note that in the average height of the Dyck path, no such logarithmic term occurs.

The location of the first maximum
For reasons of comparison, it is also interesting to study the location of the first maximum of the whole path (not only the first sojourn).The computations are somewhat similar. .
We compute again the average, by differentiating this function: And we read off coefficients again: Theorem 5 The average location of the first maximum, assuming that all b N = 1 N +1

2N
N Dyck paths of length 2N are equally likely, is given by The asymptotic evaluation is exactly as before, with the result: The average location of the first maximum, assuming that all b N = 1 N +1

2N
N Dyck paths of length 2N are equally likely, is asymptotic to

The general case
We don't have to stop here.Indeed, we can consider the height (location and value) within the r-th sojourn.The expected number of sojourns (=degree of the root of the associated planar tree) is just 2. Kemp has analyzed the height of trees with root degree exactly r, see [4,6].We consider Dyck paths of length n which have ≥ r sojourns, where r is a parameter.The generating function of them is (zC(z)z) r C(z) = z 2r C r+1 (z).A standard application of the Lagrange inversion formula enumerates the paths: Asymptotically, a proportion of r+1 2 r of all paths has ≥ r sojourns.Now, for the position of the first maximum within the r-th sojourn, we have to consider For the average, we compute Eventually, the same procedure as before produces the asymptotic formula for the position of the first maximum within the r-th sojourn:

And thus
.