Re: Calculating dice game odds



On Jun 25, 5:48 am, "eval3" <e...@xxxxxxxxxxxxxxxx> wrote:
"Ray Vickson" wrote:
On Jun 24, 3:39 am, "eval3" wrote:
"Ray Vickson" wrote:
On Jun 23, 11:02 pm, Ray Vickson wrote:
On Jun 23, 10:11 pm, "eval3" wrote:

b) What is the probability for a player to have his/her
4 numbers correct in any order (for example 2,5,1,3 in any order)
in a series of N=7 dice throws (draws)?

Hint: if all you care about is occurrence 2,5,1,3 in any order, can't
you just find the probabilities of the different ordered strings 1235,
2135, etc., and add them up? How would you find these individual
ordered string probabilities?

I have just a result of someone else: p=0.4501
Do you get this result too?

No. I get p = 595/2916 =~= .2040466392.

What is the formula to calculate these odds?

You can express the answer using a summation over multinomial
probabilities, or you can get it using a recursion. Hint: let p(i,n) =
probability of getting each of the 'i' desired numbers (at least once)
in 'n' remaining n tosses. You have p(i,n) = (i/6)*p(i-1,n-1) + (1-i/
6)*p(i,n-1). Start from p(1,1) = 1/6 and p(i,1) = 0 if i >= 2. Iterate
until you get p(4,7), which is the answer you want.

If you think about it, you must either eliminate the index 0 and be
very careful about boundary values, or else you must take p(0,n) = 1
for n = 0, 1, 2, ... and p(i,0) = 0 for i = 1, 2, 3, ... . Then the
recursion p(i,n) = (i/6)*p(i-1,n-1) + (1-i/6)*p(i,n-1) for n = 1,
2, ... and i = 1, 2, ... will work. Try it by hand to see! Perhaps
your "return 0" statement is the problem. Anyway, here it is done in
Maple 9.5:

for n from 0 to 7 do v[0,n]:=1: end do: n:='n':
for i from 1 to 6 do v[i,0]:=0: end do: i:='i':
for i from 1 to 6 do for n from 1 to 7 do v[i,n]:=(i/6)*v[i-1,n-1] + (1-i/6)*v[i,n-1]: end do:
end do:
i:='i': n:='n':
v[4,7];

595
----
2916

If you still don't believe it, here is another argument: part (b) has
some aspects of the so-called "coupon collector's" problem, although
it is also a bit different. Think of it this way: say we want to get
each of the numbers '1', '2', '3' and '4' at least once, in any order.
The time T1 (number of tosses) to get a first number is geometrically
distributed with success probability p1 = 4/6 (because getting any of
the 4 numbers will be OK); then the time T2 to get a second number is
geometrically distributed with success probability p2 = 3/6 (because
any of the three remaining numbers will be OK). The time T3 to get a
third is geometric with success probability p3 = 2/6, and the time T4
to get the remaining 4th number is geometric with success probability
p4 = 1/6. The total time to get all four numbers is T = T1 + T2 + T3 +
T4, which is a sum of independent *but not identically-distributed*
geometric random variables. We want the probability that {T <= 7}
(time to get all 4 numbers is <= 7}. Now, you can use numerical
convolutions of the four distributions P{Ti = n} = pi*(1-pi)^(n-1), n
= 1, 2, 3, ..., for i = 1,2,3,4. We only need to keep n up to 7.
Alternately, we can get the moment-generating function G(z) of T,
because it is just a product of the 4 separate mgf's of T1, T2, T3 and
T4: G = G1*G2*G3*G4. (The mgf of a geometric random variable with
success probability p is p*z/[1-(1-p)*z].) Expanding G in a series, we
have that P{T = n} is the coefficient of z^n, so we want the sum of
the coefficients for n <= 7. Again, here it is in Maple 9.5:

Generating function approach:
Gp:=p*z/(1-(1-p)*z);

p z
Gp := -------------
1 - (1 - p) z

G1:=subs({p=4/6},Gp):
G2:=subs({p=3/6},Gp):
G3:=subs({p=2/6},Gp):
G4:=subs({p=1/6},Gp):
G:=G1*G2*G3*G4;

4
z
G := ------------------------------------------
/ 2 z\ / 5 z\
54 (1 - z/3) (1 - z/2) |1 - ---| |1 - ---|
\ 3 / \ 6 /

series(G,z=0,10);

4 5 125 6 455 7 1967 8 5929 9
1/54 z + 7/162 z + ---- z + ---- z + ----- z + ----- z +
1944 5832 23328 69984

10
O(z )

g10:=convert(%,polynom);

4 5 125 6 455 7 1967 8 5929 9
g10 := 1/54 z + 7/162 z + ---- z + ---- z + ----- z + ----- z
1944 5832 23328 69984

prob:=add(coeff(g10,z,i),i=4..7);

595
prob := ----
2916


Hi Ray,
what's wrong in my implementation below of your above recursive function?
Pseudocode follows:

p(i, n)
{
if (i < 1 OR n < 1) return 0; <===== maybe this is the problem.

R.G. Vickson



if (i == 1 AND n == 1) return 1/6;
if (i >= 2 AND n >= 1) return 0;
return (i/6) * p(i-1,n-1) + (1-i/6) * p(i,n-1);

}

I cannot reproduce your .2040466392.
Can you please give an example how to get this value?
I tried this pseudocode:

N = 7;
k = 6;
m = 4;
pCum = 0, px = 0;
i = 0, j = 0;
for (i = 1 to m step 1)
for (j = 1 to N step 1)
{
px = p(i, j);
pCum = pCum + px;
print i, j, px, pCum;
}

But it gives this:

1 1 0.166667 0.166667
1 2 0.138889 0.305556
1 3 0.115741 0.421296
1 4 0.096451 0.517747 <------
1 5 0.080376 0.598122
1 6 0.066980 0.665102
1 7 0.055816 0.720918

It's obviously wrong as it should sum up to 1.0.
It seems to me that here the 0-case is missing; ie. maybe one has to start with 0 ?

.



Relevant Pages

  • No result is likely - Part IV (conclusion)
    ... "When do the dice know that it's time to give the player the win so ... To sum up: ... to be able to calculate the probabilities of different outcomes, ...
    (rec.gambling.craps)
  • Re: A modest proposal (was Calculus XOR Probability)
    ... Tony Orlow wrote: ... over an infinite set of possibilities is not well handled by the ... classical notion that all individual probabilities sum to 1, ... the individual probabilities are considered equal to zero. ...
    (sci.math)
  • Re: Calculating dice game odds
    ... you just find the probabilities of the different ordered strings 1235, ... what's wrong in my implementation below of your above recursive function? ... I tried this pseudocode: ... pCum = pCum + px; ...
    (sci.math)
  • Re: Beginners question
    ... When you take PROD and SUM you ... silently assume that the truth values behave as probabilities of independent events. ... suggested to abandon fuzzy and do it statistically. ...
    (comp.ai.fuzzy)
  • Re: Confirmation of Shannons Mistake about Perfect Secrecy of One-time-pad
    ... you cannot use the distribution on K to determine ... c not fixed so the distribution of K is uniform ... Computing the conditional probabilities. ... (sum of probabilities of all events where M=0 and C=0)/ ...
    (sci.math)