1   package baseCode.math;
2   
3   import java.util.HashSet;
4   import java.util.Set;
5   
6   import junit.framework.TestCase;
7   import baseCode.math.ROC;
8   import baseCode.math.Rank;
9   import cern.colt.list.DoubleArrayList;
10  import cern.colt.list.IntArrayList;
11  
12  /***
13   * <hr>
14   * <p>
15   * Copyright (c) 2004 Columbia University
16   * 
17   * @author pavlidis
18   * @version $Id: TestROC.java,v 1.1 2005/03/17 13:58:42 pavlidis Exp $
19   */
20  public class TestROC extends TestCase {
21  
22     Set ranksOfPositives;
23  
24     /*
25      * @see TestCase#setUp()
26      */
27     protected void setUp() throws Exception {
28        super.setUp();
29        DoubleArrayList m = new DoubleArrayList( new double[] {} );
30  
31        IntArrayList ranks = Rank.rankTransform( m );
32  
33        // set up the ranks of the opsitives
34        ranksOfPositives = new HashSet();
35        ranksOfPositives.add( new Integer( 0 ) );
36        ranksOfPositives.add( new Integer( 3 ) );
37        ranksOfPositives.add( new Integer( 5 ) );
38     }
39  
40     public void testAroc() {
41        double actualReturn = ROC.aroc( 10, ranksOfPositives );
42        double expectedReturn = ( 21.0 - 5.0 ) / 21.0;
43        assertEquals( "return value", expectedReturn, actualReturn, 0.00001 );
44     }
45     
46     public void testArocN() {
47        double actualReturn = ROC.aroc( 10, ranksOfPositives, 2 );
48        double expectedReturn = 2.0/6.0;
49        assertEquals( "return value", expectedReturn, actualReturn, 0.00001 );
50     }
51  
52  }