{
  "index": "2023-B-3",
  "type": "COMB",
  "tag": [
    "COMB",
    "ANA"
  ],
  "difficulty": "",
  "question": "A sequence $y_1,y_2,\\dots,y_k$ of real numbers is called \\emph{zigzag} if $k=1$, or if $y_2-y_1, y_3-y_2, \\dots, y_k-y_{k-1}$ are nonzero and alternate in sign. Let $X_1,X_2,\\dots,X_n$ be chosen independently from the uniform distribution on $[0,1]$. Let $a(X_1,X_2,\\dots,X_n)$ be the largest value of $k$ for which there exists an increasing sequence of integers $i_1,i_2,\\dots,i_k$ such that $X_{i_1},X_{i_2},\\dots,X_{i_k}$ is zigzag. Find the expected value of $a(X_1,X_2,\\dots,X_n)$ for $n \\geq 2$.",
  "solution": "The expected value is $\\frac{2n+2}{3}$.\n\nDivide the sequence $X_1,\\dots,X_n$ into alternating increasing and decreasing segments, with $N$ segments in all. Note that removing one term cannot increase $N$: if the removed term is interior to some segment then the number remains unchanged, whereas if it separates two segments then one of those decreases in length by 1 (and possibly disappears). From this it follows that $a(X_1,\\dots,X_n) = N+1$: in one direction, the endpoints of the segments form a zigzag of length $N+1$; in the other, for any zigzag $X_{i_1},\\dots, X_{i_m}$, we can view it as a sequence obtained from $X_1,\\dots,X_n$ by removing terms, so its number of segments (which is manifestly $m-1$) cannot exceed $N$.\n\nFor $n \\geq 3$, $a(X_1,\\dots,X_n) - a(X_2,\\dots,X_{n})$\nis 0 if $X_1, X_2, X_3$ form a monotone sequence and 1 otherwise. Since the six possible orderings of $X_1,X_2,X_3$ are equally likely,\n\\[\n\\mathbf{E}(a(X_1,\\dots,X_n) - a(X_1,\\dots,X_{n-1})) = \\frac{2}{3}.\n\\]\nMoreover, we always have $a(X_1, X_2) = 2$ because any sequence of two distinct elements is a zigzag. By linearity of expectation plus induction on $n$, we obtain $\\mathbf{E}(a(X_1,\\dots,X_n)) = \\frac{2n+2}{3}$ as claimed.",
  "vars": [
    "y_1",
    "y_2",
    "y_k",
    "X_1",
    "X_2",
    "X_3",
    "X_n",
    "X_i_1",
    "X_i_2",
    "X_i_k",
    "X_i_m",
    "i_1",
    "i_2",
    "i_k",
    "i_m",
    "k",
    "N",
    "m"
  ],
  "params": [
    "n"
  ],
  "sci_consts": [],
  "variants": {
    "descriptive_long": {
      "map": {
        "y_1": "firstyvar",
        "y_2": "secondyvar",
        "y_k": "kaythvar",
        "X_1": "firstxvar",
        "X_2": "secondxvar",
        "X_3": "thirdxvar",
        "X_n": "nthxvar",
        "X_i_1": "selxone",
        "X_i_2": "selxtwo",
        "X_i_k": "selxkay",
        "X_i_m": "selxemm",
        "i_1": "indexone",
        "i_2": "indextwo",
        "i_k": "indexkay",
        "i_m": "indexemm",
        "k": "lengthk",
        "N": "segmentn",
        "m": "lengthm",
        "n": "totalsize"
      },
      "question": "A sequence $firstyvar, secondyvar,\\dots, kaythvar$ of real numbers is called \\emph{zigzag} if $lengthk=1$, or if $secondyvar-firstyvar, y_3-secondyvar, \\dots, kaythvar - y_{lengthk-1}$ are nonzero and alternate in sign. Let $firstxvar, secondxvar,\\dots, nthxvar$ be chosen independently from the uniform distribution on $[0,1]$. Let $a(firstxvar, secondxvar,\\dots, nthxvar)$ be the largest value of $lengthk$ for which there exists an increasing sequence of integers $indexone, indextwo,\\dots, indexkay$ such that $selxone, selxtwo,\\dots, selxkay$ is zigzag. Find the expected value of $a(firstxvar, secondxvar,\\dots, nthxvar)$ for $totalsize \\geq 2$.",
      "solution": "The expected value is $\\frac{2\\text{totalsize}+2}{3}$.\\n\\nDivide the sequence $firstxvar,\\dots, nthxvar$ into alternating increasing and decreasing segments, with $segmentn$ segments in all. Note that removing one term cannot increase $segmentn$: if the removed term is interior to some segment then the number remains unchanged, whereas if it separates two segments then one of those decreases in length by 1 (and possibly disappears). From this it follows that $a(firstxvar,\\dots, nthxvar) = segmentn+1$: in one direction, the endpoints of the segments form a zigzag of length $segmentn+1$; in the other, for any zigzag $selxone,\\dots, selxemm$, we can view it as a sequence obtained from $firstxvar,\\dots, nthxvar$ by removing terms, so its number of segments (which is manifestly $lengthm-1$) cannot exceed $segmentn$.\\n\\nFor $totalsize \\geq 3$, $a(firstxvar,\\dots, nthxvar) - a(secondxvar,\\dots, nthxvar)$ is $0$ if $firstxvar, secondxvar, thirdxvar$ form a monotone sequence and $1$ otherwise. Since the six possible orderings of $firstxvar, secondxvar, thirdxvar$ are equally likely,\\n\\[\\n\\mathbf{E}(a(firstxvar,\\dots, nthxvar) - a(firstxvar,\\dots, X_{totalsize-1})) = \\frac{2}{3}.\\n\\]\\nMoreover, we always have $a(firstxvar, secondxvar) = 2$ because any sequence of two distinct elements is a zigzag. By linearity of expectation plus induction on $totalsize$, we obtain $\\mathbf{E}(a(firstxvar,\\dots, nthxvar)) = \\frac{2\\text{totalsize}+2}{3}$ as claimed."
    },
    "descriptive_long_confusing": {
      "map": {
        "y_1": "elmforest",
        "y_2": "crimsonoak",
        "y_k": "sunlitpine",
        "X_1": "silverbrook",
        "X_2": "duskylake",
        "X_3": "windyridge",
        "X_n": "mistyvalley",
        "X_i_1": "shadowcreek",
        "X_i_2": "autumncliff",
        "X_i_k": "starlitpath",
        "X_i_m": "hiddenmeadow",
        "i_1": "thunderhill",
        "i_2": "whispergrove",
        "i_k": "silentcanyon",
        "i_m": "rustlingleaf",
        "k": "amberfield",
        "N": "cobaltplain",
        "m": "opalharbor",
        "n": "goldenshore"
      },
      "question": "A sequence $elmforest,crimsonoak,\\dots,sunlitpine$ of real numbers is called \\emph{zigzag} if $amberfield=1$, or if $crimsonoak-elmforest,y_3-crimsonoak,\\dots,y_{amberfield}-y_{amberfield-1}$ are nonzero and alternate in sign. Let $silverbrook,duskylake,\\dots,mistyvalley$ be chosen independently from the uniform distribution on $[0,1]$. Let $a(silverbrook,duskylake,\\dots,mistyvalley)$ be the largest value of $amberfield$ for which there exists an increasing sequence of integers $thunderhill,whispergrove,\\dots,silentcanyon$ such that $shadowcreek,autumncliff,\\dots,starlitpath$ is zigzag. Find the expected value of $a(silverbrook,duskylake,\\dots,mistyvalley)$ for $goldenshore \\ge 2$.",
      "solution": "The expected value is $\\frac{2\\,goldenshore+2}{3}$.  \n\nDivide the sequence $silverbrook,\\dots,mistyvalley$ into alternating increasing and decreasing segments, with $cobaltplain$ segments in all. Note that removing one term cannot increase $cobaltplain$: if the removed term is interior to some segment then the number remains unchanged, whereas if it separates two segments then one of those decreases in length by 1 (and possibly disappears). From this it follows that $a(silverbrook,\\dots,mistyvalley)=cobaltplain+1$: in one direction, the endpoints of the segments form a zigzag of length $cobaltplain+1$; in the other, for any zigzag $shadowcreek,\\dots,hiddenmeadow$, we can view it as a sequence obtained from $silverbrook,\\dots,mistyvalley$ by removing terms, so its number of segments (which is manifestly $opalharbor-1$) cannot exceed $cobaltplain$.  \n\nFor $goldenshore\\ge3$, $a(silverbrook,\\dots,mistyvalley)-a(duskylake,\\dots,mistyvalley)$ is $0$ if $silverbrook,duskylake,windyridge$ form a monotone sequence and $1$ otherwise. Since the six possible orderings of $silverbrook,duskylake,windyridge$ are equally likely,\n\\[\n\\mathbf{E}\\bigl(a(silverbrook,\\dots,mistyvalley)-a(silverbrook,\\dots,X_{goldenshore-1})\\bigr)=\\frac{2}{3}.\n\\]\nMoreover, we always have $a(silverbrook,duskylake)=2$ because any sequence of two distinct elements is a zigzag. By linearity of expectation plus induction on $goldenshore$, we obtain $\\mathbf{E}\\bigl(a(silverbrook,\\dots,mistyvalley)\\bigr)=\\frac{2\\,goldenshore+2}{3}$ as claimed."
    },
    "descriptive_long_misleading": {
      "map": {
        "y_1": "imaginaryone",
        "y_2": "imaginarytwo",
        "y_k": "imaginarykappa",
        "X_1": "deterministicone",
        "X_2": "deterministictwo",
        "X_3": "deterministicthree",
        "X_n": "deterministicn",
        "X_i_1": "deterministicidxone",
        "X_i_2": "deterministicidxtwo",
        "X_i_k": "deterministicidxkappa",
        "X_i_m": "deterministicidxmu",
        "i_1": "contentone",
        "i_2": "contenttwo",
        "i_k": "contentkappa",
        "i_m": "contentmu",
        "k": "shortindex",
        "N": "monolithnum",
        "m": "minisize",
        "n": "singulars"
      },
      "question": "A sequence $imaginaryone,imaginarytwo,\\dots,imaginarykappa$ of real numbers is called \\emph{zigzag} if $shortindex=1$, or if $imaginarytwo-imaginaryone, y_3-imaginarytwo, \\dots, imaginarykappa-y_{shortindex-1}$ are nonzero and alternate in sign. Let $deterministicone,deterministictwo,\\dots,deterministicn$ be chosen independently from the uniform distribution on $[0,1]$. Let $a(deterministicone,deterministictwo,\\dots,deterministicn)$ be the largest value of $shortindex$ for which there exists an increasing sequence of integers $contentone,contenttwo,\\dots,contentkappa$ such that $deterministicidxone,deterministicidxtwo,\\dots,deterministicidxkappa$ is zigzag. Find the expected value of $a(deterministicone,deterministictwo,\\dots,deterministicn)$ for $\\singulars \\geq 2$.",
      "solution": "The expected value is $\\frac{2\\singulars+2}{3}$.\\n\\nDivide the sequence $deterministicone,\\dots,deterministicn$ into alternating increasing and decreasing segments, with $monolithnum$ segments in all. Note that removing one term cannot increase $monolithnum$: if the removed term is interior to some segment then the number remains unchanged, whereas if it separates two segments then one of those decreases in length by 1 (and possibly disappears). From this it follows that $a(deterministicone,\\dots,deterministicn)=monolithnum+1$: in one direction, the endpoints of the segments form a zigzag of length $monolithnum+1$; in the other, for any zigzag $deterministicidxone,\\dots,deterministicidxmu$, we can view it as a sequence obtained from $deterministicone,\\dots,deterministicn$ by removing terms, so its number of segments (which is manifestly $minisize-1$) cannot exceed $monolithnum$.\\n\\nFor $\\singulars \\geq 3$, $a(deterministicone,\\dots,deterministicn)-a(deterministictwo,\\dots,deterministicn)$ is 0 if $deterministicone,deterministictwo,deterministicthree$ form a monotone sequence and 1 otherwise. Since the six possible orderings of $deterministicone,deterministictwo,deterministicthree$ are equally likely,\\n\\[\\n\\mathbf{E}\\bigl(a(deterministicone,\\dots,deterministicn)-a(deterministicone,\\dots,X_{\\singulars-1})\\bigr)=\\frac{2}{3}.\\n\\]\\nMoreover, we always have $a(deterministicone,deterministictwo)=2$ because any sequence of two distinct elements is a zigzag. By linearity of expectation plus induction on $\\singulars$, we obtain $\\mathbf{E}\\bigl(a(deterministicone,\\dots,deterministicn)\\bigr)=\\frac{2\\singulars+2}{3}$ as claimed."
    },
    "garbled_string": {
      "map": {
        "y_1": "ragplint",
        "y_2": "zundakro",
        "y_k": "vikomple",
        "X_1": "slorbagu",
        "X_2": "nebtrilo",
        "X_3": "famquido",
        "X_n": "hyptegla",
        "X_i_1": "wexlurok",
        "X_i_2": "zomprade",
        "X_i_k": "jirpendu",
        "X_i_m": "quastipe",
        "i_1": "brenquaf",
        "i_2": "snulgore",
        "i_k": "cliphant",
        "i_m": "trexalop",
        "k": "dodrimex",
        "N": "vurplase",
        "m": "kratildo",
        "n": "monklute"
      },
      "question": "A sequence $ragplint,zundakro,\\dots,vikomple$ of real numbers is called \\emph{zigzag} if $dodrimex=1$, or if $zundakro-ragplint, y_3-zundakro, \\dots, vikomple-y_{dodrimex-1}$ are nonzero and alternate in sign. Let $slorbagu,nebtrilo,\\dots,hyptegla$ be chosen independently from the uniform distribution on $[0,1]$. Let $a(slorbagu,nebtrilo,\\dots,hyptegla)$ be the largest value of $dodrimex$ for which there exists an increasing sequence of integers $brenquaf,snulgore,\\dots,cliphant$ such that $wexlurok,zomprade,\\dots,jirpendu$ is zigzag. Find the expected value of $a(slorbagu,nebtrilo,\\dots,hyptegla)$ for $monklute \\geq 2$.",
      "solution": "The expected value is $\\frac{2monklute+2}{3}$.\\n\\nDivide the sequence $slorbagu,\\dots,hyptegla$ into alternating increasing and decreasing segments, with $vurplase$ segments in all. Note that removing one term cannot increase $vurplase$: if the removed term is interior to some segment then the number remains unchanged, whereas if it separates two segments then one of those decreases in length by 1 (and possibly disappears). From this it follows that $a(slorbagu,\\dots,hyptegla) = vurplase+1$: in one direction, the endpoints of the segments form a zigzag of length $vurplase+1$; in the other, for any zigzag $wexlurok,\\dots, quastipe$, we can view it as a sequence obtained from $slorbagu,\\dots,hyptegla$ by removing terms, so its number of segments (which is manifestly $kratildo-1$) cannot exceed $vurplase$.\\n\\nFor $monklute \\geq 3$, $a(slorbagu,\\dots,hyptegla) - a(nebtrilo,\\dots,hyptegla)$ is 0 if $slorbagu, nebtrilo, famquido$ form a monotone sequence and 1 otherwise. Since the six possible orderings of $slorbagu,nebtrilo,famquido$ are equally likely,\\n\\[\\mathbf{E}(a(slorbagu,\\dots,hyptegla) - a(slorbagu,\\dots,X_{monklute-1})) = \\frac{2}{3}.\\]Moreover, we always have $a(slorbagu, nebtrilo) = 2$ because any sequence of two distinct elements is a zigzag. By linearity of expectation plus induction on $monklute$, we obtain $\\mathbf{E}(a(slorbagu,\\dots,hyptegla)) = \\frac{2monklute+2}{3}$ as claimed."
    },
    "kernel_variant": {
      "question": "Let $n\\ge 3$ be an integer and let $X_{1},X_{2},\\dots ,X_{n}$ be independent standard normal random variables.  \nA finite real sequence $y_{1},y_{2},\\dots ,y_{k}$ is called \\emph{zig--zag} if $k=1$ or, for $k\\ge 2$, the successive (non--zero) differences  \n\\[\ny_{2}-y_{1},\\;y_{3}-y_{2},\\;\\dots ,\\;y_{k}-y_{k-1}\n\\]\nalternate in sign.\nDenote by $a(X_{1},X_{2},\\dots ,X_{n})$ the length of the longest alternating subsequence (LAS) of $(X_{1},X_{2},\\dots ,X_{n})$ and put  \n\\[\nA_{n}:=a(X_{1},X_{2},\\dots ,X_{n}).\n\\]\n\n\\begin{enumerate}\n\\item[(1)] Show that for every $n\\ge 3$\n\\[\n\\mathbb{E}[A_{n}]=\\frac{2n+2}{3}.\n\\]\n\n\\item[(2)] Compute the exact variance and prove that for every $n\\ge 4$\n\\[\n\\operatorname{Var}(A_{n})=\\frac{26n-34}{180}.\n\\]\n\n\\item[(3)] Establish the central--limit theorem\n\\[\n\\frac{A_{n}-\\mathbb{E}[A_{n}]}{\\sqrt{\\operatorname{Var}(A_{n})}}\\;\\Longrightarrow\\;N(0,1)\n\\quad\\text{as }n\\to\\infty ,\n\\]\nwhere $\\Longrightarrow$ denotes convergence in distribution.\n\\end{enumerate}",
      "solution": "\\textbf{Overview.}\nExactly as in the classical argument for the mean, $A_{n}$ equals one plus the number of maximal monotone runs of $(X_{1},\\dots ,X_{n})$.  \nIntroduce the indicators\n\\[\nD_{t}:=\\mathbf 1_{\\{\\,(X_{t-2},X_{t-1},X_{t})\\text{ is \\emph{not} monotone}\\,\\}},\n\\qquad t=3,\\dots ,n. \\tag{0}\n\\]\nThe sequence $(D_{t})_{t\\ge 3}$ is \\emph{stationary}, \\emph{square--integrable} and \\emph{$2$--dependent} (that is, $D_{s}$ and $D_{t}$ are independent once $|s-t|\\ge 3$).  We analyse it in turn.\n\n\\medskip\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\textbf{Step 0. From runs to the indicators $D_{t}$.}\n\nLet $N_{n}$ be the number of maximal monotone segments (runs) of the path $(X_{1},\\dots ,X_{n})$.  As in the kernel problem one proves\n\\[\nA_{n}=N_{n}+1. \\tag{1}\n\\]\nAppending $X_{t}$ creates a new run iff the triple $(X_{t-2},X_{t-1},X_{t})$ is not monotone, i.e.\\ iff $D_{t}=1$.  Hence for $t\\ge 3$\n\\[\n\\Delta_{t}:=A_{t}-A_{t-1}=D_{t}. \\tag{2}\n\\]\nBecause $A_{2}=2$ and $A_{3}=2+D_{3}$, summing \\eqref{2} yields for every $n\\ge 3$\n\\[\nA_{n}=2+\\sum_{t=3}^{n}D_{t}. \\tag{3}\n\\]\n\n\\medskip\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\textbf{Step 1. The mean.}\n\nFor three i.i.d.\\ continuous random variables each of the $3!=6$ possible relative orders is equally likely; in exactly $4$ of them the middle value is an extremum.  Consequently\n\\[\np:=\\mathbb{P}(D_{t}=1)=\\frac{4}{6}=\\frac{2}{3}. \\tag{4}\n\\]\nInserting \\eqref{4} into \\eqref{3} gives\n\\[\n\\mathbb{E}[A_{n}]=2+(n-2)p=\\frac{2n+2}{3}, \\tag{5}\n\\]\nestablishing item~(1).\n\n\\medskip\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\textbf{Step 2. Covariances and the exact variance.}\n\nBecause $(D_{t})$ is $2$--dependent, only lags $0,1,2$ contribute to $\\operatorname{Var}(A_{n})$.\n\n\\smallskip\n(2.1) \\emph{Variance of a single $D_{t}$.}\n\\[\n\\operatorname{Var}(D_{t})=p(1-p)=\\frac{2}{3}\\cdot\\frac13=\\frac29. \\tag{6}\n\\]\n\n\\smallskip\n(2.2) \\emph{Covariance for lag $1$.}\n$D_{t}$ depends on $(X_{t-2},X_{t-1},X_{t})$ and $D_{t+1}$ on $(X_{t-1},X_{t},X_{t+1})$; altogether four independent coordinates are involved.  \nEnumerating the $4!=24$ permutations reveals that in exactly ten of them both consecutive triples are non--monotone, hence\n\\[\n\\mathbb{P}(D_{t}=D_{t+1}=1)=\\frac{10}{24}=\\frac{5}{12}. \\tag{7}\n\\]\nTherefore\n\\[\n\\operatorname{Cov}(D_{t},D_{t+1})=\\frac{5}{12}-p^{2}=\\frac{5}{12}-\\frac49=-\\frac1{36}. \\tag{8}\n\\]\n\n\\smallskip\n(2.3) \\emph{Covariance for lag $2$.}\nNow $D_{t}$ depends on $(X_{t-2},X_{t-1},X_{t})$ whereas $D_{t+2}$ depends on\n$(X_{t},X_{t+1},X_{t+2})$.  Write\n\\[\n(a,b,c,d,e):=(X_{t-2},X_{t-1},X_{t},X_{t+1},X_{t+2})\n\\]\nand denote\n\\[\ns_{1}=\\operatorname{sgn}(b-a),\\;s_{2}=\\operatorname{sgn}(c-b),\\;\ns_{3}=\\operatorname{sgn}(d-c),\\;s_{4}=\\operatorname{sgn}(e-d). \\tag{9}\n\\]\nThe events\n\\[\nD_{t}=1\\iff s_{1}\\neq s_{2},\\qquad \nD_{t+2}=1\\iff s_{3}\\neq s_{4} \\tag{10}\n\\]\nare fully determined by the four signs.  Hence $D_{t}=D_{t+2}=1$ iff\n\\[\n(s_{1},s_{2},s_{3},s_{4})\\in\n\\{(+,-,+,-),(+,-,-,+),(-,+,+,-),(-,+,-,+)\\}. \\tag{11}\n\\]\nWe condition on the rank $r$ of $c$ among the five independent values $(a,b,c,d,e)$.\n\n\\smallskip\n\\emph{Case $r=1$ or $r=5$.}  \nHere $c$ is the global minimum or maximum.  Exactly two inequalities, namely $a<b$ and $d>e$ (or their symmetric counterparts), must hold; being independent, each halves the $4!$\nadmissible permutations of $(a,b,d,e)$, leaving $6$ favourable out of $24$.  Thus\n\\[\n\\mathbb{P}(D_{t}=D_{t+2}=1\\mid r=1\\text{ or }5)=\\frac{6}{24}=\\frac14. \\tag{12}\n\\]\n\n\\smallskip\n\\emph{Case $r=2$ or $r=4$.}  \nExactly one of the four remaining letters lies on the opposite side of $c$.  Denote it by $L$.  \nThe event $D_{t}=D_{t+2}=1$ occurs precisely when  \n\n(i) $L\\in\\{a,b\\}$ and $d>e$,  or  \n(ii) $L\\in\\{d,e\\}$ and $b>a$.\n\nWithin each sub--event there are six favourable permutations of the $4$ other letters, whence\n\\[\n\\mathbb{P}(D_{t}=D_{t+2}=1\\mid r=2\\text{ or }4)=\\frac{12}{24}=\\frac12. \\tag{13}\n\\]\n\n\\smallskip\n\\emph{Case $r=3$.}  \nTwo letters are smaller and two larger than $c$.  The event occurs iff both sets $\\{a,b\\}$ and $\\{d,e\\}$ are split between the lower and upper group; this has probability $\\tfrac46$.  All $2!\\cdot2!$ relative orders inside the two groups are admissible, yielding $16$ out of $24$ permutations:\n\\[\n\\mathbb{P}(D_{t}=D_{t+2}=1\\mid r=3)=\\frac{16}{24}=\\frac23. \\tag{14}\n\\]\n\n\\smallskip\nPutting the five equally likely cases together,\n\\[\n\\begin{aligned}\n\\mathbb{P}(D_{t}=D_{t+2}=1)\n&=\\frac15\\Bigl(\\tfrac14+\\tfrac12+\\tfrac23+\\tfrac12+\\tfrac14\\Bigr)\n=\\frac{13}{30}.\n\\end{aligned} \\tag{15}\n\\]\nHence\n\\[\n\\operatorname{Cov}(D_{t},D_{t+2})=\\frac{13}{30}-p^{2}=\n\\frac{13}{30}-\\frac49=-\\frac1{90}. \\tag{16}\n\\]\n\n\\smallskip\n(2.4) \\emph{Assembling the variance.}\nFor $n\\ge 5$, using \\eqref{3},\n\\[\n\\begin{aligned}\n\\operatorname{Var}(A_{n})&=\n\\sum_{t=3}^{n}\\operatorname{Var}(D_{t})\n+2\\sum_{t=3}^{n-1}\\operatorname{Cov}(D_{t},D_{t+1})\n+2\\sum_{t=3}^{n-2}\\operatorname{Cov}(D_{t},D_{t+2})  \\\\[2mm]\n&=(n-2)\\cdot\\frac29+2(n-3)\\!\\left(-\\frac1{36}\\right)\n       +2(n-4)\\!\\left(-\\frac1{90}\\right)                    \\\\[2mm]\n&=\\frac{26n-34}{180},\n\\end{aligned} \\tag{17}\n\\]\nvalid for every $n\\ge 4$.  This completes item~(2).\n\n\\medskip\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\textbf{Step 3. A central--limit theorem for $A_{n}$.}\n\nDefine the centred variables\n\\[\nY_{t}:=D_{t}-p,\\qquad t\\ge 3. \\tag{18}\n\\]\nThe sequence $(Y_{t})$ is stationary, square--integrable and $2$--dependent.  \nHoeffding and Robbins (1948) proved a central--limit theorem for any $m$--dependent, square--integrable sequence; in particular,\n\\[\n\\frac{\\sum_{t=3}^{n}Y_{t}}{\\sqrt{n\\tau^{2}}}\\;\\Longrightarrow\\;N(0,1),\n\\qquad n\\to\\infty , \\tag{19}\n\\]\nwhere\n\\[\n\\begin{aligned}\n\\tau^{2}&=\\operatorname{Var}(Y_{t})\n          +2\\operatorname{Cov}(Y_{t},Y_{t+1})\n          +2\\operatorname{Cov}(Y_{t},Y_{t+2}) \\\\[2mm]\n&=\\frac29+2\\!\\left(-\\frac1{36}\\right)+2\\!\\left(-\\frac1{90}\\right)\n=\\frac{13}{90}.  \\tag{20}\n\\end{aligned}\n\\]\n(Because $(Y_{t})$ is bounded and $m$--dependent, the Lyapunov and Lindeberg conditions are automatically satisfied, so the Hoeffding--Robbins theorem applies directly.)\n\nFrom \\eqref{3} and \\eqref{18},\n\\[\nA_{n}-\\mathbb{E}[A_{n}]=\\sum_{t=3}^{n}Y_{t}.\n\\]\nComparing \\eqref{20} with the exact variance \\eqref{17},\n\\[\n\\operatorname{Var}(A_{n})=n\\tau^{2}-\\frac{34}{180}.\n\\]\nSince the difference between $\\operatorname{Var}(A_{n})$ and $n\\tau^{2}$ is a bounded constant, replacing $\\sqrt{n\\tau^{2}}$ in \\eqref{19} by $\\sqrt{\\operatorname{Var}(A_{n})}$ does not affect the limit.  Consequently,\n\\[\n\\frac{A_{n}-\\mathbb{E}[A_{n}]}{\\sqrt{\\operatorname{Var}(A_{n})}}\n\\;\\Longrightarrow\\;N(0,1),\\qquad n\\to\\infty ,\n\\]\nwhich establishes item~(3). \\hfill$\\square$\n\n\\medskip\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
      "metadata": {
        "replaced_from": "harder_variant",
        "replacement_date": "2025-07-14T19:09:31.880264",
        "was_fixed": false,
        "difficulty_analysis": "•  Extra quantitative targets.  \n  The original problem only asked for E[Aₙ]; here one must also\n  find Var(Aₙ) and establish a full CLT, demanding second-order\n  as well as asymptotic information.\n\n•  Local–dependence combinatorics.  \n  Computing Cov(D_t,D_{t+1}) forces an explicit enumeration of\n  the 24 relative orderings of four points; the variance formula\n  requires careful bookkeeping of all overlapping triples.\n\n•  Probability-limit theory.  \n  Item 3 cannot be dispatched by elementary expectation\n  manipulations: one must recognise the 2-dependent structure\n  and invoke (or prove) a non-trivial m-dependent central-limit\n  theorem (Hoeffding–Robbins/Tikhomirov, or an appropriate\n  martingale CLT).\n\n•  Higher conceptual load.  \n  The solver has to intertwine combinatorial enumeration,\n  second-moment calculus, and limit theorems for dependent\n  variables—three separate advanced techniques instead of the\n  single first-moment trick that sufficed for the original\n  exercise.\n\nFor these reasons the enhanced variant is substantially more\ntechnically involved and conceptually demanding than both the\noriginal problem and the current kernel version."
      }
    },
    "original_kernel_variant": {
      "question": "Let $n\\ge 3$ be an integer and let $X_{1},X_{2},\\dots ,X_{n}$ be independent standard normal random variables.  \nA finite real sequence $y_{1},y_{2},\\dots ,y_{k}$ is called \\emph{zig--zag} if $k=1$ or, for $k\\ge 2$, the successive (non--zero) differences  \n\\[\ny_{2}-y_{1},\\;y_{3}-y_{2},\\;\\dots ,\\;y_{k}-y_{k-1}\n\\]\nalternate in sign.\nDenote by $a(X_{1},X_{2},\\dots ,X_{n})$ the length of the longest alternating subsequence (LAS) of $(X_{1},X_{2},\\dots ,X_{n})$ and put  \n\\[\nA_{n}:=a(X_{1},X_{2},\\dots ,X_{n}).\n\\]\n\n\\begin{enumerate}\n\\item[(1)] Show that for every $n\\ge 3$\n\\[\n\\mathbb{E}[A_{n}]=\\frac{2n+2}{3}.\n\\]\n\n\\item[(2)] Compute the exact variance and prove that for every $n\\ge 4$\n\\[\n\\operatorname{Var}(A_{n})=\\frac{26n-34}{180}.\n\\]\n\n\\item[(3)] Establish the central--limit theorem\n\\[\n\\frac{A_{n}-\\mathbb{E}[A_{n}]}{\\sqrt{\\operatorname{Var}(A_{n})}}\\;\\Longrightarrow\\;N(0,1)\n\\quad\\text{as }n\\to\\infty ,\n\\]\nwhere $\\Longrightarrow$ denotes convergence in distribution.\n\\end{enumerate}",
      "solution": "\\textbf{Overview.}\nExactly as in the classical argument for the mean, $A_{n}$ equals one plus the number of maximal monotone runs of $(X_{1},\\dots ,X_{n})$.  \nIntroduce the indicators\n\\[\nD_{t}:=\\mathbf 1_{\\{\\,(X_{t-2},X_{t-1},X_{t})\\text{ is \\emph{not} monotone}\\,\\}},\n\\qquad t=3,\\dots ,n. \\tag{0}\n\\]\nThe sequence $(D_{t})_{t\\ge 3}$ is \\emph{stationary}, \\emph{square--integrable} and \\emph{$2$--dependent} (that is, $D_{s}$ and $D_{t}$ are independent once $|s-t|\\ge 3$).  We analyse it in turn.\n\n\\medskip\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\textbf{Step 0. From runs to the indicators $D_{t}$.}\n\nLet $N_{n}$ be the number of maximal monotone segments (runs) of the path $(X_{1},\\dots ,X_{n})$.  As in the kernel problem one proves\n\\[\nA_{n}=N_{n}+1. \\tag{1}\n\\]\nAppending $X_{t}$ creates a new run iff the triple $(X_{t-2},X_{t-1},X_{t})$ is not monotone, i.e.\\ iff $D_{t}=1$.  Hence for $t\\ge 3$\n\\[\n\\Delta_{t}:=A_{t}-A_{t-1}=D_{t}. \\tag{2}\n\\]\nBecause $A_{2}=2$ and $A_{3}=2+D_{3}$, summing \\eqref{2} yields for every $n\\ge 3$\n\\[\nA_{n}=2+\\sum_{t=3}^{n}D_{t}. \\tag{3}\n\\]\n\n\\medskip\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\textbf{Step 1. The mean.}\n\nFor three i.i.d.\\ continuous random variables each of the $3!=6$ possible relative orders is equally likely; in exactly $4$ of them the middle value is an extremum.  Consequently\n\\[\np:=\\mathbb{P}(D_{t}=1)=\\frac{4}{6}=\\frac{2}{3}. \\tag{4}\n\\]\nInserting \\eqref{4} into \\eqref{3} gives\n\\[\n\\mathbb{E}[A_{n}]=2+(n-2)p=\\frac{2n+2}{3}, \\tag{5}\n\\]\nestablishing item~(1).\n\n\\medskip\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\textbf{Step 2. Covariances and the exact variance.}\n\nBecause $(D_{t})$ is $2$--dependent, only lags $0,1,2$ contribute to $\\operatorname{Var}(A_{n})$.\n\n\\smallskip\n(2.1) \\emph{Variance of a single $D_{t}$.}\n\\[\n\\operatorname{Var}(D_{t})=p(1-p)=\\frac{2}{3}\\cdot\\frac13=\\frac29. \\tag{6}\n\\]\n\n\\smallskip\n(2.2) \\emph{Covariance for lag $1$.}\n$D_{t}$ depends on $(X_{t-2},X_{t-1},X_{t})$ and $D_{t+1}$ on $(X_{t-1},X_{t},X_{t+1})$; altogether four independent coordinates are involved.  \nEnumerating the $4!=24$ permutations reveals that in exactly ten of them both consecutive triples are non--monotone, hence\n\\[\n\\mathbb{P}(D_{t}=D_{t+1}=1)=\\frac{10}{24}=\\frac{5}{12}. \\tag{7}\n\\]\nTherefore\n\\[\n\\operatorname{Cov}(D_{t},D_{t+1})=\\frac{5}{12}-p^{2}=\\frac{5}{12}-\\frac49=-\\frac1{36}. \\tag{8}\n\\]\n\n\\smallskip\n(2.3) \\emph{Covariance for lag $2$.}\nNow $D_{t}$ depends on $(X_{t-2},X_{t-1},X_{t})$ whereas $D_{t+2}$ depends on\n$(X_{t},X_{t+1},X_{t+2})$.  Write\n\\[\n(a,b,c,d,e):=(X_{t-2},X_{t-1},X_{t},X_{t+1},X_{t+2})\n\\]\nand denote\n\\[\ns_{1}=\\operatorname{sgn}(b-a),\\;s_{2}=\\operatorname{sgn}(c-b),\\;\ns_{3}=\\operatorname{sgn}(d-c),\\;s_{4}=\\operatorname{sgn}(e-d). \\tag{9}\n\\]\nThe events\n\\[\nD_{t}=1\\iff s_{1}\\neq s_{2},\\qquad \nD_{t+2}=1\\iff s_{3}\\neq s_{4} \\tag{10}\n\\]\nare fully determined by the four signs.  Hence $D_{t}=D_{t+2}=1$ iff\n\\[\n(s_{1},s_{2},s_{3},s_{4})\\in\n\\{(+,-,+,-),(+,-,-,+),(-,+,+,-),(-,+,-,+)\\}. \\tag{11}\n\\]\nWe condition on the rank $r$ of $c$ among the five independent values $(a,b,c,d,e)$.\n\n\\smallskip\n\\emph{Case $r=1$ or $r=5$.}  \nHere $c$ is the global minimum or maximum.  Exactly two inequalities, namely $a<b$ and $d>e$ (or their symmetric counterparts), must hold; being independent, each halves the $4!$\nadmissible permutations of $(a,b,d,e)$, leaving $6$ favourable out of $24$.  Thus\n\\[\n\\mathbb{P}(D_{t}=D_{t+2}=1\\mid r=1\\text{ or }5)=\\frac{6}{24}=\\frac14. \\tag{12}\n\\]\n\n\\smallskip\n\\emph{Case $r=2$ or $r=4$.}  \nExactly one of the four remaining letters lies on the opposite side of $c$.  Denote it by $L$.  \nThe event $D_{t}=D_{t+2}=1$ occurs precisely when  \n\n(i) $L\\in\\{a,b\\}$ and $d>e$,  or  \n(ii) $L\\in\\{d,e\\}$ and $b>a$.\n\nWithin each sub--event there are six favourable permutations of the $4$ other letters, whence\n\\[\n\\mathbb{P}(D_{t}=D_{t+2}=1\\mid r=2\\text{ or }4)=\\frac{12}{24}=\\frac12. \\tag{13}\n\\]\n\n\\smallskip\n\\emph{Case $r=3$.}  \nTwo letters are smaller and two larger than $c$.  The event occurs iff both sets $\\{a,b\\}$ and $\\{d,e\\}$ are split between the lower and upper group; this has probability $\\tfrac46$.  All $2!\\cdot2!$ relative orders inside the two groups are admissible, yielding $16$ out of $24$ permutations:\n\\[\n\\mathbb{P}(D_{t}=D_{t+2}=1\\mid r=3)=\\frac{16}{24}=\\frac23. \\tag{14}\n\\]\n\n\\smallskip\nPutting the five equally likely cases together,\n\\[\n\\begin{aligned}\n\\mathbb{P}(D_{t}=D_{t+2}=1)\n&=\\frac15\\Bigl(\\tfrac14+\\tfrac12+\\tfrac23+\\tfrac12+\\tfrac14\\Bigr)\n=\\frac{13}{30}.\n\\end{aligned} \\tag{15}\n\\]\nHence\n\\[\n\\operatorname{Cov}(D_{t},D_{t+2})=\\frac{13}{30}-p^{2}=\n\\frac{13}{30}-\\frac49=-\\frac1{90}. \\tag{16}\n\\]\n\n\\smallskip\n(2.4) \\emph{Assembling the variance.}\nFor $n\\ge 5$, using \\eqref{3},\n\\[\n\\begin{aligned}\n\\operatorname{Var}(A_{n})&=\n\\sum_{t=3}^{n}\\operatorname{Var}(D_{t})\n+2\\sum_{t=3}^{n-1}\\operatorname{Cov}(D_{t},D_{t+1})\n+2\\sum_{t=3}^{n-2}\\operatorname{Cov}(D_{t},D_{t+2})  \\\\[2mm]\n&=(n-2)\\cdot\\frac29+2(n-3)\\!\\left(-\\frac1{36}\\right)\n       +2(n-4)\\!\\left(-\\frac1{90}\\right)                    \\\\[2mm]\n&=\\frac{26n-34}{180},\n\\end{aligned} \\tag{17}\n\\]\nvalid for every $n\\ge 4$.  This completes item~(2).\n\n\\medskip\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\textbf{Step 3. A central--limit theorem for $A_{n}$.}\n\nDefine the centred variables\n\\[\nY_{t}:=D_{t}-p,\\qquad t\\ge 3. \\tag{18}\n\\]\nThe sequence $(Y_{t})$ is stationary, square--integrable and $2$--dependent.  \nHoeffding and Robbins (1948) proved a central--limit theorem for any $m$--dependent, square--integrable sequence; in particular,\n\\[\n\\frac{\\sum_{t=3}^{n}Y_{t}}{\\sqrt{n\\tau^{2}}}\\;\\Longrightarrow\\;N(0,1),\n\\qquad n\\to\\infty , \\tag{19}\n\\]\nwhere\n\\[\n\\begin{aligned}\n\\tau^{2}&=\\operatorname{Var}(Y_{t})\n          +2\\operatorname{Cov}(Y_{t},Y_{t+1})\n          +2\\operatorname{Cov}(Y_{t},Y_{t+2}) \\\\[2mm]\n&=\\frac29+2\\!\\left(-\\frac1{36}\\right)+2\\!\\left(-\\frac1{90}\\right)\n=\\frac{13}{90}.  \\tag{20}\n\\end{aligned}\n\\]\n(Because $(Y_{t})$ is bounded and $m$--dependent, the Lyapunov and Lindeberg conditions are automatically satisfied, so the Hoeffding--Robbins theorem applies directly.)\n\nFrom \\eqref{3} and \\eqref{18},\n\\[\nA_{n}-\\mathbb{E}[A_{n}]=\\sum_{t=3}^{n}Y_{t}.\n\\]\nComparing \\eqref{20} with the exact variance \\eqref{17},\n\\[\n\\operatorname{Var}(A_{n})=n\\tau^{2}-\\frac{34}{180}.\n\\]\nSince the difference between $\\operatorname{Var}(A_{n})$ and $n\\tau^{2}$ is a bounded constant, replacing $\\sqrt{n\\tau^{2}}$ in \\eqref{19} by $\\sqrt{\\operatorname{Var}(A_{n})}$ does not affect the limit.  Consequently,\n\\[\n\\frac{A_{n}-\\mathbb{E}[A_{n}]}{\\sqrt{\\operatorname{Var}(A_{n})}}\n\\;\\Longrightarrow\\;N(0,1),\\qquad n\\to\\infty ,\n\\]\nwhich establishes item~(3). \\hfill$\\square$\n\n\\medskip\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
      "metadata": {
        "replaced_from": "harder_variant",
        "replacement_date": "2025-07-14T01:37:45.665591",
        "was_fixed": false,
        "difficulty_analysis": "•  Extra quantitative targets.  \n  The original problem only asked for E[Aₙ]; here one must also\n  find Var(Aₙ) and establish a full CLT, demanding second-order\n  as well as asymptotic information.\n\n•  Local–dependence combinatorics.  \n  Computing Cov(D_t,D_{t+1}) forces an explicit enumeration of\n  the 24 relative orderings of four points; the variance formula\n  requires careful bookkeeping of all overlapping triples.\n\n•  Probability-limit theory.  \n  Item 3 cannot be dispatched by elementary expectation\n  manipulations: one must recognise the 2-dependent structure\n  and invoke (or prove) a non-trivial m-dependent central-limit\n  theorem (Hoeffding–Robbins/Tikhomirov, or an appropriate\n  martingale CLT).\n\n•  Higher conceptual load.  \n  The solver has to intertwine combinatorial enumeration,\n  second-moment calculus, and limit theorems for dependent\n  variables—three separate advanced techniques instead of the\n  single first-moment trick that sufficed for the original\n  exercise.\n\nFor these reasons the enhanced variant is substantially more\ntechnically involved and conceptually demanding than both the\noriginal problem and the current kernel version."
      }
    }
  },
  "checked": true,
  "problem_type": "calculation"
}