rwesson / NEAT

Empirical analysis of ionised nebulae, with uncertainty propagation
GNU General Public License v3.0
9 stars 5 forks source link

Testing for normality of output distributions #25

Closed rwesson closed 11 years ago

rwesson commented 12 years ago

At the moment we output all of the results and leave it up to the user to check whether the data for each output quantity are sensibly represented by a normal-family distribution. We could add a statistical test for this, such as the Shapiro-Wilk test:

http://en.wikipedia.org/wiki/Shapiro-Wilk_test

This would allow us to automatically flag up any non-normal distributions and would remove the need for the user to inspect all the distributions.

rwesson commented 11 years ago

I found a fortran implementation of the Shapiro-Wilk test but it seems that it is too sensitive and rejects almost every distribution as normal or log-normal, even when plotting them shows that they are very close to normal or log-normal. I'm experimenting now with simply calculating the mean and standard deviation of each distribution, and flagging it as normal if the fraction of the distribution within 1, 2 and 3 standard deviations is close to the 68-95-99.7% expected for a normal distribution.

rwesson commented 11 years ago

I've coded in the simple approach as described and it looks like it works pretty well. The code now calculates the mean and standard deviation of the derived values, their logarithm and exponent, and then calculates the fractions of each lying within 1, 2 and 3 sigma of the mean. Inspection of a large number of plots shows that it reliably finds normal, log normal and exp normal distributions, and flags up unusual distributions. I'll leave the issue open for now pending more testing though.

rwesson commented 11 years ago

Having tested this new approach on all our example line lists I'm happy with how it's doing, it reliably flags up weird distributions and inspection of all the output plots shows that it reports the uncertainties correctly in all the non-weird distributions.

rwesson commented 11 years ago

https://github.com/rwesson/NEAT/commit/4f7bcd93d02618fd72dd71def0962d6f3bb57f8e