# 1 p 1 z p 1 p 1 z 2 4 lp 2 z 2 p 2 z reducing we have

• No School
• AA 1
• 24

This preview shows page 19 - 22 out of 24 pages.

= 1 - p 1 z - p (1 - p 1 z ) 2 - 4 Lp 2 z 2 p 2 z Reducing, we have E ( z ) = 1 - p 1 z - p 1 - 2( p 1 + 2 Lp 2 k ) z + p 1 z 2 2 p 2 z Calculation As before, there is no closed simple formula for E n , but we can derive a recurrence formula by differentiating the generating function, rewritten as 2 p 2 zE ( z ) + p 1 z - 1 = - p 1 - 2( p 1 + 2 p 2 L ) z + p 1 z 2 2 p 2 zE 0 ( z ) + 2 p 2 E ( z ) + p 1 = p 1 + 2 p 2 L - p 1 z p 1 - 2( p 1 + 2 p 2 L ) z + p 1 z 2 2 p 2 zE 0 ( z ) + 2 p 2 E ( z ) + p 1 = ( p 1 + 2 p 2 L - p 1 z )(1 - p 1 z - 2 p 2 zE ( z )) 1 - 2( p 1 + 2 p 2 L ) z + p 1 z 2 2 p 2 zE 0 ( z ) + 2 p 2 E ( z ) 1 + z ( p 1 + 2 p 2 L - p 1 z ) 1 - 2( p 1 + 2 p 2 L ) z + p 1 z 2 = ( p 1 + 2 p 2 L - p 1 z )(1 - p 1 z ) 1 - 2( p 1 + 2 p 2 L ) z + p 1 z 2 - p 1 2 p 2 zE 0 ( z ) + 2 p 2 E ( z ) 1 - ( p 1 + 2 p 2 L ) z 1 - 2( p 1 + 2 p 2 L ) z + p 1 z 2 = 2 p 2 L (1 + p 1 z ) + p 1 ( p 1 - 1) z 1 - 2( p 1 + 2 p 2 L ) z + p 1 z 2 2 p 2 zE 0 ( z )(1 - 2( p 1 + 2 p 2 L ) z + p 1 z 2 ) + 2 p 2 E ( z )(1 - ( p 1 + 2 p 2 L ) z ) = (2 p 2 L (1 + p 1 z ) + p 1 ( p 1 - 1) z ) replacing E ( z ) and E 0 ( z ) with their coefficients 2 p 2 ( nE n - 2( p 1 + 2 p 2 L )( n - 1) E n - 1 + p 1 ( n - 2) E ( n - 2)) + 2 p 2 ( E n - ( p 1 + 2 p 2 L ) E n - 1 ) = 0 ( n + 1) E n - ( p 1 + 2 p 2 L )(2 n - 1) E n - 1 + p 1 ( n - 2) E n - 2 = 0 ( n + 1) E n = ( p 1 + 2 p 2 L )(2 n - 1) E n - 1 - p 1 ( n - 2) E n - 2 19
which together with E 0 = L E 1 = ( p 1 + p 2 L ) L provides a formula for calculating E n . Asymptotic estimate As before, approximations of E n for large n can be found by developing E ( z ) in the neighbourhood of the root with the smallest module of 1 - 2( p 1 + 2 p 2 L ) z + p 1 z 2 The roots are r 1 = p 1 p 1 + 2 p 2 L - p p 2 1 + 4 p 2 2 L 2 + 4 p 2 p 1 L - p 1 r 2 = p 1 p 1 + 2 p 2 L + p p 2 1 + 4 p 2 2 L 2 + 4 p 2 p 1 L - p 1 both are positive and the smallest one is r 2 To alleviate notation, let δ = q p 2 1 + 4 p 2 2 L 2 + 4 p 2 p 1 L - p 1 r 2 = p 1 p 1 + 2 p 2 L + δ developing E ( z ) near r 2 , E ( z ) 1 - p 1 r 2 - q 1 - r 2 ( p 1 +2 p 2 L - δ p 1 ) q 1 - z r 2 2 p 2 r 2 + O (1 - z r 2 ) 3 / 2 E ( z ) p 1 + 2 p 2 L + δ - p 2 1 - p 1 + 2 p 2 L + δ 2 δ q 1 - z r 2 2 p 2 p 1 + O (1 - z r 2 ) 3 / 2 and therefore E n δr - n - 1 2 2 2 p 2 p 2 πp 1 n 3 = δ 2 p 2 2 πn 3 ( p 1 + 2 p 2 L + δ ) n + 1 2 p n +1 1 C G ENERATING RANDOM EXPRESSIONS In this section we present algorithms to generate random expressions with n internal nodes. We achieve this by generating random trees, and selecting randomly their nodes and leaves. We begin with the simpler binary case ( p 1 = 0 ). C.1 B INARY TREES To generate a random binary tree with n internal nodes, we use the following one-pass procedure. Starting with an empty root node, we determine at each step the position of the next internal nodes among the empty nodes, and repeat until all internal nodes are allocated. Start with an empty node, set e = 1 ; while n > 0 do Sample a position k from K ( e, n ) ; Sample the k next empty nodes as leaves; Sample an operator, create two empty children; Set e = e - k + 1 and n = n - 1 ; end Algorithm 1: Generate a random binary tree 20
We denote by e the number of empty nodes, by n > 0 the number of operators yet to be generated, and by K ( e, n ) the probability distribution of the position ( 0 -indexed) of the next internal node to allocate.

#### You've reached the end of your free preview.

Want to read all 24 pages?

• Fall '19

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern