I am testing pseudo-random number generators and need to perform a chi-squared test. However, I've encountered some difficulties.
Let's take the following example: I have generated 100 numbers, ranging from 1 to 10.
The distribution is as follows:
From what I was able to understand, next I should calculate D.
$$D = d1 + d2 + d3 + … + d10.$$
$di =$ square of the difference between the expected value and the observer value, everything over the expected value
$$d1 = ((8 – 10)^2)/10 = 4/10$$
$$d2 = ((12 – 10)^2)/10 = 4/10$$
$$d10 = ((7 – 10)^2)/10 = 9/10$$
Adding them up results in 84/10 or 8.4.
The next step is comparing this to $X^2$.
That is $X^2[1-alpha,k-1]$. It is clear that $k=10$. But what value should I use for $alpha$? And how to I know the value of $X^2$ after I decide what $alpha$ I am going to use?
It feels that I am close but I just can't figure it out.
You are looking for the $1-alpha$ quantile of the $chi^2$ distribution with $k-1$ degrees of freedom, the critical value of your test. That is, the value that your test statistic needs to exceed in order for you to reject the null hypothesis of your test.
So the choice of $alpha$ relates to the significance level at which you test. Typically, $alpha=.05$, $0.1$ or $0.01$.
These critical values can be computed in for example
> qchisq(.95,9)  16.91898