package cs437.som.neighborhood;

import org.testng.annotations.Test;

import static org.testng.Assert.assertTrue;

public class GaussianNeighborhoodWidthFunctionTest {
    private static final double MAXIMUM_DIFFERENCE = 0.0000000000000001;
    static final int ITERATIONS = 1000;
    static final double STANDARD_DEVIATION = 100.0;

    @Test
    public void testNeighborhoodWidth() throws Exception {
        GaussianNeighborhoodWidthFunction gnwf =
                new GaussianNeighborhoodWidthFunction(STANDARD_DEVIATION);
        gnwf.setExpectedIterations(ITERATIONS);

        // always decreasing
        double last = gnwf.neighborhoodWidth(0);
        for (int i = 1; i < ITERATIONS; i++) {
            double current = gnwf.neighborhoodWidth(i);
            assertTrue(current <= last, "Must consistently decrease.");
            last = current;
        }

        // todo need a good way to verify a Gaussian
    }
}

@@ -63,16 +63,62 @@
 .Test;%0A%0A
+import static org.testng.Assert.assertEquals;%0A
 import s
@@ -153,16 +153,16 @@
 rtTrue;%0A
-
 %0Apublic 
@@ -371,16 +371,383 @@
 = 100.0;
+%0A    private static final int%5B%5D SAMPLES = %7B0, 1, 10, 100, 200, 500, 1000%7D;%0A    private static final double%5B%5D SAMPLE_RESULTS =%0A            %7B0.00398942, 0.00398922, 0.00396953, 0.00241971, 0.00053991,%0A                    1.48672e-8, 7.6946e-25%7D;%0A    private static final double%5B%5D SAMPLE_ACCURACY =%0A            %7B1.0e-8, 1.0e-8, 1.0e-8, 1.0e-8, 1.0e-8, 1.0e-13, 1.0e-29%7D;
 %0A%0A    @T
@@ -1289,49 +1289,228 @@
  // 
-todo need a good way to verify a Gaussian
+Verify the function fits known samples%0A        for (int j = 0; j %3C SAMPLES.length; j++) %7B%0A            assertEquals(gnwf.neighborhoodWidth(SAMPLES%5Bj%5D), SAMPLE_RESULTS%5Bj%5D,%0A                    SAMPLE_ACCURACY%5Bj%5D);%0A        %7D
 %0A   

Add sample-based testing to GaussianNeighborhoodWidthFunctionTest.