Package com.jgaap.util

Examples of com.jgaap.util.EventMap


   
   
   
   
    //Same event set
    double Result = new CrossEntropyDivergence().divergence(new EventMap(known1), new EventMap(known1));
   
    //System.out.println(s);
   
   
    assertTrue(DistanceTestHelper.inRange(Result, 2.3978952, 0.0000001));
   
    //different event sets
   
    test1  = new Vector<Event>();
    Vector<Event> test2 = new Vector<Event>();
   
    test1.add(new Event("alpha", null));
    test1.add(new Event("beta", null));
    known1 = new EventSet();
    known1.addEvents(test1);
   
    test2.add(new Event("alpha", null));
    test2.add(new Event("alpha", null));
    test2.add(new Event("alpha", null));
    test2.add(new Event("beta", null));
    known2 = new EventSet();
    known2.addEvents(test2);
   
    Result = new CrossEntropyDivergence().divergence(new EventMap(known1), new EventMap(known2));
   
    //System.out.println(Result);
   
    assertTrue(DistanceTestHelper.inRange(Result, 0.836988, 0.000001));
   
    //Reversed Event Sets
   
    Result = new CrossEntropyDivergence().divergence(new EventMap(known2), new EventMap(known1));
   
    //System.out.println(Result);
   
    assertTrue(DistanceTestHelper.inRange(Result, 0.693147, 0.000001));
   
    //Test with Smoothing
    test2 = new Vector<Event>();
   
    test2.add(new Event("alpha", null));
    test2.add(new Event("alpha", null));
    test2.add(new Event("beta", null));
    test2.add(new Event("gamma", null));
    known2 = new EventSet();
    known2.addEvents(test2);
 
   
    //System.out.println("Start Here");
   
    Result = new CrossEntropyDivergence().divergence(new EventMap(known2), new EventMap(known1));
   
    //System.out.println(Result);
   
    assertTrue(DistanceTestHelper.inRange(Result, 0.5198603854199589, 0.000001));
   
    //revese the event sets
   
    Result = new CrossEntropyDivergence().divergence(new EventMap(known1), new EventMap(known2));
   
    //System.out.println(Result);
   
    assertTrue(DistanceTestHelper.inRange(Result, 1.0397207, 0.0000001));
  }
View Full Code Here


    test1.add(new Event("eight", null));
    test1.add(new Event("nine", null));
    test1.add(new Event("ten", null));     
    set1.addEvents(test1);
    set2.addEvents(test1);
    double result = new ChordDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, Math.sqrt(1.8), 0.0000000001));
   
   
    set2 = new EventSet();
    Vector<Event> test2 = new Vector<Event>();
    test2.add(new Event("1", null));
    test2.add(new Event("2", null));
    test2.add(new Event("3", null));
    test2.add(new Event("4", null));
    test2.add(new Event("5", null));
    test2.add(new Event("6", null));
    test2.add(new Event("7", null));
    test2.add(new Event("8", null));
    test2.add(new Event("9", null));
    test2.add(new Event("10", null));
    set2.addEvents(test2);
    result = new ChordDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, Math.sqrt(2.0), 0.0000000001));
  }
View Full Code Here

    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));


  }
View Full Code Here

    test1.add(new Event("eight", null));
    test1.add(new Event("nine", null));
    test1.add(new Event("ten", null));     
    set1.addEvents(test1);
    set2.addEvents(test1);
    double result = new SoergleDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, 0.0, 0.0000000001));
   
   
    set2 = new EventSet();
    Vector<Event> test2 = new Vector<Event>();
    test2.add(new Event("1", null));
    test2.add(new Event("2", null));
    test2.add(new Event("3", null));
    test2.add(new Event("4", null));
    test2.add(new Event("5", null));
    test2.add(new Event("6", null));
    test2.add(new Event("7", null));
    test2.add(new Event("8", null));
    test2.add(new Event("9", null));
    test2.add(new Event("10", null));
    set2.addEvents(test2);
    result = new SoergleDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, 1.0, 0.0000000001));
  }
View Full Code Here

    test1.add(new Event("eight", null));
    test1.add(new Event("nine", null));
    test1.add(new Event("ten", null));     
    set1.addEvents(test1);
    set2.addEvents(test1);
    double result = new AngularSeparationDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, 0.90, 0.0000000001));
   
   
    set2 = new EventSet();
    Vector<Event> test2 = new Vector<Event>();
    test2.add(new Event("1", null));
    test2.add(new Event("2", null));
    test2.add(new Event("3", null));
    test2.add(new Event("4", null));
    test2.add(new Event("5", null));
    test2.add(new Event("6", null));
    test2.add(new Event("7", null));
    test2.add(new Event("8", null));
    test2.add(new Event("9", null));
    test2.add(new Event("10", null));
    set2.addEvents(test2);
    result = new AngularSeparationDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, 1.0, 0.0000000001));
  }
View Full Code Here

    test1.add(new Event("eight", null));
    test1.add(new Event("nine", null));
    test1.add(new Event("ten", null));     
    set1.addEvents(test1);
    set2.addEvents(test1);
    double result = new HistogramIntersectionDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, 0.0, 0.0000000001));
   
   
    set2 = new EventSet();
    Vector<Event> test2 = new Vector<Event>();
    test2.add(new Event("1", null));
    test2.add(new Event("2", null));
    test2.add(new Event("3", null));
    test2.add(new Event("4", null));
    test2.add(new Event("5", null));
    test2.add(new Event("6", null));
    test2.add(new Event("7", null));
    test2.add(new Event("8", null));
    test2.add(new Event("9", null));
    test2.add(new Event("10", null));
    set2.addEvents(test2);
    result = new HistogramIntersectionDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, 1.0, 0.0000000001));
  }
View Full Code Here

    test1.add(new Event("dog", null));
    test1.add(new Event(".", null));
    es1.addEvents(test1);
    es2.addEvents(test1);

    assertTrue(new KullbackLeiblerDivergence().distance(new EventMap(es1), new EventMap(es2)) == 0.00);

    /* test 2 -- different hist, same distribution (still 0.0) */
    /* use prior data and add another copy */
    es2.addEvents(test1);
    assertTrue(new KullbackLeiblerDivergence().distance(new EventMap(es1), new EventMap(es2)) == 0.00);

    /* test 3 -- different distributions */

    test1 = new Vector<Event>(); // no need to re-create test1
    Vector<Event> test2 = new Vector<Event>();

    /* es1 gets a 50/50 split between alpha and beta */
    test1.add(new Event("alpha", null));
    test1.add(new Event("beta", null));
    es1 = new EventSet();
    es1.addEvents(test1);

    /* es2 gets a 75/25 split between alpha and beta */
    test2.add(new Event("alpha", null));
    test2.add(new Event("alpha", null));
    test2.add(new Event("alpha", null));
    test2.add(new Event("beta", null));
    es2 = new EventSet();
    es2.addEvents(test2);
    double result = new KullbackLeiblerDivergence().distance(new EventMap(es1), new EventMap(es2));
    System.out.println(result);
    assertTrue(DistanceTestHelper.inRange(result, 0.1438410, 0.00001));

    /* test 4 -- reversed distributions */
    result = new KullbackLeiblerDivergence().distance(new EventMap(es2), new EventMap(es1));
    assertTrue(DistanceTestHelper.inRange(result, 0.13081203594, 0.00001));
    /* test 5 -- distributions with 0 (need rounding) */
    /* use same 50/50 es1 */
    /*
     * value of nonce-term gamma should be 0.25 (half of 0.5, because each
     * element appears once
     */

    /* es2 gets a 50/25/25 split between alpha, beta,gamma */
    test2 = new Vector<Event>();
    test2.add(new Event("alpha", null));
    test2.add(new Event("alpha", null));
    test2.add(new Event("beta", null));
    test2.add(new Event("gamma", null));

    es2 = new EventSet();
    es2.addEvents(test2);
    System.out.println("Start here");
    result = new KullbackLeiblerDivergence().distance(new EventMap(es1), new EventMap(es2));
    System.out.println(result);
    assertTrue(DistanceTestHelper.inRange(result, 0.346574, 0.00001));

  }
View Full Code Here

    test1.add(new Event("eight", null));
    test1.add(new Event("nine", null));
    test1.add(new Event("ten", null));     
    set1.addEvents(test1);
    set2.addEvents(test1);
    double result = new MatusitaDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, 0.0, 0.0000000001));
   
   
    set2 = new EventSet();
    Vector<Event> test2 = new Vector<Event>();
    test2.add(new Event("1", null));
    test2.add(new Event("2", null));
    test2.add(new Event("3", null));
    test2.add(new Event("4", null));
    test2.add(new Event("5", null));
    test2.add(new Event("6", null));
    test2.add(new Event("7", null));
    test2.add(new Event("8", null));
    test2.add(new Event("9", null));
    test2.add(new Event("10", null));
    set2.addEvents(test2);
    result = new MatusitaDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, Math.sqrt(2), 0.0000000001));
  }
View Full Code Here

    test1.add(new Event("eight", null));
    test1.add(new Event("nine", null));
    test1.add(new Event("ten", null));     
    set1.addEvents(test1);
    set2.addEvents(test1);
    double result = new WaveHedgesDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, 0.0, 0.0000000001));
   
   
    set2 = new EventSet();
    Vector<Event> test2 = new Vector<Event>();
    test2.add(new Event("1", null));
    test2.add(new Event("2", null));
    test2.add(new Event("3", null));
    test2.add(new Event("4", null));
    test2.add(new Event("5", null));
    test2.add(new Event("6", null));
    test2.add(new Event("7", null));
    test2.add(new Event("8", null));
    test2.add(new Event("9", null));
    test2.add(new Event("10", null));
    set2.addEvents(test2);
    result = new WaveHedgesDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, 20.0, 0.0000000001));
  }
View Full Code Here

    test1.add(new Event("lazy", null));
    test1.add(new Event("dog", null));
    test1.add(new Event(".", null));
    es1.addEvents(test1);
    es2.addEvents(test1);
    double result = new CosineDistance().distance(new EventMap(es1), new EventMap(es2));
    assertTrue(DistanceTestHelper.inRange(result, 0.0, 0.0000000001));

    Vector<Event> test2 = new Vector<Event>();
    test2.add(new Event("3", null));
    test2.add(new Event("..", null));
    test2.add(new Event("1", null));
    test2.add(new Event("4", null));
    test2.add(new Event("11", null));
    test2.add(new Event("5", null));
    test2.add(new Event("2", null));
    test2.add(new Event("6", null));
    test2.add(new Event("55", null));
    test2.add(new Event("33", null));
    es2 = new EventSet();
    es2.addEvents(test2);
    result = new CosineDistance().distance(new EventMap(es1), new EventMap(es2));
    assertTrue(DistanceTestHelper.inRange(result, 1.0, 0.0000000001));

    es1 = new EventSet();
    es2 = new EventSet();
    test1=new Vector<Event>();
    test1.add( new Event("alpha", null));
    test2=new Vector<Event>();
    test2.add( new Event("alpha", null));
    test2.add( new Event("alpha", null));
    es1.addEvents(test1);
    es2.addEvents(test2);
    result = new CosineDistance().distance(new EventMap(es1), new EventMap(es2));
    assertTrue(DistanceTestHelper.inRange(result, 0.0, 0.0000000001));

    es1=new EventSet();
    es2 =new EventSet();
    test1=new Vector<Event>();
    test1.add( new Event("alpha", null));
    test2=new Vector<Event>();
    test2.add( new Event("alpha", null));
    test2.add( new Event("beta", null));
    es1.addEvents(test1);
    es2.addEvents(test2);
    result = new CosineDistance().distance(new EventMap(es1), new EventMap(es2));
    assertTrue(DistanceTestHelper.inRange(result, 0.29289321881345, 0.0000000001));
  }
View Full Code Here

TOP

Related Classes of com.jgaap.util.EventMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.