# problem-9.7

problem-9.7 The first is done quite quickly using the defaults, as the uniform distribution is the null hypothesis.

    > murder = c(53,42,51,45,36,36,65)
    > chisq.test(murder)

            Chi-squared test for given probabilities

    data:  murder
    X-squared = 13.80, df = 6, p-value = 0.03189

The second we must do by hand. First note that if we specify pw, the weekend probability, then pd, the weekday probability, is (1-2pw)/5. There is only 1 degree of freedom. We estimate pw with the average of the weekend counts:

    > n = sum(murder)
    > phatw = (53 + 65)/(2*n)
    > phatd = (1 - 2*phatw)/5
    > e = n * c(phatw, rep(phatd,5), phatw)
    > cs = sum ( (murder - e)^2/e )
    > cs
    [1] 5.077
    > 1 - pchisq(cs,df=1)
    [1] 0.02424

In both cases the p-value is small.