Java tutorial
//package com.java2s; import android.util.SparseArray; import java.util.*; import static java.lang.Math.*; public class Main { /** * @param SStandard data from user account * @param SAuth data from recognition mode * @return true if sequence converge */ public static boolean fisherCheck(List<Double> SStandard, List<Double> SAuth) { double Fp; int standardSize = SStandard.size(); int authSize = SAuth.size(); /** * use temporary list link to arraylist object */ if (standardSize < authSize) { List<Double> temp = new ArrayList<Double>(standardSize); for (int i = 0; i < standardSize; i++) { temp.add(SAuth.get(i)); } SAuth = temp; authSize = standardSize; } else if (standardSize > authSize) { List<Double> temp = new ArrayList<Double>(authSize); for (int i = 0; i < authSize; i++) { temp.add(SStandard.get(i)); } SStandard = temp; standardSize = authSize; } double theoreticalF = getTheoreticalFisher(authSize); for (int i = 0; i < standardSize; i++) { double Smin = min(SStandard.get(i), SAuth.get(i)); double Smax = max(SStandard.get(i), SAuth.get(i)); Fp = Smax / Smin; if (Fp > theoreticalF) { return false; } } return true; } /** * @return theoretical fishers table * table realized by SparseArray, in connection with better performance than HashMap */ private static Double getTheoreticalFisher(int n) { SparseArray<Double> theorFisher = new SparseArray<Double>(); theorFisher.put(1, 12.706); theorFisher.put(2, 4.3027); theorFisher.put(3, 3.1825); theorFisher.put(4, 2.7764); theorFisher.put(5, 2.5706); theorFisher.put(6, 2.4469); theorFisher.put(7, 2.3646); theorFisher.put(8, 2.3060); theorFisher.put(9, 2.2622); theorFisher.put(10, 2.2281); theorFisher.put(11, 2.2010); theorFisher.put(12, 2.1788); theorFisher.put(13, 2.1604); theorFisher.put(14, 2.1448); theorFisher.put(15, 2.1315); theorFisher.put(16, 2.1199); theorFisher.put(17, 2.1098); theorFisher.put(18, 2.1009); theorFisher.put(19, 2.0930); theorFisher.put(20, 2.0860); theorFisher.put(30, 2.0423); theorFisher.put(40, 2.0211); theorFisher.put(60, 2.0003); if (n >= 60) { return theorFisher.get(60); } else if (n >= 40) { return theorFisher.get(40); } else if (n >= 30) { return theorFisher.get(30); } else if (n >= 20) { return theorFisher.get(20); } else { return theorFisher.get(n); } } }