I have an unfair die whose sides are known to have the following probabilities:{.02,.04,.08,.12,.24,.5}
Assign the numbers {1,2,3,4,5,6} to these sides so the expected roll is the same as for a fair die.
Can you solve this without brute force?
If the weights are in sequence
.02 .04 .08 .12 .24 .5
the numbers can be assigned in any of these orders:
134562
165324
246153
251643
325614
452163
526134
531624
612453
643215
or, looked at the other way around, for faces 1, 2, 3, 4, 5, 6:
0.02 0.50 0.04 0.08 0.12 0.24
0.02 0.24 0.12 0.50 0.08 0.04
0.12 0.02 0.50 0.04 0.24 0.08
0.08 0.02 0.50 0.24 0.04 0.12
0.24 0.04 0.02 0.50 0.08 0.12
0.12 0.08 0.50 0.02 0.04 0.24
0.12 0.04 0.24 0.50 0.02 0.08
0.08 0.24 0.04 0.50 0.02 0.12
0.04 0.08 0.50 0.12 0.24 0.02
0.24 0.12 0.08 0.04 0.50 0.02
the first list from:
DECLARE SUB permute (a$)
CLS
DATA .02,.04,.08,.12,.24,.5
FOR i = 1 TO 6
READ vl(i)
PRINT vl(i);
NEXT
PRINT
a$ = "123456": h$ = a$
DO
t = 0
FOR i = 1 TO 6
t = t + vl(i) * VAL(MID$(a$, i, 1))
NEXT
IF t = 3.5 THEN
PRINT a$
ct = ct + 1
END IF
permute a$
LOOP UNTIL a$ = h$
PRINT ct
and the latter list from
DECLARE SUB permute (a$)
CLS
DATA .02,.04,.08,.12,.24,.5
FOR i = 1 TO 6
READ vl(i)
PRINT vl(i);
NEXT
PRINT
a$ = "123456": h$ = a$
DO
t = 0
FOR i = 1 TO 6
t = t + vl(i) * VAL(MID$(a$, i, 1))
NEXT
IF t = 3.5 THEN
FOR i = 1 TO 6
ix = INSTR(a$, LTRIM$(STR$(i)))
PRINT USING " #.##"; vl(ix);
NEXT
PRINT
ct = ct + 1
END IF
permute a$
LOOP UNTIL a$ = h$
PRINT ct
|
Posted by Charlie
on 2006-04-28 15:01:51 |