// Path: src/main/java/com/jfcorugedo/rserver/exception/DimensionMismatchException.java
// @ResponseStatus(value=HttpStatus.BAD_REQUEST)
// public class DimensionMismatchException extends RuntimeException {
// 
// 	private static final long serialVersionUID = 1L;
// 	
// 	
// 	public DimensionMismatchException(String message) {
// 		super(message);
// 	}
// }


import static java.lang.String.format;
import org.springframework.stereotype.Component;
import com.codahale.metrics.annotation.Timed;
import com.jfcorugedo.rserver.exception.DimensionMismatchException;
package com.jfcorugedo.rserver.generalization.algorithm;




@Component
public class ChiSquareTestImpl implements ChiSquareTest {

	public static final String CHI_TEST = "Chi-Square test";
	
	private org.apache.commons.math3.stat.inference.ChiSquareTest chiTest = new org.apache.commons.math3.stat.inference.ChiSquareTest();
	
	@Override
	@Timed
	public boolean areGeneralizable(long[] observed1, long[] observed2) {
		
		if(observed1.length != observed2.length) {
// Path: src/main/java/com/jfcorugedo/rserver/exception/DimensionMismatchException.java
// @ResponseStatus(value=HttpStatus.BAD_REQUEST)
// public class DimensionMismatchException extends RuntimeException {
// 
// 	private static final long serialVersionUID = 1L;
// 	
// 	
// 	public DimensionMismatchException(String message) {
// 		super(message);
// 	}
// }


// Path: src/main/java/com/jfcorugedo/rserver/generalization/algorithm/ChiSquareTestImpl.java
import static java.lang.String.format;
import org.springframework.stereotype.Component;
import com.codahale.metrics.annotation.Timed;
import com.jfcorugedo.rserver.exception.DimensionMismatchException;

package com.jfcorugedo.rserver.generalization.algorithm;




@Component
public class ChiSquareTestImpl implements ChiSquareTest {

	public static final String CHI_TEST = "Chi-Square test";
	
	private org.apache.commons.math3.stat.inference.ChiSquareTest chiTest = new org.apache.commons.math3.stat.inference.ChiSquareTest();
	
	@Override
	@Timed
	public boolean areGeneralizable(long[] observed1, long[] observed2) {
		
		if(observed1.length != observed2.length) {
			throw new DimensionMismatchException(format("Observed samples have different dimension: %d != %d", observed1.length, observed2.length));