test1.add(new Event("gamma", null));
test1.add(new Event("gamma", null));
test1.add(new Event("gamma", null));
es1.addEvents(test1);
es2.addEvents(test1);
assertTrue(new PearsonCorrelationDistance().distance(new EventMap(es1), new EventMap(es2)) == 0);
// test 2 : identical probabilities but different distributions
es1=new EventSet();
es2=new EventSet();
test1 = new Vector<Event>();
Vector<Event> test2 = new Vector<Event>();
test1.add(new Event("A", null));
test1.add(new Event("B", null));
test1.add(new Event("B", null));
test1.add(new Event("C", null));
test1.add(new Event("D", null));
test1.add(new Event("E", null));
test2.add(new Event("A", null));
test2.add(new Event("A", null));
test2.add(new Event("B", null));
test2.add(new Event("B", null));
test2.add(new Event("B", null));
test2.add(new Event("B", null));
test2.add(new Event("C", null));
test2.add(new Event("C", null));
test2.add(new Event("D", null));
test2.add(new Event("D", null));
test2.add(new Event("E", null));
test2.add(new Event("E", null));
es1.addEvents(test1);
es2.addEvents(test2);
double result = new PearsonCorrelationDistance().distance(new EventMap(es1), new EventMap(es2));
//System.out.println(result);
assertTrue(DistanceTestHelper.inRange(result, 0.0, 0.0000000001));
// test 3 : Perfect anticorrelation
es1=new EventSet();
es2=new EventSet();
test1 = new Vector<Event>();
test2 = new Vector<Event>();
test1.add(new Event("A", null));
test1.add(new Event("A", null));
test1.add(new Event("A", null));
test1.add(new Event("B", null));
test1.add(new Event("B", null));
test1.add(new Event("C", null));
test2.add(new Event("C", null));
test2.add(new Event("C", null));
test2.add(new Event("C", null));
test2.add(new Event("B", null));
test2.add(new Event("B", null));
test2.add(new Event("A", null));
es1.addEvents(test1);
es2.addEvents(test2);
result = new PearsonCorrelationDistance().distance(new EventMap(es1), new EventMap(es2));
//System.out.println(result);
assertTrue(DistanceTestHelper.inRange(result, 2.0, 0.0000000001));
// test 4 : non-trivial calculation
es1=new EventSet();
es2=new EventSet();
test1 = new Vector<Event>();
test2 = new Vector<Event>();
test1.add(new Event("A", null));
test1.add(new Event("B", null));
test1.add(new Event("B", null));
test1.add(new Event("C", null));
test1.add(new Event("C", null));
test1.add(new Event("C", null));
test2.add(new Event("A", null));
test2.add(new Event("A", null));
test2.add(new Event("B", null));
test2.add(new Event("B", null));
test2.add(new Event("B", null));
test2.add(new Event("B", null));
test2.add(new Event("B", null));
test2.add(new Event("C", null));
test2.add(new Event("C", null));
test2.add(new Event("C", null));
test2.add(new Event("C", null));
test2.add(new Event("C", null));
test2.add(new Event("C", null));
es1.addEvents(test1);
es2.addEvents(test2);
result = new PearsonCorrelationDistance().distance(new EventMap(es1), new EventMap(es2));
System.out.println(result);
assertTrue(DistanceTestHelper.inRange(result, 1-0.9608, 0.001));
// test 5 : edge case (NaN)
es1=new EventSet();
es2=new EventSet();
test1 = new Vector<Event>();
test2 = new Vector<Event>();
test1.add(new Event("A", null));
test1.add(new Event("B", null));
test1.add(new Event("C", null));
test2.add(new Event("A", null));
test2.add(new Event("B", null));
test2.add(new Event("B", null));
test2.add(new Event("C", null));
test2.add(new Event("C", null));
test2.add(new Event("C", null));
es1.addEvents(test1);
es2.addEvents(test2);
result = new PearsonCorrelationDistance().distance(new EventMap(es1), new EventMap(es2));
System.out.println(result);
assertTrue(DistanceTestHelper.inRange(result, 1.0, 0.001));
// test 6 : edge case (point mass)
es1=new EventSet();
es2=new EventSet();
test1 = new Vector<Event>();
test2 = new Vector<Event>();
test1.add(new Event("A", null));
test1.add(new Event("B", null));
test1.add(new Event("C", null));
test2.add(new Event("A", null));
test2.add(new Event("A", null));
test2.add(new Event("B", null));
test2.add(new Event("B", null));
test2.add(new Event("C", null));
test2.add(new Event("C", null));
es1.addEvents(test1);
es2.addEvents(test2);
result = new PearsonCorrelationDistance().distance(new EventMap(es1), new EventMap(es2));
System.out.println(result);
assertTrue(DistanceTestHelper.inRange(result, 0.0, 0.001));
}