aa r X i v : . [ m a t h . C O ] A p r CULMINATING PATHSMIREILLE BOUSQUET-MÉLOU AND YANN PONTYAbstra t. Let a and b be two positive integers. A ulminating path is a path of Z thatstarts from (0 , , onsists of steps (1 , a ) and (1 , − b ) , stays above the x -axis and ends at thehighest ordinate it ever rea hes. These paths were (cid:28)rst en ountered in bioinformati s, in theanalysis of similarity sear h algorithms. They are also related to ertain models of Lorentziangravity in theoreti al physi s.We (cid:28)rst show that the language on a two letter alphabet that naturally en odes ulminatingpaths is not ontext-free.Then, we fo us on the enumeration of ulminating paths. A step by step approa h, om-bined with the kernel method, provides a losed form expression for the generating fun tionof ulminating paths ending at a (generi ) height k . In the ase a = b , we derive from thisexpression the asymptoti behaviour of the number of ulminating paths of length n . When a > b , we obtain the asymptoti behaviour by a simpler argument. When a < b , we onlydetermine the exponential growth of the number of ulminating paths.Finally, we study the uniform random generation of ulminating paths via various methods.The reje tion approa h, oupled with a symmetry argument, gives an algorithm that is linearwhen a ≥ b , with no pre omputation stage nor non-linear storage required. The hoi e of thebest algorithm is not as lear when a < b . An elementary re ursive approa h yields a linearalgorithm after a pre omputation stage involving O ( n ) arithmeti operations, but we alsopresent some alternatives that may be more e(cid:30) ient in pra ti e.1. Introdu tionOne-dimensional latti e walks on Z have been extensively studied over the past 50 years.These walks usually start from the point , and take their steps in a pres ribed (cid:28)nite set S ⊂ Z . Alarge number of results are now known on the enumeration of sub-families of these walks, and anbe obtained in a systemati way on e the set S is given. This in ludes the enumeration of bridges(walks ending at 0), meanders (walks that always remain at a non-negative level), ex ursions(meanders ending at level 0), ex ursions of bounded height, and so on. In parti ular, the natureof the asso iated generating fun tions is well understood: these series are always algebrai , andeven rational for bounded walks [2, 5, 10, 8, 19, 26, 31, 32, 37℄. These algebrai ity propertiesa tually re(cid:29)e t the fa t that the languages on the alphabet S that naturally en ode these familiesof walks are ontext-free, and even regular in the bounded ase. In many papers, these one-dimensional walks are a tually des ribed as dire ted two-dimensional (2D) walks, upon repla ingthe starting point by (0 , and every step s by (1 , s ) . This explains why ex ursions are often alled generalized Dy k paths (the authenti Dy k paths orrespond to the ase S = { , − } ).This two-dimensional setting allows for a further generalisation, with steps of the form ( i, j ) ,with i > and j ∈ Z , but this does not a(cid:27)e t the nature of the asso iated languages andgenerating fun tions. The uniform random generation of these walks has also been investigated,through a re ursive approa h [39, 24, 20℄ or using an anti ipated reje tion [6, 33℄.This paper deals with a new lass of walks whi h has re ently o urred in two independent ontexts, and seems to have a more ompli ated stru ture than the above mentioned lasses: ulminating walks. A 2D dire ted walk is said to be ulminating if ea h step ends at a positivelevel, and the (cid:28)nal step ends at the highest level ever rea hed by the walk (Figure 1). We fo usMBM was partially supported by the Fren h (cid:16)Agen e Nationale de la Re her he(cid:17), proje t SADA ANR-05-BLAN-0372. YB was partially supported by the a tion "Aspe ts mathématiques et algorithmiques des réseauxbio himiques et évolutifs ( π -vert)" of ACI Nouvelles Interfa es des Mathématiques, Fren h Ministry of Resear h.1 MIREILLE BOUSQUET-MÉLOU AND YANN PONTY m m mm m m m m m m m m m mab Figure 1. A ulminating path (for a = 5 and b = 3 ) and the orresponding word.here on the ase where the steps are (1 , a ) and (1 , − b ) , with a and b positive, hoping that thisen apsulates all the possible typi al behaviours.In the ase a = b = 1 , ulminating walks have re ently been shown to be in bije tion with ertain Lorentzian triangulations [18℄, a lass of ombinatorial obje ts studied in theoreti alphysi s as a model of dis rete two-dimensional Lorentzian gravity. Using a transfer matrixapproa h, the authors derived the generating fun tion for this ase. We give two shorter proofsof their result. Also, while it is not lear how the method used in [18℄ ould be extended to thegeneral ( a, b ) - ase, one of our approa hes works for arbitrary values of a and b .The general ( a, b ) - ase appears in bioinformati s in the study of the sensitivity of heuristi homology sear h algorithms, su h as BLAST, FASTA or FLASH [1, 34, 11℄. These algorithmsaim at (cid:28)nding the most onserved regions (similarities ) between two genomi sequen es (DNA,RNA, proteins...) while allowing ertain alterations in the entries of the sequen es. In orderto avoid the supposedly intrinsi quadrati omplexity of the deterministi algorithms, theseheuristi algorithms (cid:28)rst onsider identi al regions of bounded size and extend them in bothdire tions, updating the s ore with a bonus for a mat h or a penalty for an alteration, until thes ore drops below a ertain threshold. The evolution of the s ore all the way through the (cid:28)nalalignment turns out to be en oded by a ulminating walk.In [30℄, we (cid:28)rst studied the probability of a ulminating walk to ontain ertain patterns alled seeds, as some re ent algorithms make use of them to relax the mandatory onservation ofsmall an horing portions. Then, we proposed a variant of the re ursive approa h for the randomgeneration of these walks. Finally, we observed that the naive reje tion-based algorithm, whi h onsists in drawing uniformly at random up and down steps and reje ting the resulting walk ifis not ulminating, seemed to be linear (resp. exponential) when a > b (resp. a < b ). Thisobservation, whi h is losely related to the asymptoti enumeration of ulminating walks, is on(cid:28)rmed below in Se tion 6.2.To on lude this introdu tion, let us (cid:28)x the notation and summarize the ontents of this paper.Let a and b be two positive integers. A walk (or path) of length n is a sequen e (0 , η ) , . . . , ( n, η n ) su h that η = 0 and η i +1 − η i ∈ { a, − b } for all i . The height of the walk is the largest of the η i 's, while the (cid:28)nal height is η n . The walk is ulminating if the two following onditions hold: ∀ i ∈ [1 , n ] , η i > (Positivity), ∀ i ∈ [0 , n − , η i < η n (Final re ord) . See Figures 1 and 2 for examples and ounter-examples. We en ode every walk by a word onthe alphabet { m, m } in a standard way: ea h as ending step (1 , a ) is repla ed by a letter m and ea h des ending step (1 , − b ) is repla ed by a letter m . We denote by { m, m } ∗ the set ofwords on the alphabet { m, m } . From now on, we identify a path and the orresponding word.Sin e these obje ts are essentially one-dimensional, we will often use a 1D vo abulary, saying,for instan e, that our paths take steps + a and − b (rather than (1 , a ) and (1 , − b ) ). We hope thatULMINATING PATHS 3Figure 2. Two walks that are not ulminating, violating the (cid:28)nal re ord on-dition (left) or the positivity ondition (right).this will not ause any onfusion. Without loss of generality, we restri t our study to the asewhere a and b are oprime.For any word w , we denote by | w | m (resp. | w | m ) the number of o urren es of the letter m (resp. m ) that it ontains. We denote by | w | the length of w . The fun tion φ a,b : { m, m } ∗ → N maps a word to the (cid:28)nal height of the orresponding walk. That is, φ a,b ( w ) = a | w | m − b | w | m .The ulmination properties an be translated into the following language-theoreti de(cid:28)nition:De(cid:28)nition 1.1. The language of ulminating words is the set C a,b ⊂ { m, m } ∗ of words w su hthat, for every non-empty pre(cid:28)x w ′ of w : φ a,b ( w ′ ) > (Positivity) , and, for every proper pre(cid:28)x w ′ of w : φ a,b ( w ′ ) < φ a,b ( w ) (Final re ord) . The main result of Se tion 2 is that the language C a,b is not ontext-free. In Se tion 3,we obtain a losed form expression for the generating fun tion of ulminating walks. Thisexpression is ompli ated, but we believe this only re(cid:29)e ts the omplexity of this lass of walks.This enumerative se tion is losely related to the re ent work [10℄, devoted to a general studyof ex ursions on(cid:28)ned in a strip. In parti ular, symmetri fun tions play a slightly surprisingrole in the proof and statement of our results. We then derive in Se tion 4 the asymptoti number of ulminating walks, in the ase a ≥ b . Our result implies that, asymptoti ally, apositive fra tion of (general) ( a, b ) -walks are ulminating if a > b . We prove that this fra tiontends to 0 exponentially fast if a < b . More pre isely, we determine the exponential growthof the number of ulminating walks. This asymptoti se tion uses the results obtained in [5℄on the exa t and asymptoti enumeration of ex ursions and meanders. Finally, in Se tion 6,we present several algorithms for generating uniformly at random ulminating walks of a givenlength. Our best algorithms are linear when a ≥ b . When a < b , the hoi e of the best algorithmis not obvious. An elementary re ursive approa h yields a quasi-linear generating stage butrequires the pre omputation and storage of O ( n ) ∼ ponty/walks. Figure 3 shows random ulminating paths oflength 1000 generated with our software, for various values of a and b .2. Language theoreti propertiesWe denote by C a,b ⇒ k the subset of C a,b that onsists of the walks (words) ending at height k .It will be easily seen that this language (for a (cid:28)xed k ) is regular. However, we shall prove thatthe full language C a,b is not ontext-free. We refer to [27℄ for de(cid:28)nitions on languages. MIREILLE BOUSQUET-MÉLOU AND YANN PONTY Figure 3. Random ulminating paths of size , when ( a, b ) = (1 , , ( a, b ) =(2 , , ( a, b ) = (1 , . In the (cid:28)rst two ases, four paths are displayed, while forthe sake of larity, only one path is shown in the third ase.2.1. Culminating walks of bounded heightProposition 2.1. For all a, b, k ∈ N , the language C a,b ⇒ k of ulminating words ending at height k is regular.Proof. The ulminating paths of (cid:28)nal height k move inside a bounded spa e. This allows us to onstru t a (deterministi ) (cid:28)nite-state automaton that re ognizes these paths. The states of thisULMINATING PATHS 5automaton are the a essible heights (that is, , , . . . , k ), plus a garbage state ⊥ . The initialstate is , the (cid:28)nal state is k , and the transition fun tion δ is given, for ≤ q < k , by: δ ( q, m ) = (cid:26) q + a if q ≤ k − a, ⊥ otherwise , δ ( q, m ) = (cid:26) q − b if q > b, ⊥ otherwise , while δ ( k, · ) = δ ( ⊥ , · ) = ⊥ . Clearly, this automaton sends any word attempting to walk below (resp. above k ) in thegarbage ⊥ , where it will stay forever and therefore be reje ted. Moreover, it only a epts thosewords ending in the state k . Hen e this automaton re ognizes exa tly C a,b ⇒ k . Sin e the statespa e is (cid:28)nite, C a,b ⇒ k is a regular language.2.2. Unbounded ulminating walksProposition 2.2. For all a, b ∈ N , the language C a,b of ulminating walks is not ontext-free.Proof. Re all that the interse tion of a ontext-free language and a regular language is ontext-free [27℄. Let L be the following regular language: L = m ∗ .m ∗ .m ∗ . It an be seen as the languageof (cid:16)zig-zag(cid:17) paths. Let K = C a,b ∩ L . It is easy to see that K = { m i .m j .m k | i > , bj < ai and bj < ak } . Assume that C a,b is ontext-free. Then so is K , and, by the pumping lemma for ontext-freelanguages [27, Theorem 4.7℄, there exists n ∈ N su h that any word w ∈ K of length at least n admits a fa torisation w = x.u.y.v.z satisfying the following properties: ( i ) | u.v | ≥ , ( ii ) | u.y.v | ≤ n , ( iii ) ∀ ℓ ≥ , w ℓ := x.u ℓ .y.v ℓ .z ∈ K .Sin e a and b are oprime, there exist i > n and j > n su h that ia − jb = 1 (this is theBa het-Bezout theorem). Hen e the word w = m i m j m i belongs to K . In the rest of the proof,we will refer to the (cid:28)rst sequen e of as ending steps of w as A , to the des ending sequen e as B and to the se ond as ending sequen e as C .Where is the fa tor u.y.v ? ℓ w ℓ Failing ondition A m i − h .m j .m i Pos.: φ ( m i − h .m j ) = 1 − ah ≤ B m i .m j + h .m i Pos.: φ ( m i .m j + h ) = 1 − bh ≤ C m i .m j .m i − h Fin. re .: φ ( w ℓ ) = φ ( m i ) − ah ≤ φ ( m i ) A ∪ B | u | m . | u | m + | v | m . | v | m = 0 2 m p .m k .m k ′ .m p ′ .m i w ℓ / ∈ L (Too many peaks) u = m k , v = m k ′ m i + k .m k ′ + j .m i Final re ord: φ ( w ℓ ) = φ ( m i + k ) + 1 − bk ′ ≤ φ ( m i + k ) B ∪ C | u | m . | u | m + | v | m . | v | m = 0 2 m i .m p .m k .m k ′ .m p ′ w ℓ / ∈ L (Too many valleys) u = m k , v = m k ′ m i .m j + k .m k ′ + i Pos.: φ ( m i .m j + k ) = 1 − kb ≤ Table 1. Why the pumping lemma is not satis(cid:28)ed.In Table 1, we onsider all eligible fa torisations of w of the form w = x.u.y.v.z . Five asesarise, depending on whi h part of w ontains the fa tor u.y.v . Condition ( ii ) implies that thisfa tor annot overlap simultaneously with the parts A and C . Ea h of the ases A ∪ B and B ∪ C is further subdivided into two ases, depending on whether u and v are monotone or not. MIREILLE BOUSQUET-MÉLOU AND YANN PONTYFor ea h fa torisation, the table gives a value of ℓ for whi h the word w ℓ does not belong to K . This is justi(cid:28)ed in the rightmost olumn: either w ℓ does not belong to the set L of zig-zagpaths, or the positivity ondition does not hold, or the last step of the walk is not a re ord.On e all the possible fa torisations have been investigated and found not to satisfy the pump-ing lemma, we on lude that the languages K and C a,b are not ontext-free.3. Exa t enumerative resultsIn this se tion, we give a losed form expression for the generating fun tion of ( a, b ) - ulminating walks. More pre isely, we give an expression for the series ounting ulminatingwalks of height k , and then sum over k . This summation makes the series a bit di(cid:30) ult to han-dle, for instan e to extra t the asymptoti behaviour of the oe(cid:30) ients (Se tion 4). We believethat this omplexity is inherent to the problem. In parti ular, we prove that the generatingfun tion of (1 , - ulminating walks is not only trans endental, but also not D-(cid:28)nite. That is, itdoes not satisfy any linear di(cid:27)erential equation with polynomial oe(cid:30) ients [37, Ch. 6℄.3.1. Statement of the results and dis ussionLet us (cid:28)rst state our results in the (1,1)- ase and then explain what form they take in thegeneral ( a, b ) - ase.Proposition 3.1. Let a = b = 1 and k ≥ . The length generating fun tion of ulminatingpaths of height k is C k ( t ) = t k F k − = t U − U U k − U k = 1 − U U U k − U k , where • F k is the k th Fibona i polynomial, de(cid:28)ned by F = F = 1 and F k = F k − − t F k − for k ≥ , • U and U are the two roots of the polynomial u − t (1 + u ) : U , = 1 ∓ √ − t t , • U stands for any of the U i 's.The generating fun tion of ulminating walks, C ( t ) = 1 − U U X k ≥ U k − U k , (1)is not D-(cid:28)nite.The above expression of C ( t ) is equivalent to the ase x = y = 1 of [18, Eq.(2.26)℄.The (cid:28)rst expression of C k , in terms of the Fibona i polynomials, is learly rational. Asexplained in Se tion 2.1, the language of ulminating walks of height k is regular for all a and b ,so that the series C k will always be rational. Of ourse, C k is simply when k < a . When k = a ,there is only one ulminating path, redu ed to one up step, so that C k = t . More generally, thefollowing property, illustrated in Figure 4 and proved in Se tion 3.2.1, holds.Property 3.2. For k ≤ a + b , there is at most one ulminating path of height k .As soon as k > a , ulminating walks of height k have at least two steps. Deleting the (cid:28)rstand last ones gives C k = t W k , where W k ounts walks (with steps + a, − b ) going from a to k − a on the segment J , k − K . General (and basi ) results on the enumeration of walks on a digraphprovide [36, Ch. 4℄: C k = t W k = t (cid:0) (1 − tA k ) − (cid:1) a,k − a = t N k D k , (2)ULMINATING PATHS 7 Figure 4. When a = 5 and b = 3 , there is no ulminating walk of height k , for k ∈ J , K \ { , , } . For k = 5 , , , there is exa tly one ulminating walk.where A k = ( A i,j ) ≤ i,j ≤ k − is the adja en y matrix of our segment graph: A i,j = (cid:26) if j = i + a or j = i − b, otherwise, (3) D k is the determinant of (1 − tA k ) and N k /D k is the entry ( a, k − a ) of (1 − tA k ) − .We note from Proposition 3.1 that, in the (1 , - ase, both N k and D k are espe ially simple.Indeed, N k = t k − , while D k = F k − satis(cid:28)es a linear re urren e relation (with onstant oe(cid:30)- ients) of order 2. We will prove that, for all a and b , both sequen es N k and D k satisfy su h are urren e relation (of a larger order in general). The monomial form of N k will hold as soon as a = 1 .The se ond expression of C k given in Proposition 3.1 appears as a rational fun tion of theroots of the polynomial u − t (1 + u ) . Even though both series U and U are algebrai (andirrational), the fa t that C k is symmetri in U and U explains why C k itself is rational. Ingeneral, we will write C k as a symmetri rational fun tion of the a + b roots of the polynomial u b − t (1 + u a + b ) , denoted U , . . . , U a + b .The third expression of C k follows from the fa t that U U = 1 . In general, t = U b / (1 + U a + b ) for U = U i , so that it will always be possible to write C k as a rational fun tion of U . However,this expression will not be always as simple as above. The equivalen e of the three expressionsof Proposition 3.1 follows easily from the fa t that F k = 1 − U k +2 (1 − U )(1 + U ) k . This an be proved by solving the re urren e relation satis(cid:28)ed by the F k 's (cid:22) or an be he kedby indu tion on k .Let us now state our generalisation of Proposition 3.1 to ( a, b ) - ulminating walks. Our (cid:28)rstexpression of C k , namely the rational form (2), involves the evaluation of two determinantsof size (approximately) k . Our se ond expression of C k will be a (cid:28)xed rational fun tion of U , . . . , U a + b , U k , . . . , U ka + b , symmetri in the U i , whi h involves two determinants of onstantsize a + b . The existen e of su h smaller determinantal forms for walks on(cid:28)ned in a striphas already been re ognized in [3, Ch. 1℄. More re ently, the ase of ex ursions on(cid:28)ned in astrip has been simpli(cid:28)ed and worked out in greater detail [10℄. As in [10℄, our results will beexpressed in terms of the S hur fun tions s λ , whi h form one of the most important bases ofsymmetri fun tions in n variables x , . . . , x n : for any integer partition λ with at most n parts, λ = ( λ , . . . , λ n ) with λ ≥ λ ≥ · · · ≥ λ n ≥ , s λ ( X ) = a δ + λ a δ , (4)with X = ( x , . . . , x n ) , δ = ( n − , n − , . . . , , and a µ = det (cid:0) x µ j i (cid:1) ≤ i,j ≤ n . We refer to [37,Ch. 7℄ for generalities on symmetri fun tions. MIREILLE BOUSQUET-MÉLOU AND YANN PONTYProposition 3.3. Let k > a . With the above notation, the length generating fun tion of ( a, b ) - ulminating paths of height k admits the following expressions: C k ( t ) = t (cid:0) (1 − tA k ) − (cid:1) a,k − a = t N k D k = t s µ ( U ) s λ ( U ) , where A k is given by (3), the ( a + b ) -tuple U = ( U , . . . , U a + b ) is the olle tion of roots ofthe polynomial u b − t (1 + u a + b ) , and the partitions λ and µ are given by λ = ( k − a and µ = (( k − a − , a − .The determinant D k of (1 − tA k ) and the relevant ofa tor N k are respe tively given by D k = ( − ( a − k − t k − s λ ( U ) and N k = ( − ( a − k − t k − s µ ( U ) . (5)Both sequen es N k and D k satisfy a linear re urren e relation with oe(cid:30) ients in Q [ t ] , respe -tively of order (cid:0) a + ba (cid:1) and (cid:0) a + ba − (cid:1) . These orders are optimal.Note that the expression of C k in terms of S hur fun tions still holds for k = a . Examples willbe given below. For the moment, let us underline that the ase a = 1 of this proposition takesa remarkably simple form, whi h will be given a ombinatorial explanation in Se tion 3.2.3.Corollary 3.4. When a = 1 , the generating fun tion of ulminating walks of height k ≥ reads C k ( t ) = t k D k = th k − ( U ) , where h i is the omplete homogeneous symmetri fun tion of degree i , D k = 1 for ≤ k ≤ b + 1 and D k = D k − − t b +1 D k − b − for k > b + 1 .Examples. Let us illustrate Proposition 3.3 by writing down expli itly the expression of C k fora few values of a and b . We use the determinantal form (4) of S hur fun tions.Case a = b = 1 . Here U and U are the two roots of the polynomial u − t (1 + u ) . The partition µ is empty, so that s µ = 1 , while λ = ( k − . This gives C k = t (cid:12)(cid:12)(cid:12)(cid:12) U U (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) U k U k (cid:12)(cid:12)(cid:12)(cid:12) = t U − U U k − U k , as in Proposition 3.1. The re urren e relations satis(cid:28)ed by the polynomials N k and D k analways be worked out from their expressions (5), as will be explained in Se tion 3.2.2. In the ase a = b = 1 , one (cid:28)nds C k = t N k /D k with N k = t k − and D k = D k − − t D k − , with initial onditions D = D = 1 .Case a = 1 , b = 2 . Here U , U , U are the three roots of the polynomial u − t (1 + u ) . Again, µ is empty and λ = ( k − (this holds as soon as a = 1 ). One obtains C k = t (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) U U U U U U (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) U k +11 U U k +12 U U k +13 U (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) . The rational expression of C k reads C k = t N k /D k with N k = t k − and D k = D k − − t D k − , with initial onditions D = D = D = 1 . Note that this expression allows us to ompute in afew se onds the number c n of ulminating walks for n up to .ULMINATING PATHS 9Case a = 2 , b = 1 . Here U , U , U are the three roots of the polynomial u − t (1 + u ) . One has µ = ( k − , and λ = ( k − , whi h gives: C k = t (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) U k +11 U U k +12 U U k +13 U (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) U k +11 U k U k +12 U k U k +13 U k (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) = t (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ¯ U k +11 ¯ U k − U k +12 ¯ U k − U k +13 ¯ U k − (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ¯ U k +11 ¯ U U k +12 ¯ U U k +13 ¯ U (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) , where ¯ U i := 1 /U i . Note that the series ¯ U i are the roots of the polynomial u − t (1 + u ) , whi ho urs in the (symmetri ) ase a = 1 , b = 2 . It is a tually lear from (2) that the denominator D k is un hanged when ex hanging a and b .The rational expression of C k reads C k = t N k /D k with N k = tN k − + t N k − and D k = D k − − t D k − , with initial onditions N = 0 , N = 1 /t, N = t and D = D = D = 1 .3.2. Proofs3.2.1. Proof of Property 3.2. Let us say that a path is positive if every step ends at a positivelevel. For instan e, ulminating walks are positive. For n ≥ there exists a unique positive walkof length n and height at most a + b , denoted w n . Indeed, given h ∈ J , a + b K , exa tly one ofthe values h + a, h − b lies in the interval J , a + b K . For the same reason, w i is a pre(cid:28)x of w j for i ≤ j . Let k ≤ a + b , and assume that there exist two distin t ulminating walks of height k .These walks must be w i and w j , for some i and j , with, say, i < j . But then w i is a pre(cid:28)x of w j , and ends at height k , whi h prevents w j from being ulminating.3.2.2. Proof of Proposition 3.3. The expression of C k in terms of the adja en y matrix A k has been justi(cid:28)ed in Se tion 3.1. Let us now derive the S hur fun tion expression of thisseries. We will give a tually two proofs of this expression: the (cid:28)rst one is based on the kernelmethod [8, 4, 3℄, and the se ond one on the Ja obi-Trudi identity. The (cid:28)rst proof is ompletelyelementary. The se ond one allows us to relate the polynomials N k and D k to the S hur fun tions s λ and s µ . This derivation is very lose to what was done in [10℄ for ex ursions on(cid:28)ned in astrip. Some of the results of [10℄ will a tually be used to shorten some arguments.First proof via the kernel method. Consider a ulminating walk of height k > a . Su h awalk has length at least 2. Delete its (cid:28)rst and last steps: this gives a walk starting from level a , ending at level k − a , and on(cid:28)ned between levels and k − . Shifting this walk one stepdown, we obtain a non-negative walk starting from level a − and ending at level k − − a , ofheight at most k − . Let G ( t, u ) ≡ G ( u ) denote the generating fun tion of non-negative walksstarting from a − , of height at most k − . In this series, the variable t keeps tra k of the lengthwhile the variable u re ords the (cid:28)nal height. Write G ( u ) = P k − h =0 u h G h , where G h ounts walksending at height h . The above argument implies that the generating fun tion of ulminatingwalks of height k is C k = t G k − a − . (6)We an onstru t the walks ounted by G ( u ) step by step, starting from height a − , and addingat ea h time a step + a (unless the urrent height is k − a − or more) or − b (unless the urrentheight is b − or less). In terms of generating fun tions, this gives: G ( u ) = u a − + t ( u a + u − b ) G ( u ) − tu − b b − X h =0 u h G h − tu a k − X h = k − a − u h G h , (cid:0) u b − t (1 + u a + b ) (cid:1) G ( u ) = u a + b − − t b − X h =0 u h G h − tu a + b k − X h = k − a − u h G h . The kernel of this equation, that is, the polynomial u b − t (1 + u a + b ) , has a + b distin t roots,whi h are Puiseux series in t . We denote them U , . . . , U a + b . Re all that G ( u ) is a polynomial in u (of degree k − ). Repla ing u by ea h of the U i gives a system of a + b linear equations relatingthe unknown series G , . . . , G b − and G k − a − , . . . , G k − . For U = U i , with ≤ i ≤ a + b , b − X h =0 U h G h + U a + b k − X h = k − a − U h G h = U a + b − /t. In matrix form, we have MG = C /t , where M is the square matrix of size a + b given by M = U a + b + k − U a + b + k − · · · U b + k − U b − U b − · · · U a + b + k − · · · · · · ... ... U a + b + k − a + b U a + b + k − a + b · · · U b + k − a + b U b − a + b U b − a + b · · · , (7) G is the olumn ve tor ( G k − , . . . , G k − a − , G b − , . . . , G ) , and C is the olumn ve tor ( U a + b − , . . . , U a + b − a + b ) . In view of the de(cid:28)nition (4) of S hur fun tions, det( M ) = s λ ( U ) , with λ = ( k − a . It has been shown in [10℄ that the generating fun tion of ex ursions (walksstarting and ending at ) on(cid:28)ned in the strip of height k − is ( − a +1 t s ( k − a ( U ) s ( k − a ( U ) , and that, in parti ular, s λ ( U ) = 0 . Hen e M is invertible, and applying Cramer's rule to theabove system gives G k − a − = 1 t s µ ( U ) s λ ( U ) , with λ and µ de(cid:28)ned as in the statement of the proposition. Combining this with (6) gives thedesired S hur fun tion form of C k .A se ond proof via symmetri fun tions. Let us now give an alternative proof of the S hurfun tion expression of C k . It will be based on the dual Ja obi-Trudi identity, whi h expressesS hur fun tions as a determinant in the elementary symmetri fun tions e i [37, Cor. 7.16.2℄: forany partition ν , s ν = det (cid:16) e ν ′ j + i − j (cid:17) ≤ i,j ≤ ν , (8)where ν ′ is the onjugate partition of ν .Let us onsider the identity (2), with D k = det(1 − tA k ) . It turns out that this determinantis of the form (8). Indeed, let us de(cid:28)ne V i = − U i , for ≤ i ≤ a + b . Then the only elementarysymmetri fun tions of the V i that do not vanish are e ( V ) = 1 , e a ( V ) = − /t and e a + b ( V ) = 1 (with V = ( V , . . . , V a + b ) ). Let us apply (8) to ν = λ = ( k − a , with variables V , . . . , V a + b .Then ν ′ = a k − and one obtains s λ ( V ) = ( − t ) − ( k − D k = ( − a ( k − s λ ( U ) , sin e s λ is homogeneous of degree a ( k − . This gives the S hur fun tion expression of D k .Now, by the general inversion formula for matri es, N k = ( − k det((1 − tA k ) k − a,a ) , where (1 − tA k ) k − a,a is obtained by deleting row k − a and olumn a from (1 − tA k ) . Let us apply (8)to ν = µ = (( k − a − , a − . Then ν ′ = a a − ( a − k − a . The matrix (cid:16) e ν ′ j + i − j (cid:17) has size k − ,ULMINATING PATHS 11and its last olumn ontains only one non-zero entry (equal to e ( V ) = 1 ), in row k − a . Afterdeleting this row and the last olumn, one obtains: s µ ( V ) = ( − a − ( − t ) − ( k − det((1 − tA k ) k − a,a ) = ( − a − t − ( k − N k = ( − k ( a − s µ ( U ) , as s µ is homogeneous of degree k ( a − . This gives the desired expression of N k .Linear re ursions. Finally, let us prove that the sequen es of polynomials N k and D k satisfya linear re urren e relation with oe(cid:30) ients in Q [ t ] , the ring of polynomials in t . Equivalently,we prove that ea h of the generating fun tions N ( z, t ) := X k ≥ a N k z k and D ( z, t ) := X k ≥ a D k z k is a tually a rational fun tion in z and t . The existen e of a linear re ursion then easily followsby the general theory of rational series [36, Ch. 4℄.Given the expression (5) of N k , what we have to do is to evaluate N ′ ( z ; u , . . . , u a + b ) := X k ≥ a s ( k − a − ,a − z k where the symmetri fun tions involve the a + b indeterminates u , . . . , u n , with n = a + b .We use the de(cid:28)nition (4) of S hur fun tions to write s ( k − a − ,a − as a ratio of determinants ofsize n . The determinant o urring at the denominator is the Vandermonde V n in the u i 's, andis independent of k . The determinant at the numerator is obtained from (7) by repla ing the olumn ontaining U b + k − i by a olumn of U a + b − i (and then ea h U i by the indeterminate u i ).We expand it as a sum over permutations of length n , and obtain: N ′ ( z ; u ) = 1 V n X k ≥ a z k X σ ∈ S n ε ( σ ) σ (cid:0) u n + k − · · · u b + ka − u a + b − a u b − a +1 · · · u n − u n (cid:1) = 1 V n X σ ∈ S n ε ( σ ) σ u n + a − · · · u a + ba − u a + b − a u b − a +1 · · · u n − u n − zu · · · u a − ! , where σ a ts on fun tions of u , . . . , u n by permuting the variables: σF ( u , . . . , u n ) = F ( u σ (1) , . . . , u σ ( n ) ) . Equivalently, N ′ ( z ; u ) = P ( z ; u ) Q ( z ; u ) where Q ( z ; u ) = X I ⊂ J n K , | I | = a − − z Y i ∈ I u i ! and P ( z ; u ) is another polynomial in z and the u i , symmetri in the u i 's. This symmetry propertyshows that repla ing u i by U i transforms N ′ ( z ; u ) into a rational series in z and t . The linkbetween N k and s ( k − a − ,a − then gives N ( z, t ) = ( − a − P (( − a − tz ; U ) t Q (( − a − tz ; U ) , another rational fun tion of z and t . A similar argument, given expli itly in [10℄, yields D ( z, t ) = ( − a − ˜ P (( − a − tz ; U ) t ˜ Q (( − a − tz ; U ) , for two polynomials ˜ P and ˜ Q in z and u , . . . , u n . More pre isely, ˜ Q ( z ; u ) = X I ⊂ J n K , | I | = a − z Y i ∈ I u i ! . ˜ Q and Q , this establishes the existen e of re urren e relations oforder (cid:0) a + ba − (cid:1) for N k , and (cid:0) a + ba (cid:1) for D k . If there were re ursions of a smaller order, the polynomials Q ( z ; U ) or ˜ Q ( z ; U ) would fa tor. It has been shown in [10, Se tion 6℄ that ˜ Q ( z ; U ) is irredu ible,and the same argument implies that Q ( z ; U ) is irredu ible as well.3.2.3. Two proofs of Corollary 3.4. Let us spe ialize Proposition 3.3 to the ase a = 1 . Weobserve that µ is the empty partition, so that s µ = 1 , while λ = ( k − , so that s λ = h k − . Theexpressions (5) of N k and D k in terms of S hur fun tions give N k = t k − and D k = t k − h k − ( U ) .Observe that e ( U ) = 1 /t and e b +1 ( U ) = ( − b +1 . The lassi al relation between elementaryand omplete symmetri fun tions [37, Eq. (7.13)℄ gives, for k ≥ , h k ( U ) = 1 t h k − ( U ) − h k − b − ( U ) , with initial onditions h = 1 and h i = 0 for i < . This gives the desired re ursion for D k .Let us now justify ombinatorially the simpli ity of N k and D k . Re all that, for k ≥ , onehas C k = t W k , where W k ounts walks (with steps +1, − b ) going from 1 to k − on the segmentgraph J , k − K . The adja en y matrix of this graph is A k . The ombinatorial des ription1 of theinverse of the matrix (1 − tA k ) tells us that D k ounts non-interse ting olle tions of elementary y les on the segment J , k − K , while N k ounts on(cid:28)gurations formed of a self-avoiding path w going from 1 to k − together with a non-interse ting olle tion of elementary y les that donot meet w . In the polynomials N k and D k , ea h y le of length ℓ is given a weight ( − t ℓ ) whilethe path w is simply weighted t ℓ if it has length ℓ . This gives dire tly N k = t k − , as the onlypossible path w is formed of k − up steps, and leaves no pla e to o-existing y les. Now theonly elementary y les are formed of b up steps and one down step − b . The re ursion satis(cid:28)edby D k is then obtained by dis ussing whether the point k − is ontained in one su h y le.Note that this proof an be rephrased in terms of heaps of y les using Viennot's orrespon-den e between walks on a graph and ertain heaps [38℄. The expression N k /D k then appears asa spe ialisation of the inversion lemma (also found in [38℄). In parti ular, D k is the (alternating)generating fun tion of trivial heaps of y les.Remark. For general values of a and b , the des ription of D k and N k in terms of y les andpaths on the graph J , k − K remains perfe tly valid. But the stru ture of elementary y les andself-avoiding paths be omes more ompli ated. See an example in Figure 5.Figure 5. Two non-interse ting elementary y les (for a = 4 and b = 3 ).3.2.4. Proof of Proposition 3.1. The expression of C k is just a spe ialisation of Corollary 3.4to the ase b = 1 . It remains to prove that the series C ( t ) is not D-(cid:28)nite.Let us (cid:28)rst observe that C ( t ) is D-(cid:28)nite if and only if the power series (in u ) B ( u ) := P k u k / (1 − u k ) is D-(cid:28)nite. Indeed, one goes from C ( t ) to B ( u ) , and vi e-versa, by an algebrai substitution of the variable, as U is an algebrai fun tion of t and t = U/ (1 + U ) . It is knownthat D-(cid:28)nite series are preserved by algebrai substitutions [37, Thm. 6.4.10℄, so that we annow fo us on the series B ( u ) .This series has integer oe(cid:30) ients, and radius of onvergen e 1. Hen e it is either rational,or admits the unit ir le as a natural boundary [12℄. As will be re alled later (10), the singularbehaviour of B ( u ) as u approa hes 1 involves a logarithm, whi h rules out the possibility of1This des ription seems to have been around sin e, at least, the 80's [25, 38℄. See [9, Thm. 2.1℄ for a modernformulation.ULMINATING PATHS 13 B ( u ) being rational. Thus B ( u ) has a natural boundary, and, in parti ular, in(cid:28)nitely manysingularities. But D-(cid:28)nite series have only (cid:28)nitely many singularities, so that B ( u ) is not D-(cid:28)nite. 4. Asymptoti enumerative resultsIn this se tion we present some results on the asymptoti enumeration of ulminating walks.Intuitively, three ases arise, depending on the drift of the walks, de(cid:28)ned as the di(cid:27)eren e a − b .Indeed, an n -step random walk of positive drift is known to end at level O ( n ) and is, intuitively,quite likely to be ulminating. On the ontrary, walks with a negative drift have a very smallprobability of staying positive. We (cid:28)rst work out the intermediate ase of a zero drift.4.1. Walks with a null drift ( a = b = 1 )When the drift is zero, the number of positive walks (walks in whi h every step ends at apositive level) of length n is known to be asymptoti ally equivalent to n / √ πn . The averageheight, and the average (cid:28)nal level of these walks both s ale like √ n . Hen e we an expe t thenumber of ulminating walks to be of the order of n /n . This is on(cid:28)rmed by the followingresult.Proposition 4.1. As n → ∞ , the number of (1 , - ulminating paths of length n is asymptoti- ally equivalent to n / (4 n ) .Proof. We start from the expression (1) of C ( t ) , with U = U = O ( t ) , and apply the singularityanalysis of [23℄. Note that U ( t ) is an odd fun tion of t . Let us (cid:28)rst study the even part of C ( t ) ,whi h ounts ulminating paths of even length: C e ( t ) = 1 − U U X k ≥ U k − U k . Let Z ≡ Z ( x ) be su h that U ( t ) = Z ( t ) . That is, Z ≡ Z ( x ) = 1 − x − √ − x x . The equation U = t (1 + U ) gives Z = x (1 + Z ) . Moreover, we have C e ( t ) = D ( t ) where D ( x ) = 1 − Z Z X k ≥ Z k − Z k . We thus need to study the asymptoti behaviour of the oe(cid:30) ients of D ( x ) . We write D ( x ) = S ( Z ( x )) , with S ( z ) = 1 − z z X k ≥ z k − z k . The series Z ( x ) has radius of onvergen e / . It is analyti in the domain D = C \ [1 / , + ∞ ) ,with exa tly one singularity, at x = 1 / . One has Z (0) = 0 , and | Z ( x ) | < for all x in D . Indeed,assume | Z ( x ) | ≥ for some x in D . By ontinuity, Z ( x ) = e iθ for some x in D . From the equation x (1 + Z ) = Z , we on lude that θ ∈ ( − π, π ) (for θ = ± π , we would have Z = − ), andthat x = 1 / (4 cos ( θ/ . But this ontradi ts the fa t that x ∈ D .The series S ( z ) has radius of onvergen e . Given that | Z ( x ) | < in D , this implies that D ( x ) = S ( Z ( x ))) is analyti in the domain D . It remains to understand how D ( x ) behaves as x approa hes / in D .Take x = (1 − re iθ ) / , with < r < and | θ | < π . Then Z ( x ) = 1 − √ − x + O (1 − x ) = 1 − √ re iθ/ + O ( r ) . In parti ular, arg(1 − Z ( x )) = θ/ O ( √ r ) . α ∈ ( π/ , π/ . The above identity shows that there exists η > and π/ < φ < π su hthat, in the indented disk I = { x : | − x | < η and | arg(1 − x ) | < φ } , one has | arg(1 − Z ( x )) | < α. (9)Now when z → in su h a way that | arg(1 − z ) | < α , X k ≥ z k − z k ∼ − z ) log 11 − z , so that S ( z ) ∼
14 log 11 − z . (10)This an be obtained using a Mellin transform or some already known results on the generatingfun tion of divisor sums [22℄.Combining (9) and (10) shows that, as x tends to / in the indented disk I , D ( x ) = S ( Z ( x )) ∼
18 log 11 − x . (11)This allows us to apply the transfer theorems of [23℄. Indeed, the series D ( x ) is analyti
in thefollowing domain: ∆ = { x = 1 / | x | < η and | arg(1 − x ) | < φ } , with singular behaviour near x = 1 / given by (11). From this we
on
lude that the
oe(cid:30)
ientof x n in D ( x ) is asymptoti
ally equivalent to n / (8 n ) . Going ba
k to the series C e ( t ) , this meansthat the number of
ulminating paths of (even) length N = 2 n is asymptoti
ally equivalent to N / (4 N ) .The study of the odd part of C ( t ) is similar.4.2. Walks with positive drift ( a > b )When the drift is positive, it is known that, asymptoti
ally, a positive fra
tion of walks withsteps + a , − b is a
tually positive (every step ends at a positive level). More pre
isely, as n → ∞ ,the number p a,bn of positive walks of length n satis(cid:28)es p a,bn ∼ κ a,b . n (12)for some positive
onstant κ a,b . We will show that the
ulmination and (cid:28)nal re
ord
onditionsplay similar (cid:28)ltering roles in the paths of { m, m } ∗ , and prove the following result.Proposition 4.2. For a > b , the number c a,bn of
ulminating walks of length n satis(cid:28)es c a,bn = κ a,b . n + O ( ρ n ) , where ρ < and κ a,b is the
onstant involved in the asymptoti
s of positive walks.Proof. In what follows, we
onsider two families of paths that are
lose to the meanders andex
ursions de(cid:28)ned in the introdu
tion: the (already de(cid:28)ned) positive walks, and
ertain quasi-ex
ursions. The exa
t and asymptoti
enumeration of meanders and ex
ursions has been
om-pletely worked out in [5℄, and we will rely heavily on this paper. For instan
e, the estimate (12)follows from the results of [5℄ by noti
ing that a meander fa
tors into an ex
ursion followed by apositive walk. Let us
all quasi-ex
ursion a walk in whi
h every step, ex
ept the (cid:28)nal one, endsat a positive level. For instan
e, if a = 3 and b = 2 , the word mmm is a quasi-ex
ursion. Byremoving the last step of su
h a walk, we see that quasi-ex
ursions are in bije
tion with positivewalks of (cid:28)nal height 1, 2, . . . , or b . We denote the number of quasi-ex
ursions of length n by e a,bn . Using the results of [5℄, it is easy to see that, when the drift is positive, quasi-ex
ursionsare exponentially rare among general walks. That is, there exists µ < su
h that for n largeenough, e a,bn < µ n . (13)ULMINATING PATHS 15From now on, we drop the supers
ripts a and b , writing for instan
e c n rather than c a,bn . Forany word w = w · · · w k , denote by ← w the mirror image of w , that is, ← w = w k · · · w . Let u be a
ulminating word of length n , and write u = vw , where the word v (resp. w ) has length ⌊ n/ ⌋ (resp. ⌈ n/ ⌉ ). Then both v and ← w are positive walks, and this proves that c n ≤ p ⌊ n/ ⌋ p ⌈ n/ ⌉ . (14)Conversely, let us bound the number of pairs ( v, w ) , where v and w are positive walks of respe
tivelengths ⌊ n/ ⌋ and ⌈ n/ ⌉ , su
h that the word u = v ← w is not
ulminating. This means that • either u fa
tors as v w , where v is a quasi-ex
ursion of length i > ⌊ n/ ⌋ , • or, symmetri
ally, u fa
tors as v ← w where w is a quasi-ex
ursion of length j > ⌈ n/ ⌉ .This implies that p ⌊ n/ ⌋ p ⌈ n/ ⌉ − c n ≤ n X i = ⌊ n/ ⌋ e i n − i . In view of (13), we have, for n large enough: p ⌊ n/ ⌋ p ⌈ n/ ⌉ − c n ≤ n X i = ⌊ n/ ⌋ µ i n − i ≤ − µ/ n ( µ/ ⌊ n/ ⌋ ≤ − µ/ µ ) ⌊ n/ ⌋ . Combining this with (14) and the known asymptoti
s for the numbers p n gives the expe
tedresult.4.3. Walks with negative drift ( a < b ): exponential de
ayWhen the drift is negative, it is known that positive walks are exponentially rare amonggeneral walks. Indeed, there exist
onstants κ a,b > and α a,b ∈ (1 , , su
h that p a,bn ∼ κ a,b α na,b n / . More pre
isely, α a,b = a + b a + b √ a a b b = 1 + q q √ q q ≡ α ( q ) , (15)where q = a/b < . We show below that the
onstant α a,b also governs the number of
ulminatingwalks of size n .Proposition 4.3. For a < b , the number c a,bn of
ulminating walks of length n satis(cid:28)es c a,bn = O (cid:18) α na,b n (cid:19) , (16)where α a,b is given above. Moreover, lim n →∞ (cid:0) c a,bn (cid:1) /n = α a,b . Proof. The inequality (14) still holds, and gives the upper bound (16) on the number of
ulmi-nating paths.Let us now prove that the growth
onstant of
ulminating walks is still α a,b by
onstru
ting alarge
lass of su
h walks. Let E n be the set of ex
ursions of length n (from now on, we drop thesupers
ripts a and b ). Su
h ex
ursions only exist when n is a multiple of a + b , and the number e n of su
h walks then satis(cid:28)es e n ∼ κα na,b n − / for some positive
onstant κ . It is known that random ( a, b ) -ex
ursions of length n onvergein law to the Brownian ex
ursion, after normalising the length by n and the height by κ ′ √ n ,for some
onstant κ ′ depending on a and b [29℄. This implies that the (normalized) height ofa dis
rete ex
ursion
onverges in law to the height of the Brownian ex
ursion (des
ribed by atheta distribution). In parti
ular, the probability p n that an ex
ursion of E n has height larger6 MIREILLE BOUSQUET-MÉLOU AND YANN PONTYthan √ n tends to a limit p < as n goes to in(cid:28)nity. Take an ex
ursion of E k of height less than √ n , with k = ( a + b ) (cid:22) n − − √ na + b (cid:23) and append one up step at its left, and n − k − up steps at its right: this gives a
ulminatingwalk of length n , whi
h proves that c n ≥ e k (1 − p k ) . Taking n th roots gives the required lower bound on the growth of c n .Hen
e there are exponentially few walks of size n with steps + a, − b that are
ulminating. Itis likely that c n behaves like α na,b n − − γ , for some γ ≥ that remains to be determined. Notethat the (cid:28)nal height of an n -step meander is known to have a dis
rete limit law as n → ∞ [5℄.5. Random generation of positive walksThe random generation of positive walks will be a preliminary step in some of the algorithmswe present in the next se
tion for the generation of
ulminating walks. The main ideas underlyingthe generation are the same for both
lasses of walks, but the
lass of positive walks is simpler. Weapply three di(cid:27)erent approa
hes to their random generation: re
ursive methods (two versions),anti
ipated reje
tion, and Boltzmann sampling. The
hoi
e of the best algorithm depends on thedrift, as summarized in the top part of Table 2. We denote by P a,b the language of positivewalks, but the supers
ript a, b will often be dropped.5.1. Re
ursive step-by-step approa
hThe (cid:28)rst approa
h we present is elementary: we
onstru
t positive walks step-by-step,
hoos-ing at ea
h time an up or down step with the right probability. This is the basis of the re
ursiveapproa
h introdu
ed in [39℄. Here are the three ideas underlying the algorithm: • Let W be a language, and let W p denote the language of the pre(cid:28)xes of words of W .Assume that for all w ∈ W p su
h that | w | ≤ n , we know the number N w ( n ) of words of W of length n beginning with w (we
all these word extensions of w ). Then it is possibleto draw uniformly words of length n in W as follows. One starts from the empty word,and adds steps in
rementally. If at some point the pre(cid:28)x that is built is w , one adds theletter x to w with probability N wx ( n ) /N w ( n ) . • When W = P a,b , the number of extensions of length n of a pre(cid:28)x w ∈ W p depends onlyon two parameters:(cid:21) the length di(cid:27)eren
e i = n − | w | ,(cid:21) the (cid:28)nal height of w , j = φ a,b ( w ) , • Let p i,j be the number of extensions of length n of su
h a pre(cid:28)x w . The numbers p i,j obey the following re
urren
e: p i,j = p i − ,j + a + j>b p i − ,j − b for i ≥ ,p ,j = 1 . As the two parameters i and j are bounded by n and an respe
tively, the pre
omputation of thenumbers p i,j takes O ( n ) arithmeti
operations and requires to store O ( n ) numbers. Then, thegeneration of a random word of length n an be performed in linear time. However, one shouldtake into a
ount the
ost due to the size of the numbers in the pre
omputation stage. Indeed,the numbers p i,j are exponential in n , so that the a
tual time-spa
e
omplexity for this stagemay grow to O ( n ) . However, using a (cid:29)oating-point te
hnique adapted from [16℄, it should bepossible to take advantage of the numeri
al stability of the algorithm to redu
e the spa
e neededto O ( n ε ) .This naive re
ursive approa
h is less e(cid:30)
ient than the one presented below, whi
h is basedon
ontext-free grammars. But it will be easily adapted to the generation of
ulminating walks,whi
h
annot be generated via a grammar, as was proved in Se
tion 2.ULMINATING PATHS 175.2. Re
ursive approa
h via
ontext-free grammarsIt is easy to see that the language P a,b ≡ P is re
ognized by a non-deterministi
push-downautomaton. This implies that P is
ontext-free. The same holds for the language D a,b ≡ D of ex
ursions. A non-ambiguous
ontext-free grammar generating ex
ursions is given expli
itlyin [19℄. It su(cid:30)
es to add one equation to obtain a non-ambiguous grammar generating positivewalks: D = ε + P ak =1 L k R k , L i = i = a m D + P ak = i +1 L k R k − i , P = ε + P ai =1 L i P , R j = j = b m D + P bk = j +1 L k − j R k . (17)In this system, ε is the empty word, D (resp. P ) is the language of ex
ursions (resp. positivewalks) while L i , ≤ i ≤ a and R j , ≤ j ≤ b , are a + b auxiliary languages de(cid:28)ned in [19℄. Asabove, m and m are the up and down letters in our alphabet.From this grammar, we
an apply the re
ursive approa
h of [24℄ for the uniform generation ofde
omposable obje
ts, implemented in the
ombstru
t pa
kage of Maple or in the stand-alonesoftware GenRGenS [35℄. The generation of positive walks of size n begins with the pre
ompu-tation of O ( n ) large numbers. These numbers
ount words of length r , for all r ≤ n , in ea
h ofthe languages involved in the grammar. The fastest way to get them is to
onvert the algebrai
system (17) into a system of linear di(cid:27)erential equations, whi
h, in turn, yields a system oflinear re
urren
e relations (with polynomial
oe(cid:30)
ients) de(cid:28)ning the requested numbers. Thisstep requires a linear number of arithmeti
operations. But one has to multiply numbers whosesize (number of digits) is O ( n ) , whi
h may result, in pra
ti
e, in a quadrati
time-
omplexity forthe pre
omputation stage. Then, the generation of a random positive walk
an be performed intime O ( n log n ) .Note that a
areful implementation [15℄ of the (cid:29)oating point approa
h of [16℄ using anarbitrary-pre
ision (cid:29)oating-point
omputation library yields a O ( n ε ) omplexity after a O ( n ε ) pre
omputation.5.3. Anti
ipated reje
tionThe prin
iple of this approa
h is to start with an empty walk, and then add su
essive upand down steps by (cid:29)ipping an unbiased
oin until the walk rea
hes the desired length n , ora non-positive ordinate. In this
ase, the walk is reje
ted and the pro
edure starts from thebeginning. Of
ourse, no pre
omputation nor non-linear storage is required. This prin
iple wasapplied to meanders, in the
ase a = b = 1 , in [6℄, as a (cid:28)rst step towards the uniform randomgeneration of dire
ted animals. The analysis of this algorithm yielded a linear time-
omplexity,later generalized in [7℄ to the
ase of
oloured walks, in whi
h up, down, and level steps
omerespe
tively in p , q and r di(cid:27)erent
olours. There, it was shown that the time-
omplexity islinear when p ≥ q , but exponential when p < q .Unsurprisingly, we obtain similar results for the general ( a, b ) -
ase.Proposition 5.1. The anti
ipated reje
tion s
heme applied to the uniform random generationof ( a, b ) -positive walks has a linear time-
omplexity when a ≥ b and an exponential
omplexityin Θ((2 /α a,b ) n n √ n ) when a < b , with α a,b = a + b a + b √ a a b b < .Proof. We (cid:28)rst note that the language P of positive walks is a left-fa
tor language. That is, itis stable by taking pre(cid:28)xes, and every word of P is the proper pre(cid:28)x of another word of P . Ithas been proved in [14℄ that the average
omplexity f L ( n ) of the anti
ipated reje
tion s
hemefor a left-fa
tor language L on a k -letter alphabet is f L ( n ) = [ z n ] z − z L ( z/k )[ z n ] L ( z/k ) where L ( z ) is the length generating fun
tion of the words of L .We now exploit the results of [5℄, giving the singular behaviour of the series M ( z ) and E ( z ) that
ount respe
tively meanders and ex
ursions. As a meander fa
tors uniquely as an ex
ursion8 MIREILLE BOUSQUET-MÉLOU AND YANN PONTYfollowed by a positive walk, we
an derive from [5℄ the singular behaviour of the series P ( z ) = P p n z n that
ounts positive walks. This series is always algebrai
, so that singularity analysisapplies.(cid:21) For a ≥ b , the series P ( z/ has an algebrai
singularity at z = 1 in (1 − z ) − ν (with ν = 1 if a > b , and ν = 1 / if a = b ). Thus P ( z/ / (1 − z ) has a singular behaviour in (1 − z ) − ν − . A singularity analysis gives f P ( n ) ∼ n/ν .(cid:21) For a < b , the series P ( z/ has a square-root singularity at /α a,b > , but P ( z/ / (1 − z ) has a smaller radius of
onvergen
e z c = 1 , with a simple pole at this point. Thisgives f P ( n ) ∼ n P (1 / p n ∼ κ (cid:18) α a,b (cid:19) n n √ n for some
onstant κ .5.4. Boltzmann samplingA Boltzmann generator [20℄ generates every obje
t in the
lass C with a probability propor-tional to x n , where n is the size of the obje
t. More pre
isely, for every obje
t w (a walk, in our
ontext): P ( w ) = x | w | C ( x ) where C ( x ) is the generating fun
tion of the obje
ts of C . Of
ourse, this results in a relaxationof the size
onstraint, sin
e obje
ts of all sizes
an be generated. But, by tuning
arefully theparameter x (whi
h has to be smaller than or equal to the radius of
onvergen
e of C ( x ) ), andreje
ting the too large and too small obje
ts, one
an often a
hieve an approximate-size randomsampling, with a toleran
e ε , in linear time. This means that after a linear number of real-arithmeti
operations, and a number of attempts that is
onstant on average, the algorithm willprodu
e an obje
t of size | w | ∈ [(1 − ε ) n, (1 + ε ) n ] , whi
h is uniform among the obje
ts of thesame size.In parti
ular, the grammar (17) shows that the
lass of positive walks is spe
i(cid:28)able in thesense of [20℄. The analysis of the generating fun
tions of meanders and ex
ursions performedin [5℄ shows that the series P ( z ) ounting positive walks is always analyti
in a ∆ -domain, witha dominant singularity in (1 − µt ) − ν , where ν = 1 if a > b , ν = 1 / if a = b and ν = − / if a < b . In the (cid:28)rst two
ases, Theorem 6.3 of [20℄ gives an approximate sampling in lineartime (and an exa
t sampling in quadrati
time). In the third
ase, the standard deviation ofthe obje
ts produ
ed by a standard Boltzmann sampler is mu
h larger than their mean, whi
hmakes reje
tion
ostly. However, we
an generate instead pointed positive walks, that is, positivewalks with a distinguished step, and forget the pointing: as guaranteed by Theorem 6.5 of [20℄,this gives again an approximate sampling in linear time.To
on
lude, the uniform random generation of ( a, b ) -positive walks of size n an be performedin linear time when a ≥ b by an anti
ipated reje
tion, and this strategy does not require anypre
omputations nor storage. When a < b , our best algorithm for exa
t sampling remains there
ursive approa
h based on the grammar (17). It runs in O ( n ε ) after a O ( n ε ) pre
ompu-tation. However, one
an a
hieve, in linear time and spa
e, an approximate-size sampling usinga Boltzmann generator.6. Random generation of
ulminating walks6.1. Re
ursive step-by-step approa
hThis elementary pro
edure, introdu
ed in [30℄, generates
ulminating walks step by step,
hoosing every new step with the right probability. This is again an instan
e of Wilf's re
ursiveULMINATING PATHS 19method. The arguments given in Se
tion 5.1 for positive walks should now be repla
ed by thefollowing ones: • For W = C a,b , the number of extensions of length n of a pre(cid:28)x w ∈ W p depends only onthree parameters:(cid:21) the length di(cid:27)eren
e i = n − | w | ,(cid:21) the (cid:28)nal height j = φ a,b ( w ) ,(cid:21) the maximal height h rea
hed by w . • Let c i,j,h be the number of extensions of length n of su
h a pre(cid:28)x w . The numbers c i,j,h obey the following re
urren
e: c i,j,h = c i − ,j + a, max( h,j + a ) + j>b c i − ,j − b,h for i > ,c ,j,h = j + a>h . As the parameters i , j and h are bounded by n , an and an respe
tively, the pre
omputation ofthe numbers c ( i, j, h ) takes O ( n ) arithmeti
operations and requires to store O ( n ) numbers.Then, the generation of a random word of length n an be performed in linear time. Butagain, the numbers c i,j,h are exponential in n , so that the a
tual time-spa
e
omplexity of thepre
omputation stage may grow to O ( n ) .The above pro
edure is easily adapted to generate
ulminating walks ending at a pres
ribedheight k . The number c ( k ) i,j of i -step extensions of a pre(cid:28)x ending at height j is given by c ( k ) i,j = j + a