# How to test my data against an specific normal distribution?

I need to test my data to see if it follows a normal distribution with specific mean and std like N~(mu, std) I know that this can be done by Kolmogorov-Smirnov test which has a function in both MATLAB and R but the default for these function is standard normal and I do not know how should I specify my mu and std in the function. If you can help me in any of these two softwares I will be thankful.

ks.test in R allows one to adjust the mean and sd of the distribution to be tested against. e.g.

x <- rnorm(1000, 4, 10)
ks.test(x, "pnorm", mean = 4, sd = 10)


In R, you can just use the function ks.test with the following arguments:

ks.test(your_data, "pnorm", mean=test_mu, sd=test_sd)


Where your_data is your data vector, test_mu is the specific mean of the theoretical normal distribution and test_sd its standard deviation.

To inspect your data graphically, you can use the function qqPlot from the car package. Just use it with the following arguments:

qqPlot(your_data, "norm", mean=test_mu, sd=test_sd)


This produces a Q-Q plot with a comparison line and a 95% point-wise confidence envelope (as default).

Hope that helps.

So don't use the default! As already noted, R lets you specify the population mean and standard deviation.

Here is how to do it in MATLAB or anything else that doesn't give you the option to specify:

Standardize your variable by the population parameters: $z_i = \frac{x_i-\mu_0}{\sigma_0}$

... and then test against standard normal.

(However, if those $\mu$ and $\sigma$ values come from a sample... don't do this!)

• +1 for being the first to point out the important point that $\mu$ and $\sigma$ should not be estimates.
– whuber
Apr 15, 2013 at 4:14