All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Twelve Divisor Trial (Posted on 2010-04-09)
Barbara writes a sequence of integers starting with the number 12. Each subsequent integer she writes is chosen randomly with equal probability from amongst the positive divisors of the previous integer (including the possibility of the integer itself). She keeps writing integers until she writes the integer 1 for the first time, and then she stops.

An example of one such sequence is 12, 6, 6, 3, 3, 3, 1.

What is the expected value of the number of terms in Barbara’s sequence?

 No Solution Yet Submitted by K Sengupta Rating: 3.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 solution | Comment 5 of 7 |

If n is the starting number (where n=12 for the given problem), then the expected number of terms in the sequence, x, can be seen to be:

x = 1 + (c/(c+1))*e + (1/(c+1))*x

where e is the average expectation for the other possible chosen divisors of n, and c is the number of other such divisors, including 1, so that c+1 is the total number of divisors including n itself. The reason for this is:

The 1 accounts for this number in the sequence itself.
The (c/(c+1))*e represents the c/(c+1) probability that a divisor other than n itself will be chosen.
The (1/(c+1))*x represents the 1/(c+1) probability that n itself will be chosen as the divisor, with of course the same expectation again.

Solving for x, this comes out to

x = 1 + e + 1/c

This allows the recursive calculation of the expectation:

DECLARE FUNCTION expct# (n#)
DEFDBL A-Z
PRINT expct(12)
END

FUNCTION expct (n)
IF n = 1 THEN expct = 1: EXIT FUNCTION
tot = 0: ct = 0
FOR i = 1 TO n - 1
IF n MOD i = 0 THEN
tot = tot + expct(i)
ct = ct + 1
END IF
NEXT
e = tot / ct
PRINT n; 1 + e + 1 / ct
expct = 1 + e + 1 / ct
END FUNCTION

It finds the expectation for n=12 to be 4.033333333333333, or 4 + 1/30, or 121/30.

Along the way it reports the expectations for the other divisors of 12:

2: 3
3: 3
4: 3.5
6: 3 + 2/3 = 11/3

with of course the known expected value for 1, as 1.

As a check, 121/30 is indeed 1 more than the average of 1, 3, 3, 3.5, 11/3 and 121/30.

A simulation, likewise checks:

DO
n = 12: ct = 1
DO
PRINT n;
ct = ct + 1
num = 0
FOR i = 1 TO n
IF n MOD i = 0 THEN
num = num + 1
d(num) = i
END IF
NEXT

r = INT(RND(1) * num + 1)
n = d(r)
LOOP UNTIL n = 1
PRINT 1, ct
totCt = totCt + ct: trials = trials + 1
PRINT totCt; trials, totCt / trials
LOOP

which finds, at 55,325 trials, 222,991 total count of terms used in the sequences, for an average of 4.030565.

For n other than 12, here is a table of expected sequence lengths:

`2             33             34             3.55             36             3.6666666666666677             38             3.8333333333333339             3.510            3.66666666666666711            312            4.03333333333333313            314            3.66666666666666715            3.66666666666666716            4.08333333333333417            318            4.03333333333333319            320            4.033333333333333`

For a prime, it's 3; for the square of a prime it's 3.5; for a product of two primes, it's 3+2/3; for the square of a prime multiplied by another prime, it's the current answer, etc.

 Posted by Charlie on 2010-04-09 16:27:06

 Search: Search body:
Forums (0)