package dhbw.ka.mwi.businesshorizon2.methods.timeseries;

import static org.junit.Assert.*;

import org.junit.Test;

public class TestAutokovarianz {

	@Test
	public void testBerechneAutokovarianz() throws Exception {
		
		//int n = 4;
		AnalysisTimeseries at = new AnalysisTimeseries();
		double [] testZeitreihe = {8,12,10,14,12,16};
		testZeitreihe = at.reduceTide(testZeitreihe);
		
		for (int i =0; i<testZeitreihe.length; i++) {
			System.out.println("Zeitreihe["+i+"]: " + testZeitreihe[i]);
		}
				
		int i_TestLag = 0;
		System.out.println("Lag: " + i_TestLag);
		
		//double db_TestAutocovariance = 0;
		//System.out.println("Autovarianz: " + db_TestAutocovariance);
		
		AnalysisTimeseries atTest = new AnalysisTimeseries();	
		for(int i = 0; i<testZeitreihe.length;i++){
			i_TestLag = i;
			System.out.println("Autokovarianz mit Lag "+ i_TestLag+": " + atTest.calculateAutocovariance(testZeitreihe, i_TestLag));
			System.out.println("Autokorrelation mit Lag "+ i_TestLag+": " + atTest.calculateAutocorrelation(testZeitreihe, i_TestLag));
		}
				
	}

}

@@ -64,15 +64,8 @@
 ort 
-static 
 org.
@@ -80,13 +80,9 @@
 sert
-.*;%0D%0A
+;
 %0D%0Aim
@@ -105,16 +105,18 @@
 est;%0D%0A%0D%0A
+%0D%0A
 public c
@@ -387,16 +387,36 @@
 );%0D%0A%09%09%0D%0A
+//%09%09Debug output%0D%0A//
 %09%09for (i
@@ -456,16 +456,18 @@
 i++) %7B%0D%0A
+//
 %09%09%09Syste
@@ -519,24 +519,26 @@
 reihe%5Bi%5D);%0D%0A
+//
 %09%09%7D%0D%0A%09%09%09%09%0D%0A%09
@@ -564,97 +564,32 @@
 %0D%0A%09%09
-System.out.println(%22Lag: %22 + i_TestLag);%0D%0A%09%09%0D%0A%09%09//double db_TestAutocovariance = 0;%0D%0A%09%09//
+%0D%0A//%09%09Debug Output%0D%0A//%09%09
 Syst
@@ -608,46 +608,26 @@
 ln(%22
-Autovarianz
+Lag
 : %22 + 
-db
+i
 _Test
-Autocovariance
+Lag
 );%0D%0A
@@ -688,16 +688,40 @@
 es();%09%0D%0A
+%09%09%0D%0A//%09%09Debug Output%0D%0A//
 %09%09for(in
@@ -759,16 +759,18 @@
 ;i++)%7B%0D%0A
+//
 %09%09%09i_Tes
@@ -780,16 +780,18 @@
 g = i;%0D%0A
+//
 %09%09%09Syste
@@ -907,16 +907,110 @@
 Lag));%0D%0A
+//%09%09%09System.out.println(%22Varianz der Zeitreihe: %22+ atTest.berechneVarianz(testZeitreihe));%0D%0A//
 %09%09%09Syste
@@ -1133,22 +1133,533 @@
 );%0D%0A
+//
 %09%09%7D%0D%0A%09%09
+%0D%0A%09%09Assert.assertEquals(3.5, atTest.calculateAutocovariance(testZeitreihe, 0),0.2);%0D%0A%09%09Assert.assertEquals(-0.31, atTest.calculateAutocovariance(testZeitreihe, 1),0.2);%0D%0A%09%09Assert.assertEquals(1.96, atTest.calculateAutocovariance(testZeitreihe, 2),0.2);%0D%0A%09%09Assert.assertEquals(-1.38, atTest.calculateAutocovariance(testZeitreihe, 3),0.2);%0D%0A%09%09Assert.assertEquals(1.03, atTest.calculateAutocovariance(testZeitreihe, 4),0.2);%0D%0A%09%09Assert.assertEquals(0, atTest.calculateAutocovariance(testZeitreihe, 5),0.2);%0D%0A%0D%0A
 %09%09%0D%0A%09%7D%0D
+%0A%09%0D
 %0A%0D%0A%7D

change TestAutokovarianz