3

I'm trying to run a Smirnov test in Java, to see if two sets of data come from the same distribution. However, I am getting a "cannot find symbol" error. How to do I "construct" a Smirnov Test so as not get this error?

import java.io.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.*;
import jsc.independentsamples.SmirnovTest;
import jsc.*;

public class test{

  public static void main(String[] arg) throws Exception {

    double[] array1 = {1.1,2.2,3.3};
    double[] array2 = {1.2,2.3,3.4};

    SmirnovTest test = SmirnovTest(array1, array2);

    test.getSP();

  }
}
Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
kjm
  • 113
  • 2
  • 2
  • 10
  • 1
    First rule of asking for help: "Post the entire actual error message, using copy/paste. Do not paraphrase". Second rule: "When the message refers to a line number in your code, identify the line in question". – Jim Garrison Aug 07 '13 at 23:23

2 Answers2

1

Two possible issues, not mutually exclusive and one of them is definitely an issue.

  1. Your classpath is wrong. Make sure that jsc.jar is in your classpath.
  2. You need to invoke the constructor for SmirnovTest by using an instance creation expression which requires the use of the keyword new.

That is

SmirnovTest test = new SmirnovTest(array1, array2);
                   ^^^

The second is definitely an issue with your code. Without using the keyword new, javac will interpret

SmirnovTest test = SmirnovTest(array1, array2);

as a method invocation and look for a method named SmirnovTest in the class test. You don't have it, so it will die with a cannot find symbol error, whether or not you have successfully imported jsc.jar.

Please fix the second if not also the first of these issues.

jason
  • 236,483
  • 35
  • 423
  • 525
0

Thanks for the help. Here's the final code:

import java.util.ArrayList;

import jsc.independentsamples.SmirnovTest;



public class test{



 public static void main(String[] arg) throws Exception {


double[] array1 = {1.1,2.2,3.3};
double[] array2 = {1.2,2.3,3.4};


SmirnovTest test = new SmirnovTest(array1, array2);

System.out.println(test.getSP());




 }

}

The output is: 1.0

kjm
  • 113
  • 2
  • 2
  • 10