https://youtu.be/iNAUzUEsgs4?t=8691
It was when Tomoe Shirayuki was playing "Yacht" in the "World's Asobi Taizen 51" distribution.
"Mottainai is a choice here"
(The score at that time was 20)
I suddenly wondered, so I did some research.
Yacht is a game of rolling 5 dice to make a hand, and Choice is one of them.
Choice is the sum of all eyes to score.
20 is a choice choice "Yes"
--The average choice is 17.5 --69.48% chance of being less than 20 ――The probability of becoming 21 or more is 22.14%
When throwing a single die with 1 to 6 rolls, consider the average number of rolls.
(* The appearance of the eyes is also certain)
Here, the total number of dice rolls is 21, and each roll can be expected to appear evenly, so the average $ E (x) $ to be calculated is
The $ E (x) $ obtained in this way is called the expected value of $ X
. $ \begin{eqnarray} E(x) &=& x_1p_1 + x_2p_2 + \cdots + x_np_n \ &=& \sum^n_{k=1}x_kp_k\ &&(X = x_1, x_2, ..., x_n)(P=p_1, p_2, ..., p_n) \end{eqnarray} $$ Is required.
Now, if you throw 5 dice at the same time, consider the average of the total number of dice.
At this time, the probabilities for the five dice are independent, so the average can be obtained by simply adding them together.
In other words
When $ X $ is a random variable and $ a $, $ b $ are constants
$ E(aX+b) = aE(x)+b $ Is true, so you can substitute $ E (X) = \ frac {7} {2} $, $ a = 5 $, $ b = 0 $.
So far, I have used mathematics to find the average of choices.
~~ But I've forgotten so much, so I don't know if it's correct ... ~~
From now on, we will use Python to verify that the average we have calculated is correct.
In addition, all the following codes have been confirmed to work on Google Colab.
The strategy is simple.
Roll 5 dice 100 million times and find the total of the eyes. Next, if you find the average, you can find the average to find.
In other words, the law of large numbers.
The code I actually tried is below.
import numpy as np
#Number of trials
N = 1 * 10**8
#Choice execution
x = np.random.randint(1, 6+1, (N, 5))
x = x.sum(axis=1)
#Average calculation
print(np.mean(x))
# 17.4996012
The result was 17.4996012
, which was almost the same as the calculation result.
A brief explanation.
On the 7th line, create random numbers 1 to 6 with size (N, 5).
On line 8, calculate the sum of each of the 5 dice.
It was easier than I expected, so I created a histogram as a bonus.
The code actually used is as follows.
import numpy as np
import matplotlib.pyplot as plt
#Number of trials
N = 1 * 10**8
#Choice execution
x = np.random.randint(1, 6+1, (N, 5))
x = x.sum(axis=1)
#Histogram generation
result = plt.hist(x, bins=26, alpha=0.5, color=(0.43, 0.25, 0.91))
#Auxiliary line
ex = 17.5
min_ylim, max_ylim = plt.ylim()
plt.axvline(17.5, color='k', linestyle='dashed', linewidth=1)
plt.text(ex*1.05, max_ylim*0.9, f"E(x)={ex}")
plt.axvline(20, color='w', linestyle='dashed', linewidth=1)
#label
plt.title('Distribution of Scores in "Choice"')
plt.xlabel("point")
plt.ylabel("frequency")
plt.savefig("fig.png ")
The resulting histogram is below.
In this histogram, the black dotted line is the average and the white dotted line is 20.
From this, you can see at a glance that it is above the average.
Now, what is the probability that your choice score will be less than 20?
If this is known, it will be more persuasive.
So, ask Python to find it approximately.
import numpy as np
#Number of trials
N = 1 * 10**8
#Choice execution
x = np.random.randint(1, 6+1, (N, 5))
x = x.sum(axis=1)
#Frequency calculation
uni, counts = np.unique(x, return_counts=True)
d = {str(u): c for u, c in zip(uni, counts)}
#Probability of less than 20
temp = [v for k, v in d.items() if int(k) < 20]
print(f"{(sum(temp) / N)*100:.02f}%")
# 69.48%
The result was 69.48%, and it was found that about 70% of the total was less than 20.
Also, if you change the direction of the inequality sign on the 15th line of this program, you can easily check the probability of occurrence of 21 or more.
The result is 22.14%. In other words, the probability of getting a higher hand is about 20%.
It feels expensive because it is poisoned by the gacha of social games, but ...
Asobi encyclopedia game fun to analyze
Recommended Posts