# Parameter estimation for normal distribution in Java

Given a set of data (~5000 values) I'd like to draw random samples from the same distribution as the original data. The problem is there is no way to know for sure what distribution the original data comes from.

It makes sense to use normal distribution in my case, although I'd like to be able to motivate that decision, and of course I also need to estimate the $(\mu,\sigma)$ pair.

Any idea on how to accomplish this, preferably within Java environment. I have been using Apache Commons Math and recently stumbled upon Colt library. I was hoping to get it done without bothering with MATLAB and R.

• you should mention java environment in the title of your question this will maximize the chance to get an answer. Also is there a tag "java" ? – robin girard Feb 9 '11 at 17:09
• @robin Yes it is. – user88 Feb 9 '11 at 17:14
• @mbq: cheers! I wasnt too sure about tagging/mentioning java too much; my interest is primarily if it can be done relatively easily, then a Java implementation. But this works as well. – posdef Feb 9 '11 at 17:20
• @posdef, if it is normal, then simulation is easy, just calculate mean and standard deviation. For motivation you will need to test whether the sample is normal. – mpiktas Feb 9 '11 at 20:01
• @posdef, answers require better quality than comments, this is why I commented. As for commercial use, try google to find non comercial. This seems free. In worst case scenario you will need to reimplement this test, or another normality test. I suggest asking here or on stackoverflow , which of the normality tests is easiest to implement. – mpiktas Feb 10 '11 at 10:48

Otherwise, it seems that the org.apache.commons.math.stat.descriptive.moment package has a Mean and StandardDeviation class which use the correct formulas. These should give you $\mu$ and $\sigma$, respectively.