I'm working on a climate simulation program that takes monthly averages and generates daily readings that are assumed to be normally distributed. The following program creates 10 sets of 100,000 random deviates with mean 10 and SD 5. It then applies a t test (results below) to ensure that the generated numbers are good enough. As the results show, they aren't. I'm wondering a) I am doing something wrong or b) is there something wrong with the stats routines?

Thanks,

wjr

package usda.weru.cligen2;

import org.apache.commons.math.MathException;

/**
*
* @author wjr
*/
public class TestNormal {
static org.apache.commons.math.distribution.NormalDistributionImpl nd = new org.apache.commons.math.distribution.NormalDistributionImpl(10, 5);

   public static void main(String[] args) {
       double[] arry = new double[100000];
       java.util.Random ran = new java.util.Random(1l);
for (int jdx = 0; jdx < 10; jdx++) {
           for (int idx = 0; idx < arry.length; idx++) {
               try {
arry[idx] = nd.inverseCumulativeProbability(ran.nextDouble());
               } catch (MathException ex) {
                   ex.printStackTrace();
               }
           }
           try {
System.out.println("ttest " + org.apache.commons.math.stat.inference.TestUtils.tTest(10,arry));
           } catch (IllegalArgumentException ex) {
               ex.printStackTrace();
           } catch (MathException ex) {
               ex.printStackTrace();
           }
       }
   }
}

Output:


run-single:
ttest 0.3433300114960922
ttest 0.1431930575825282
ttest 0.12336027805916228
ttest 0.49478850669361796
ttest 0.9216887341410063
ttest 0.9937228334312525
ttest 0.13669784550400177
ttest 0.9646134537758599
ttest 0.9965741269090211
ttest 0.03815948891784959
BUILD SUCCESSFUL (total time: 20 seconds)



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to