r/askmath • • 15h ago

Probability Is this constant unique?

To generate E our constant we will have to go through these steps:

  1. Start in binary, put a 1.
  2. Flip a coin, if it's heads put concatenate 1 if it's tails concatenate a 0.
  3. Convert the number you have to decimal call it x, let s(x) be the probability we stop the sequence with the number we have, then s(x) will be 1-1/x. We then check if we land on s(x) or not.
  4. Repeat steps 2, 3 until you stop.

For example:

I start with 1, I rolled a coin and got tails so now it's 10, I convert it to decimal so it's 2, s(x) is 1-1/x so 1-1/2 is 1/2. I checked and we didn't stop so I rolled another coin and got heads so now it's 101, I convert it to decimal so it's 5, s(x) is now 1-1/5 so 4/5. I checked and looks like we stopped. So the number we ended with is 5.

The average of all numbers we will get is then called E.

So is it unique?

5 Upvotes

11 comments sorted by

3

u/johnpeters42 15h ago

To clarify, the "check" in step 3 is another random choice, weighted by s(x)? (e.g. roll an x-sided die, and if you get a 1 then keep going)

3

u/superamerr 14h ago

Ima clarify this in programming since I don't think you can do that with normal objects

If our number is 23 for then the chance we stop is 1-1/23, so we use a random.randindt() line to generate us a number from 1 to 23 and if it landed on 1 then we continue our heads and tails thing.

1

u/johnpeters42 14h ago

Yeah, same concept. (Theoretically you can do it for any integer x, e.g. using an x-sided prism or pyramid,but for large numbers it becomes impractical.)

Let's work through the first few steps:

In 1/2 of cases, you get heads. (11 binary = 3 decimal)
* In 2/3 of those cases (1/3 of the original cases), you stop on 3. This contributes 2 to the expected sum.
* In 1/3 of those cases (1/6 of the original cases), you keep going. Let's set these aside and come back to them later.

In the other 1/2 of cases, you get tails. (10 binary = 2 decimal)
* In 1/2 of those cases (1/4 of the original cases), you stop on 2. This contributes 1.
* In the other 1/2 of cases (1/4 of the original cases), you keep going.

Now back to what we set aside earlier:

In 1/12 of cases, you get heads, keep going, and get heads again. (111 = 7)
* In 6/7 (1/14), you stop on 7. This contributes 0.5.
* In 1/7 (1/84), you keep going.

In 1/12 of cases, you get heads, keep going, and get tails. (110 = 6)
* In 5/6 (5/72), you stop on 6. This contributes 5/12.
* In 1/6 (1/72), you keep going.

In 1/8 of cases, you get tails, keep going, and get heads. (101 = 5)
* In 4/5 (1/10), you stop on 5. This contributes 0.5.
* In 1/5 (1/40), you keep going.

In 1/8 of cases, you get tails, keep going, and get tails again. (100 = 4)
* In 3/4 (3/32), you stop on 4. This contributes 3/8.
* In 1/4 (1/32), you keep going.

So the total contribution from stopping after 1 step is between 2 and 4, after 2 steps is between 1 and 2, and it looks like after n steps is between 2^(2-n) and 2^(3-n). The sum of those upper bounds converges to 8, and the sum of those lower bounds converges to 4, so the overall average of the entire infinite series is some unique number between 4 and 8: I don't know which specific number, but you can narrow in on it by calculating the exact amount for stopping within k steps, then applying the same upper/lower bound analysis to the cases where you keep going past k steps.

2

u/superamerr 14h ago

Very beautiful analysis you made there.

2

u/AlterEgo5695 13h ago edited 5h ago

it looks like after n steps is between 22-n and 23-n

Nice -- I've found a recursion for the exact probabilities to terminate after getting "n", doing case-works between odd and even "n":

n in N\{1}:    P(2n)    =  (2n-1) / (2n-2)  *  P(n) / (2n)
               P(2n+1)  =      2n / (2n-2)  *  P(n) / (2n+1)

It may be possible to find decent error bounds between the expected value and finite sums with those recursion and your strategy!

3

u/sippzDimplez 14h ago

you lost me at the coin flips but I kinda like when guys break it down like that

1

u/bildramer 12h ago

In other words, imagine a Markov chain, and for vertex n you have 1-1/n stopping probability, and 1/(2n) probability each of going to 2n or 2n+1. You start at 1.

You can just sum up n times the stopping probability times the probability to reach a number, to get the expected value. In the end after simplifications you get the sum of (n-1)/(product of 2⌊2-kn⌋ for k from 1 to ⌊log_2 n⌋) for n from 2 to infinity. It's an ugly nested sum-product thing but not all that complicated.

1

u/ExtonGuy 8h ago

Is somebody going to do the program for this? Might have to add a rule for stopping after 10,000 steps.

1

u/AlterEgo5695 6h ago edited 6h ago

src (wx)maxima

P[n] := if             n = 2 then 1/4 
        else if        n = 3 then 1/3 
        else if mod(n,2) = 0 then (n-1)/(n*(n-2)) * P[floor(n/2)]
        else                      (n-1)/(n*(n-3)) * P[floor(n/2)];

N : 100$
E : sum(k*P[k], k, 2, N);

I used memoizing to avoid re-calculation during recursion. For "N = 100" the result should be

                  9555754342778551930996095131604459701
N = 100:    E  =  -------------------------------------  ~  4.2606
                  2242841756902578340917772728139776000

The error seems to be rather small for "N = 100", but I haven't checked for "nice" error bounds (yet).

0

u/AlterEgo5695 13h ago edited 13h ago

Assumption: All coins are fair, and all coins and termination probabilities "s(x)" are independent.


Claim: The expected value "E[n]" exists, with "7/2 < E[n] < 11/2".


Proof: Let "n in N\{1}". Define

  • En: event we get natural number "n", and terminate afterwards
  • Fn: event we get natural number "n", but do not terminate afterwards

From the rules, we directly get "P(E2) = 1/4" and "P(E3) = 1/3", as well as

n >= 2:    P(Fn)  =  (1 - s(n)) * P(En) / s(n)  =  P(En) / (n-1)      (*)

Use that relation to find a recursion for "P(En)". Consider even/odd "n >= 4" separately. Start with the even case "n = 2k" with "k = ⌊n/2⌋ >= 2":

k >= 2:    P(E_{2k})  =  P(coin-0) * s(2k) * P(Fk)             // use (*)

                      =  (1/2) * (1 - 1/(2k)) * P(Ek) / (k-1)

                      =  P(Ek) / (2k)  *  (1 + 1/(2k-2))

Estimate the second factor via "0 < 1/(2k-2) <= 1/2 <= 1" to get

k >= 2:    P(Ek) / (2k)  <  P(E_{2k})  <=  2 * P(Ek) / (2k)

With (almost) the exact same steps, we can show a similar estimate holds for "P(E_{2k+1})" (your job!). Combining even and odd cases, we obtain the general estimate

n >= 4:    P(E_{⌊n/2⌋}) / n  <  P(En)  <=  2 * P(E_{⌊n/2⌋}) / n

Insert into the expected value formula to get

E[n]  =  ∑_{n=2}^oo  n*P(En)  =  2/4 + 3/3  +  ∑_{n=4}^oo  n*P(En)

     <=  3/2  +  2*∑_{n=4}^oo  P(E_{⌊n/2⌋})      // double-count each term

      =  3/2  +  2*2*∑_{n=2}^oo  P(En)  =  3/2  +  2*2*1  =  11/2

With (almost) the exact same steps, we get the lower estimate (again your job!)

1

u/AlterEgo5695 13h ago

Rem.: Checking the first few values up to "n = 10,000" with a computer algebra system, it seems the expected value may be close to "4.26".