문제

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

  }
}
도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top