0
$\begingroup$

I don't have much background in statistics, and one of the exercises in my programming course asks for the following:

  1. Generate a sample of normally distributed data using rejection sampling and Metropolis (I did this).
  2. Check, using appropriate statistical tests, if the results agree with a normal distribution.

My background in practical statistics is fairly limited, so I'm not sure what is meant by appropriate statistical tests. I'm guessing there are tests designed especially for checking if a sample is from a normal distribution with a given $\mu, \sigma$ (I'm generating the sample with fixed values of the parameters).

Also, I would like to try randomizing the $\mu, \sigma$ values, and then use some test for checking whether the data are from any normal distribution (I'm guessing there's a test for that, and that it's different from the previous one).

Which tests should I use and how to use them?

$\endgroup$
1
$\begingroup$

Perhaps generate samples form a normal distribution with $\mu$, $\sigma$ and perform a Kolmogorov–Smirnov test to check if the distributions are the same.

What programming language are you using? In r here is an example

 x=rnorm(1000,2,3)
 y=rnorm(1000,4,5)
 ks.test(x,y)

 x=rnorm(1000,2,3)
 y=rnorm(1000,2,3)
 ks.test(x,y)

The P-value will tell you whether to reject or not

and to do a normality test, you can

a) standardise your results and do a Q-Q plot against a standard normal b) using R again

 library(fBasics)
 x=rnorm(1000,2,3)
 y=rgamma(1000,2,3)
 shapiroTest(x)
 shapiroTest(y)

This is using the Shapiro–Wilk test and again decide using the P-value

$\endgroup$
  • $\begingroup$ Oh, I definitely need to learn R at some point! But atm I'm stuck with C++, so I need to implement the statistical tests by myself. I guess that's the point of the exercise. $\endgroup$ – Spine Feast Dec 2 '14 at 17:07
  • 1
    $\begingroup$ right, so programming these yourself can be a pain but Pearson's chi-squared test should be a 'relatively' easy option. Also Numerical recipes should have some of these programmed ready for you to use $\endgroup$ – Sam Bhatt Dec 2 '14 at 17:14

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.