To test the die class, we will use the Chi-squared test. I have been assured by Dr. Hoggard that this is the proper test to use.
I have found this page to be quite helpful in understanding the test. It includes a very good example. (You will be asked to use this example as a test case later).
In our case, where there are equally likely outcomes, the test is performed by sampling the different categories of the population and seeing how far this sample varies from the expected value the categories. The formula to compute this is:
$$ \chi^2 = \Sigma_{i=1}^{k}\frac{(x_i-m_i)^2}{m_i}$$ Where
Since you are testing a uniform distribution $m_i$ is just trials/sides.
Since you are testing a $n$ sided die, find $x_i$ by rolling the die many times and counting how many times i occurs.
You might want to adjust the index i to better work with 0 indexed vectors.
Once $\chi^2$ is compute, you examine the Chi-Square Probabilities Table, using the degrees of freedom (IE categories -1 ) and the desired significance level to determine if your if you reject or fail to reject the null hypothesis that the sides of the die appear to be uniformly distributed.
Work your way through the example on the first link for proper procedure.
You are to produce a tool which will allow a user to conduct a $\chi^2$ test on a vector of results. Assume that your user will pass you a vector of integers, the results of a sampling and that the user expects these results to be uniform.
In specific, you should support
To support your system, and to show that it works and test its functionality, please provide a test driver that does the following:
Testing the example data Stat = 52.750 X^2(4,0.050) = 9.488 9.488 < 52.750 The result is reject.
Testing a d6 for 1000000 trials. Stat = 2.030 X_(5,0.010) = 15.086 2.030 < 15.086 The result is do not reject.
-g -O2 -Wall -Wextra -Wpedantic -Werror --std=c++20 -Wnon-virtual-dtor -Wold-style-cast -Wunused-parameter -Wuninitialized -Winit-self -Wshadow -Wparentheses -Wdangling-else