zuloosalsa.blogg.se

Dieroll coding
Dieroll coding






chi2_stat, p_val, dof, ex = stats.chi2_contingency(dice2) print("=Chi2 Stat=") print(chi2_stat) print("\n") print("=Degrees of Freedom=") print(dof) print("\n") print("=P-Value=") print(p_val) print("\n") print("=Contingency Table=") print(ex) Now that I’ve explained what everything means, we can create easier-to-read output code in SciPy. In this particular example, the p-value (the second number in our output: 0.3502) is far 0.01, and thus we have not met the threshold for statistical significance. we reject the null hypothesis) if we get a p-value below our threshold.įor our purposes, we’ll use 0.01 as the threshold. Depending on the test, we are generally looking for a threshold at either 0.05 or 0.01. The p-value is what we use to determine significance (or independence in this case). With the chi-square stat and the degrees of freedoms, we can find the p-value. So we take (6–1) and multiply by (4–1) to get 15 degrees of freedom. Skip down to the third number in the output that’s ‘degrees of freedom.’ This can be calculated by taking the number of rows minus one and multiplying this result by the number of columns minus one. The first value (16.49) is the chi-square statistic. Here is my distribution of rolls, with the four samples denoted by letters ‘a’, ‘b’, ‘c’, and ‘d’. These are smaller samples than we prefer, but I wanted to give us some real data to work with.

dieroll coding

with actual dice), the first 3 samples were 35 rolls each, and the last sample as 45 rolls. I decided to do 4 samples of die rolls manually (i.e. Let’s conduct a few samples to try to ascertain the frequency of each roll. We’d have to estimate the expected frequency through data samples. Let’s pretend for a second we don’t know the expected frequency of die rolls. Sometimes, our ‘expected distribution’ is estimated through data. However, die rolls are an example of a variable where the ‘expected distribution’ is known.

dieroll coding

A chi-square test can help determine whether a die is ‘fair’ or if die-roll generators (such as those used in software) are generating ‘random’ results. If we roll a standard 6-sided die a thousand times, we know that each number should come up approximately 1/6 of the time (i.e. It’s typically used with categorical data such as educational attainment, colors, or gender.ĭice rolls are a great example of data suited for chi-square testing. The chi-square statistical test is used to determine whether there’s a significant difference between an expected distribution and an actual distribution.

dieroll coding

I wanted to know how unusual this distribution was, so I conducted some chi-square tests in Python.īefore we look at those tests, however, I’ll explain chi-square in more detail. After 303 rolls, my opponent’s average roll was 3.855. After 279 rolls, my average roll was 3.254.








Dieroll coding