[PYTHON] Detecting Hancho's Cee-lo Injustice-Statistics Part 2-

Introduction

Do you know ** Otsuki Team Leader **? That's right, he is the villainous team leader who appears in the underground forced labor facility of the cartoon Kaiji. Even if you don't know, I've heard Kaiji's quote when he drank draft beer ** "It's cold to kinkin ... !!" "It's criminal ... it's too good ..." ** Isn't there? ** The person who gave the draft beer to Kaiji. ** ** In fact, it is very popular among this Otsuki team leader and some fans, and up to 9 volumes of spin-off manga have already been sold. I read it, but it's criminally interesting. This time, I will try to test the binomial distribution by statistically detecting the fraud of Cee-lo that Mr. Otsuki was doing in the underground forced labor facility.

image.png

Cee-loline rules (underground ver)

The gambling that was held in the underground forced labor facility is Cee-loline (abbreviated as Cee-lo). The rules are very simple ** Throw three dice into the bowl and the strength of the role will determine the outcome. ** Participants sit in a circle as shown in the figure below, first the parent swings, then the children swing counterclockwise, and Pelica (1 yen in the currency of the underground labor facility = 1 yen in the currency of the underground labor facility) depending on which is stronger, the parent's eyes vs. the children's eyes 10 Pelica) come and go. The image is as shown below.

image.png

** The strength of the role is as shown in the table below. ** ** image.png

Basically, the one with big eyes is stronger, and the doublet and shigoro are the roles above it. By the way, if you want to copy the same parts in parallel positions (up, down, left, right) in large numbers with PowerPoint as shown in the above table, it is very easy to use Ctrl + Shift + mouse drag.

Hancho's cheating dice

Now, let's take a look at the Ikasama dice used by Hanchou. ** The cheating dice have only 4 to 6 rolls, but the same numbers are placed on the opposite side, so just looking at the rolled dice does not make you notice it. It has become like. ** **

image.png

** In addition, Hancho has taken the following two measures to prevent the exposure of squid. ** **

  1. If you use it all the time, you'll get caught, so you only use it twice in one game.
  2. When using it as a parent number, let the child shake it to eliminate the discomfort.

Test with dice roll

I would like to consider how to detect Ikasama of Team Leader Otsuki using estimated statistics. The story of Poincare and the bakery, a famous anecdote of inference statistics, is introduced in this article. To put it simply, the test of inference statistics is a method of making a hypothesis about the population in advance and checking whether the obtained sample is within a realistic range. ** **

It is assumed that playing with 10 people and turning the parents for one lap is "one game". The dice roll was implemented using Python's random function.

The results (total dice rolls) of keeping records every day for 10 days are shown below. I roll three dice at a time, but for the sake of simplicity, I think of them all independently. You can see that there are a lot of 4 to 6 somehow.

image.png

With a normal dice, the probability of rolling 4 to 6 should be 1/2, so the null hypothesis is that "when you roll this dice 300 times, you will get 4 to 6". It's half 150 times. " ** **

The number of successes when n trials with a success probability of p follow the ** binomial distribution **. The ** expected value of the number of successes in the binomial distribution (the number of times 4 to 6 appear) is E (X) = np **, and the ** variance is V (x) = np (1-p) **. Then, by standardizing the binomial distribution with the following formula, it approximates the standard normal distribution N (0, 1). Since the rejection rate is 1% as a two-sided test, the null hypothesis is correct if z in the following equation falls within -2.68 to 2.68.


\begin{align}
z=\frac{X-np}{\sqrt{np(1-p)} \\}
\end{align}

** Now, what about the results? ** **

image.png

** Since the observed value did not enter the rejected area, the conclusion is that the observed value is realistic even with a normal dice. ** **

Tested by combining the three sides of the dice that you can see

As a next consideration, ** cheating dice take only 4 to 6 values, so consider testing "three-sided dice that you can see x the random variables of three dice". .. ** * Depending on the angle, it may not be possible to see three sides, but I will proceed for the time being. The combination of dice that you can see is one of the following eight patterns if it is a normal dice structure. (1,2,3)、(1,2,4)、(1,3,5)、(1,4,5)、(2,3,6)、(2,4,6)、(3,5,6)、(4,5,6) image.png

** And with a normal dice, the probability that the appearance will be (4,5,6) is 1/8. ** **

** The figure below is the observed value. It's the same random variable as before, but the bias is more pronounced. ** **

image.png

** Similarly, the expected value of the binomial distribution was tested. What about the result? ** **

image.png

** Since the observed values are far off, the null hypothesis was rejected and it was concluded that Hanchou was cheating. ** **

code



import math
import random
import numpy as np
import matplotlib.pyplot as plt

#The visible eye pattern of the dice that you can see
look_pattern = {1:[1,2,3],
                2:[1,2,4],
                3:[1,3,5],
                4:[1,4,5],
                5:[2,3,6],
                6:[2,4,6],
                7:[3,5,6],
                8:[4,5,6]}

counts_single = [0 for _ in range(7)]
counts_multi = [0 for _ in range(9)]

#for 10 days
for day in range(10):
    #Normal
    for normal in range(8):
        #3 dice
        for dice_num in range(3):
            #How to see the dice
            result = random.randint(1,8)
            counts_multi[result] += 1
            #Dice roll
            result = look_pattern[result][random.randint(0,2)]
            counts_single[result] += 1
    #Ikasama
    for ikasama in range(2):
        #3 dice
        for dice_num in range(3):
            #How to see the dice
            result = 8
            counts_multi[result] += 1
            #Dice roll
            result = look_pattern[result][random.randint(0,2)]
            counts_single[result] += 1
#Dice roll
plt.scatter(range(len(counts_single[1:])),counts_single[1:])
plt.plot(range(len(counts_single[1:])),counts_single[1:])
plt.ylim(0,100)
plt.show()

#The dice that you can see
plt.scatter(range(len(counts_multi[1:])),counts_multi[1:])
plt.plot(range(len(counts_multi[1:])),counts_multi[1:])
plt.ylim(0,100)
plt.show()

#Test
n = sum(counts_multi)
p = 1/8
X = counts_multi[8]
z = (X - n*p) / (n*p*(1-p))**0.5
ok_Xs = np.linspace(-2.68, 2.68, num = 50)

f = lambda x: (math.exp(-x**2/2)) / math.sqrt(2*math.pi)
plt.plot([i*0.1-5 for i in range(100)],[f(i*0.1-5) for i in range(100)], color = "black")
plt.fill_between(ok_Xs, np.zeros_like(ok_Xs),list(map(f, ok_Xs)),facecolor='darkred',alpha=0.5)

plt.plot([z,z],[0,1], color = "blue")
plt.ylim(0,0.4)
plt.xlim(-4,10)

plt.show()

reference

  1. Consideration of Kaiji Underground Cee-lo Team Leader's Ikasama Hole and Countermeasures
  2. Underground Cee-loline Rule

At the end

Thank you for reading to the end.

Recommended Posts

Detecting Hancho's Cee-lo Injustice-Statistics Part 2-