### Question:
LevenesIndependentSamples { public static boolean testVariances(TransposeDataCollection transposeDataCollection, double aLevel) { int n=0; int k = transposeDataCollection.size(); if(k<=1) { throw new IllegalArgumentException("The collection must contain observations from at least 2 groups."); } Map<Object, Integer> nj = new HashMap<>(); Map<Object, Double> Yjmean = new HashMap<>(); for(Map.Entry<Object, FlatDataCollection> entry : transposeDataCollection.entrySet()) { Object j = entry.getKey(); FlatDataCollection flatDataCollection = entry.getValue(); int tmp = flatDataCollection.size(); if(tmp==0) { throw new IllegalArgumentException("The number of observations in each group but be larger than 0."); } nj.put(j, tmp); n+=tmp; Yjmean.put(j, Descriptives.sum(flatDataCollection)/tmp); } double zdotdot = 0.0; Map<Object, Double> zjdot = new HashMap<>(); Map<Object, Map<Object, Double>> zji = new HashMap<>(); for(Map.Entry<Object, FlatDataCollection> entry : transposeDataCollection.entrySet()) { Object j = entry.getKey(); FlatDataCollection flatDataCollection = entry.getValue(); zji.put(j, new HashMap<>()); double zjdotSum=0.0; int i = 0; Iterator<Double> it = flatDataCollection.iteratorDouble(); while(it.hasNext()) { Double Yji = it.next(); double tmp = Math.abs( Yji - Yjmean.get(j) ); zji.get(j).put(i, tmp); zdotdot += tmp; zjdotSum += tmp; ++i; } zjdot.put(j, zjdotSum/nj.get(j)); } zdotdot/=n; double numerator=0; double denominator=0; for(Map.Entry<Object, FlatDataCollection> entry : transposeDataCollection.entrySet()) { Object j = entry.getKey(); FlatDataCollection flatDataCollection = entry.getValue(); numerator+=nj.get(j)*Math.pow(zjdot.get(j)-zdotdot, 2); int len = flatDataCollection.size(); for(int i = 0; i < len; i++) { denominator+= Math.pow(zji.get(j).get(i)-zjdot.get(j), 2); } } if(denominator==0) { throw new IllegalArgumentException("The values of the input collection are invalid."); } double W = ((n-k)/(k-1.0))*(numerator/denominator); boolean rejectH0 = checkCriticalValue(W, n, k, aLevel); return rejectH0; }  static boolean testVariances(TransposeDataCollection transposeDataCollection, double aLevel);  }### Answer:
@Test public void testTestVariances() { logger.info("testVariances"); TransposeDataCollection transposeDataCollection = new TransposeDataCollection(); transposeDataCollection.put(0, new FlatDataCollection(Arrays.asList(new Object[]{60.8,57.0,65.0,58.6,61.7}))); transposeDataCollection.put(1, new FlatDataCollection(Arrays.asList(new Object[]{68.7,67.7,74.0,66.3,69.8}))); transposeDataCollection.put(2, new FlatDataCollection(Arrays.asList(new Object[]{102.6,103.1,100.2,96.5}))); transposeDataCollection.put(3, new FlatDataCollection(Arrays.asList(new Object[]{87.9,84.2,83.1,85.7,90.3}))); double aLevel = 0.05; boolean expResult = true; boolean result = LevenesIndependentSamples.testVariances(transposeDataCollection, aLevel); assertEquals(expResult, result); }