12

Seven cards numbered from $1$ to $7$ are randomly shuffled and then arranged in a circle. Given that the $1$ and $7$ are adjacent to each other, what is the expected number of cards that are larger than both of their neighbors?

I am not sure I understand the question correctly. But here's my thought process:

If $1$ and $7$ are adjacent, their neighbors can be chosen in $5C_2 = 10$ ways, therefore, if the neighbors are $2$ and $3$, for instance, these can come in $2$ ways $(2,3)$ and $(3,2)$, hence it's probability is $\frac{2}{10}$ and the numbers larger than $2$ and $3$ are $4,5,$ and $6$. Working on individual cases like this I arrived at the following:

$\frac{2}{10} \times 3 + \frac{2}{10} \times 2 + \frac{2}{10} \times 1 + \frac{2}{10} \times 2 + \frac{2}{10} \times 1 + \frac{2}{10} \times 1 = 2$

Therefore, the answer is $2$, but this is wrong. I simulated it and I got $\approx 2.5$. How can I solve this question?

Shs Tht
  • 1,321
  • 1
    It's not clear to me what you are doing. Can you elaborate on how you work on the individual cases? EG For the specific case of $(2, 3)$, are you saying that there are 3 (expected?) numbers who would be larger than their neighbors? – Calvin Lin Oct 15 '24 at 08:42
  • If $2$ and $3$ are the neighbors of $1$ and $7$, they would have 3 numbers larger than them, namely, $3,4,$ and $5$. I think I must've misinterpreted the question. – Shs Tht Oct 15 '24 at 09:36
  • Ah, ic. We could indeed do that analysis by considering neighbors, but you need to be accurate. If we had 1, 7, 2, 4, 5, 6, 3 then there's only 2 LTN values. However if we had 1, 7, 2, 6, 4, 5, 3, then there are 3 LTN values. This only happens if 4 is between 5 and 6. So, the expected value is somewhere between $ 2/3 \times 2 + 1/3 \times 3 = 2 \frac{1}{3}$ in this case. I encourage you to work this out.$\quad$ An indicator variable analysis on $1, 7, 2, A, B, C, 3$ similar to my post yields an expected value of $0+1+0+1/2+1/3+1/2+0 = 2 \frac{1}{3}$. (which matches up with the case analysis) – Calvin Lin Oct 16 '24 at 14:35

2 Answers2

21

Consider the position for the 7 cards as (WLOG) $ 1, 7, A, B, C, D, E$.

Let I be the random variable for the number of larger-than-neighbors (LTN for short).
We apply the indicator variables to calculate the expected value that each position is LTN, so $I = I_1 + I_7 + I_A + I_B + I_C + I_D + I_E$

  • 1: $E(I_1) = 0$ clearly.
  • 7: $E(I_7) = 1 $ clearly.
  • A: $E(I_A) = 0 $ clearly.
  • B: $E(I_B) = 1/3$, since there are 6 ways to arrange A, B, C with 2 ways resulting in $ A < B > C$.
  • C: $E(I_C) = 1/3$ for the same reason.
  • D: $E(I_D) = 1/3$ for the same reason.
  • E: $E(I_E) = 1/2$. Can you explain why?

Then $E(I) = E(I_1) + E(I_7) + E(I_A) + E(I_B) + E(I_C) + E(I_D) + E(I_E) = 2.5$. This matches OP's simulation.


Note

  • Without the condition that 1 is next to 7, a similar indicator variable analysis gives that the expected number of larger cards is $ \frac{7}{3}$.
Calvin Lin
  • 77,541
  • I was thinking $1,A,B,C,D,E,7$, but obviously that makes no difference in the final result, only in the indexing. – David K Oct 15 '24 at 20:09
  • 4
    It is not obvious to me that the events $I_B$, $I_C$, $I_D$ and $I_E$ are independent, which is what you need to straight add up the probabilities. The result aligns with the simulation, which is good, but it would be nice to show an argument for it. – Rad80 Oct 16 '24 at 09:01
  • 3
    @Rad80 The events do not need to be independent. See here. (Here is another question that uses this "trick".) – Dan Oct 16 '24 at 09:24
  • @Dan Neat, didnt'think of that. It'd be worth a mention in the answer IMO. – Rad80 Oct 16 '24 at 15:04
  • @Rad80 Indicator variables (alongside the linearity of expectation) is a standard technique, and I don't feel that it warrants additional elaboration each time it is used. If that approach is new to you, I'd encourage you to read up more about it. $\quad$ Relatedly, my fav finance interview question is: I'm going to toss 5 coins. You can choose between 2 payoff structures. A/ 1 for each consecutive HH, B/1 for each consecutive HT. Which would you pick and why. – Calvin Lin Oct 16 '24 at 15:08
  • @CalvinLin Depends whether the objective is the pay (with utility value proportional to the amount), or to win by being the player paid more. If the former, then linearity of expectation applied to each toss that follows a H. If the latter, then HT has the greater chance to win even though HH can, and HT can't, score 2 on successive tosses. Chances: HT: 13/32, HH: 10/32, draw, 9/32. – Rosie F Oct 17 '24 at 07:38
  • @RosieF (Assume you receive the payoff) Linearity of expectation applies to both cases. Why are you concerned about the probability that a payoff wins over the other? Does simply winning mean that it is better? Would you accept a 99% of wining 1 but a 1% of losing 10000000? What are the expected payoffs? – Calvin Lin Oct 17 '24 at 11:21
2

For lack of a better place, here's the solution to the analogous problem for arbitrary number $N$ of cards: The expected number $E_n$ of cards larger than both neighboring cards is $$ \begin{align*} E_n = & 1 + \frac{1}{(N-2)!} \sum_{j=3}^{N-1} \left[ (j-2) (N-4)! + N (j-2) (j-3) (N-5)!\right] \\ = & 1 + \frac{1}{(N-2)(N-3)} \sum_{j=3}^{N-1} (j-2)^2 \\ = & \frac{2N+1}{6} \end{align*} $$ The $1$ is for the card labelled $N$. The first term in the sum counts the number of configurations with card $j$ adjacent to card $1$ and larger than its other neighbor. The second term in the sum counts all other configurations where card $j$ is larger than its neighbors.

If you remove the constraint on card $1$ being next to card $N$, then the analogous expression becomes

$$ \begin{align*} E_n = & \frac{1}{N!} \sum_{j=1}^{N} N (j-1) (j-2) (N-3)! \\ = & \frac{1}{(N-1)(N-2)} \sum_{j=1}^{N} (j-1) (j-2) \\ = & \frac{N}{3} \end{align*} $$

This is obvious if you phrase it this way: Given three random cards displayed from left to right, the odds that the largest one is in the middle is $1/3$.


Some informal analysis:

The fact that the asymptotic behavior of the two problems is the same says that boundary conditions don't matter in the large $N$ limit. The difference between $E_n$ in the two cases, $1/6$, can be interpreted like this:

  • Call a card "hot" if it is bigger than its two neighbors, and "cold" otherwise.
  • For large $N$, the highest card $N$ always makes its two neighbors cold. These neighbors would otherwise have a $1/3$ chance each of being hot. So the $N$ card on average cools $1/3$ of a hot card for each of its two neighbors.
  • Similarly, the $1$ card increases the chance that each of its neighbors is hot from $1/3$ to $1/2$, since a neighbor to $1$ has $1/2$ odds of being bigger than its other neighbor. So on average, the $1$ card heats up each neighbor by $\left(\frac{1}{2}-\frac{1}{3}\right) = 1/6$.
  • When you put $1$ next to $N$, both lose one neighbor that would otherwise be affected as above. That means the other cards are on average $1/3 - 1/6 = 1/6$ hotter.
Yly
  • 15,791
  • 1
    I found this a very fun circle of problems. I'd like to thank the OP for trying to cheat on their homework. (PS: I would not have posted this unless there were already another solution posted.) – Yly Oct 17 '24 at 02:05