package de.lmu.ifi.dbs.elki.test.math;

import static org.junit.Assert.*;

import org.junit.Test;

import de.lmu.ifi.dbs.elki.varianceanalysis.weightfunctions.*;

public class TestWeightFunctions {
  /**
   * Just a 'boring' value test for completeness.
   */
  @Test
  public void testGetWeight() {
    WeightFunction[] wf = {new ConstantWeight(), new ErfcWeight(), new ErfcStddevWeight(),
        new GaussWeight(), new GaussStddevWeight(), new LinearWeight(), new ExponentialWeight()};
    double[] at0 = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
    double[] at01 = {1.0, 0.7995676697105694, 0.920344325445942, 0.9772372209558107,
        0.9950124791926823, 0.91, 0.7943282347242815};
    double[] at09 = {1.0, 0.10981854852784237, 0.368120250693519, 0.15488166189124816,
        0.6669768108584744, 0.18999999999999995, 0.12589254117941673};
    
    assert(wf.length == at0.length);
    assert(wf.length == at01.length);
    assert(wf.length == at09.length);
    
    for (int i=0; i < wf.length; i++) {
      double val0 = wf[i].getWeight(0, 1, 1);
      double val01 = wf[i].getWeight(0.1, 1, 1);
      double val09 = wf[i].getWeight(0.9, 1, 1);
      assertTrue(val0 == at0[i]);
      assertTrue(val01 == at01[i]);
      assertTrue(val09 == at09[i]);
    }
  }

}

@@ -514,35 +514,50 @@
  1.0, 1.0, 1.0, 
-1.0
+0.3989422804014327
 , 1.0, 1.0%7D;%0A   
@@ -585,24 +585,24 @@
 , 0.
-7995676697105694
+8693490686884612
 , 0.
@@ -652,24 +652,24 @@
   0.
-9950124791926823
+3969525474770118
 , 0.
@@ -726,24 +726,24 @@
  0.1
-0981854852784237
+3877499454059491
 , 0.
@@ -794,24 +794,24 @@
   0.
-6669768108584744
+2660852498987548
 , 0.
@@ -851,16 +851,177 @@
 41673%7D;%0A
+    double%5B%5D at10 = %7B1.0, 0.10000000000000016, 0.31731050786291415, 0.10000000000000002,%0A        0.24197072451914337, 0.09999999999999998, 0.10000000000000002%7D;%0A
     %0A   
@@ -1126,24 +1126,62 @@
 09.length);%0A
+    assert(wf.length == at10.length);%0A
     %0A    for
@@ -1367,105 +1367,438 @@
     
-assertTrue(val0 == at0%5Bi%5D);%0A      assertTrue(val01 == at01%5Bi%5D);%0A      assertTrue(val09 == at09%5Bi%5D
+double val10 = wf%5Bi%5D.getWeight(1.0, 1, 1);%0A      assertEquals(wf%5Bi%5D.getClass().getSimpleName()+%22 at 0.0%22, at0%5Bi%5D, val0, Double.MIN_VALUE);%0A      assertEquals(wf%5Bi%5D.getClass().getSimpleName()+%22 at 0.1%22, at01%5Bi%5D, val01, Double.MIN_VALUE);%0A      assertEquals(wf%5Bi%5D.getClass().getSimpleName()+%22 at 0.9%22, at09%5Bi%5D, val09, Double.MIN_VALUE);%0A      assertEquals(wf%5Bi%5D.getClass().getSimpleName()+%22 at 1.0%22, at10%5Bi%5D, val10, Double.MIN_VALUE
 );%0A 

Update values (Gauss and Erfc scaling were updated), add new series for 1.0