package deepDriver.dl.aml.math.test;

import deepDriver.dl.aml.math.MathUtil;

public class TestNormalDistribution {
	
	public static void testNormal() {
		double u = 1.0;
		double sigma = 2.0;
		int l = 30;
		double min = u - (double)l;
		for (int i = 0; i < 2 * l; i++) {
			double x = (double)i + min;
			double y = MathUtil.normalDistribution(x, u, sigma);
			System.out.println(x+","+y);
		}
	}
	
	public static void testSampleFromArr() {
		double [] x = {0.8626521816691124};
//		double [] x = {0.8626521816691124,0.9389977714730531,-2.9731836972125434,1.8138805863511873,2.583093674902962,-2.057188775066848,1.9924196067432955,-1.85085156721928,2.2460358918408065,0.9148141078124681,1.5104920872692649,0.4134647794552233,1.5148271041957173,3.457290245643133,-2.7515052893501384,-1.245183854764587,-3.0934229371904163,1.0932231379698116,0.8744005077426618,-0.8629412870216093,-1.1583611269981482,-0.8750311807339397,2.2884210121291453,0.36065179942047365,-1.083593453800468,3.0255181636383046,-2.3664309500445944,-0.32268238861423626,-0.871738062270424,3.17181369554333,2.1608763836310843,0.6850165834664015,1.6900054611690578,0.2033400305314661,1.2390735282615388,0.36319359324646605,-0.26493226946390536,0.6917718218252489,1.5058743489243067,-1.086445599579445,2.9186413908593796,2.5188348303283306,1.8530437393455,-0.3270442926437944,-2.4998605736136383,-0.7113042164787657,-0.05526659242183918,2.216266722038135,4.332406342638823,0.7962382143197075,1.9550432671804678,1.1162777480487769,2.081429957188849,1.5112802449082015,3.0882387806165887,-0.44951116512082656,4.68233627415788,1.008414045729598,-3.062790127136995,2.4233023460836964,0.612149654564794,0.34296086917506763,3.4417391147321243,2.2521069769503494,-1.6809784222989066,0.8890561962154031,-0.5761080882556566,1.6102799609850802,1.6322015237481082,3.4305797887707925,2.3353191438615823,1.2125761644350241,2.528604453541142,2.2555077402926074,3.6997922928783815,-1.773015065448348,0.1309856542564809,-0.17798828302797354,4.036239520521793,-2.6474931803433996,-2.225438789228652,0.003880509598264581,1.9835248167656516,-0.48508434050108384,7.484428176613985,0.885484343069848,2.81628655045143,1.8275985579826504,3.660124420568742,2.661521399712676,-1.1532754237155913,3.6201724133163644,1.613951112211934,-0.09352092673080215,3.0399476413664708,3.0439969532068876,1.537592385870429,-1.792969612260464,1.6939380039011134,4.4358343662812825,};
		int l = 5000;
		int [] a = new int[20];
		for (int i = 0; i < l; i++) {
			double y = MathUtil.sampleNormalDistribution(x, false);
			int j = (int) Math.rint(y);
			a[j + 10]++;
		}	
		for (int i = 0; i < a.length; i++) {
			System.out.println((i - 10) +",  "+a[i]);
		}
	}
	
	public static void testSnd() {
		double u = 1.0;
		double sigma = 2.0;
		int l = 100;
		int [] a = new int[20];
		for (int i = 0; i <  l; i++) {
			double x = MathUtil.sampleNormalDistribution(u, sigma, a.length/2, false);
			int j = (int) Math.rint(x);
			a[j + 10]++;
			System.out.print(x+",");
		}
//		for (int i = 0; i < a.length; i++) {
//			System.out.println((i - 10) +","+a[i]);
//		}
	}
	
	public static void main(String[] args) {
		
//		testNormal();
//		testSnd();
		testSampleFromArr();
		
	}

}
