Deciding to put our knowledge of probability to good use, we encounter a slot machine with three independently turning reels, each producing one of the four symbols BAR, BELL, LEMON, or CHERRY with equal probability. The slot machine has the following pay- out scheme for a bet of 1 coin (where “?” denotes that we don’t care what comes up for that wheel):
Compute the expected “payback” percentage of the machine. In other words, for each coin played, what is the expected coin return?
Compute the probability that playing the slot machine once will result in a win.
Estimate the mean and median number of plays you can expect to make until you go broke, if you start with 8 coins. You can run a simulation to estimate this, rather than trying to compute an exact answer.
Ha 2 interpretações para o que ? significa.
Na 1a interpretação ? significa um nao-CHERRY.
Assim as probabilidades de cada um das saidas pagantes é
21*1/64+16*1/64 + 5*1/64 + 3*1/64 + 2*3/64 + 1*9/64 = 60/64 = 0.937
(CHERRY/?/? nao é vitoria)
1/64+1/64+1/64+ 1/64 + 3/64 = 7/64 = 0.109
(CHERRY/?/? conta como vitoria)
1/64+1/64+1/64+ 1/64 + 3/64 + 9/64 = 16/64 = 0.25
media: 117.6 mediana: 14
Na 2a interpretação o primeiro ? significa uma nao-CHERRY na segunda posição mas qualquer coisa na terceira.
Assim as probabilidades de cada um das saidas pagantes é
21*1/64+16*1/64 + 5*1/64 + 3*1/64 + 2*3/64 + 1*12/64 = 63/64 = 0.984
(CHERRY/?/? nao é vitoria)
1/64+1/64+1/64+ 1/64 + 3/64 = 7/64 = 0.109
(CHERRY/?/? conta como vitoria)
1/64+1/64+1/64+ 1/64 + 3/64 + 12/64 = 19/64 = 0.267
media: 518.2 mediana: 15
import statistics
import random
def volta1():
x = random.randint(1, 4)
y = random.randint(1, 4)
z = random.randint(1, 4)
if x==y==z==1:
return 21
if x==y==z==2:
return 16
if x==y==z==3:
return 5
if x==y==z==4:
return 3
if x==y==4:
return 2
if x==4 and y<4 and z<4:
return 1
return 0
def volta2():
x = random.randint(1, 4)
y = random.randint(1, 4)
z = random.randint(1, 4)
if x==y==z==1:
return 21
if x==y==z==2:
return 16
if x==y==z==3:
return 5
if x==y==z==4:
return 3
if x==y==4:
return 2
if x==4:
return 1
return 0
def joga1(n):
c = 0
while n > 0:
c += 1
n -= 1
a = volta1()
n += a
return c
def joga2(n):
c = 0
while n > 0:
c += 1
n -= 1
a = volta2()
n += a
return c
def proc(n=1):
if n == 1:
l = [joga1(8) for _ in range(10000)]
else:
l = [joga2(8) for _ in range(10000)]
print(statistics.mean(l))
print(statistics.median(l))