Our teacher has posted the following task: We have 100 random numbers in our disposal that come from Exp(1) and the task is to perform the chi square test in order to check if the numbers come indeed from Exp(1)(he basically wants us to get more confortable with the r environment,so we have to look for everything by ourselves*). Although i know how to perform the test and answer about the null hypothesis based on the pvalue, i have no clue on how to separate the interval from zero to infinity(in the r environment)We need that in order to calculate the probabilities. I also have in mind that we need all our expected values to be bigger than 5. Any ideas?

*we are amateurs who started using r one week ago,we are familiar with basic stuff only.


I usually start by splitting things into deciles. Basically, if you take the 0 -- 0.1, 0.1 -- 0.2, ..., 0.9 -- 1.0 quantiles as your intervals, then you expect 10 of the draws to be in each of the intervals.

The quantiles come from the CDF of the Exp(1) distribution, which you can find on wikipedia, so then all you have to do is create a vector (suppose we call it "Observed") where each element is the observed counts in each interval.

Then just

sum((Observed - 10)^2/10)

gives you the $\chi^2$ value, and all that's left is for you to get the p-value, for which you'll need the degrees of freedom and the appropriate function call. Hopefully that's enough to get you started!

  • $\begingroup$ i ll check it, thanks man $\endgroup$
    – al.al.
    Apr 11 '19 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.