Homework 2, Testing the Die Class.

Short Description:

Write a program that will test the Die class.

Goals

When you finish this homework, you should have:

Formal Description

While it is probably unnecessary, I would like to see if my Die class is "fair". Given it is driven by a uniform distribution, which has been tested, it probably is, however it is still good to test things.

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:

Useful Files

Additional notes

Required Files

A single tar or zip file containing the source code and makefile for this program.

Submission

Submit the assignment to the D2L folder Homework 2 by the due date.