Learn from a vibrant community of students and enthusiasts,
including olympiad champions, researchers, and professionals.

Expected chain

Background

Audition Online is a music game where players compete to gain the most number of points in a given song. In each song, there are a certain number of bars - in each bar, a player has to execute a certain sequence of keystrokes and press spacebar on the 4th beat. A judgment is made based on how accurately the spacebar is pressed - from best to worst, "perfect", "great", "cool", "bad", and "miss". When a player does 2 or more "perfects" consecutively, he will get bonus points for doing so. Within a song, the largest number of consecutive "perfects" a player gets is called his "chain".

Problem

A song has \(n\) number of bars. Assume that a given player has a constant probability of getting a "perfect", \(p\), on each bar. The chain for a particular song (largest number of consecutive "perfects") is denoted as \(c\).

What is the expected value of \(c\) in terms of \(n\) and \(p\)?

Add-on: What is the probability of getting a particular \(c\) in terms of \(n\) and \(p\)? (In essence, what is the probability distribution of \(c\)?)

Checks

A valid solution must minimally satisfy the following cases:

We know that given \(p=1\) (i.e. a completely perfect player), \(c=n\).

We also know that given \(p=0\) (i.e. a completely horrible player), \(c=0\).

A song with \(n=1\) basically has only one bar, hence \(c=p\).

A song with \(n=2\) has two bars and the expected value of \(c\) can be trivially calculated to be \(2 p\).

Details and assumptions

A gameplay of P-G-P-P-G-G-G-P-G-P-P-P-P-P-G-G-P-G counts as having a chain of 5 (P is "perfect", G is "great").

For simplicity, "greats", "cools", "bads" and "misses" are treated as the same thing. In reality, a "miss" on one bar will forfeit the next bar, hence \(n\) may not be treated as a constant.

Comments

A partial result. If the chain length, \(c\), satisfies \(n>c>\frac{n}{2}\), then the probability of the maximal chain being of length \(c\) is

\(P_n(c)=2p^c(1-p)+(n-(c+1))p^c(1-p)^2\).

Where the first term is due to the chains being right at the start or end, and the second term due to the chain being in the middle. Obviously \(P_n(n)=p^n\).

For \(c \le \frac{n}{2}\), it's harder as previously we didn't have to worry about what was happening in any bars other than those in chain and the one or two bars surrounding it, as the chain would always be the longest chain regardless. It's fairly easy to represent as a sum, but simplifying it would be problematic.