### Question:
StratifiedSampling { public static double mean(TransposeDataCollection sampleDataCollection, AssociativeArray populationNh) { double populationN = Descriptives.sum(populationNh.toFlatDataCollection()); if(populationN<=0) { throw new IllegalArgumentException("The populationN parameter must be positive."); } double mean = 0.0; for(Map.Entry<Object, FlatDataCollection> entry : sampleDataCollection.entrySet()) { Object strata = entry.getKey(); Integer strataPopulation = ((Number)populationNh.get(strata)).intValue(); if(strataPopulation==null) { throw new IllegalArgumentException("Invalid strata population size."); } mean += strataPopulation*SimpleRandomSampling.mean(entry.getValue())/populationN; } return mean; }  static TransposeDataCollection weightedProbabilitySampling(AssociativeArray2D strataFrequencyTable, AssociativeArray nh, boolean withReplacement); static TransposeDataCollection randomSampling(TransposeDataList strataIdList, AssociativeArray nh, boolean withReplacement); static double mean(TransposeDataCollection sampleDataCollection, AssociativeArray populationNh); static double variance(TransposeDataCollection sampleDataCollection, AssociativeArray populationNh); static double std(TransposeDataCollection sampleDataCollection, AssociativeArray populationNh); static double xbarVariance(TransposeDataCollection sampleDataCollection, AssociativeArray nh, AssociativeArray populationNh); static double xbarStd(TransposeDataCollection sampleDataCollection, AssociativeArray nh, AssociativeArray populationNh); static AssociativeArray optimumSampleSize(int n, AssociativeArray populationNh, AssociativeArray populationStdh);  }### Answer:
@Test public void testMean() { logger.info("mean"); TransposeDataCollection sampleDataCollection = generateSampleDataCollection(); AssociativeArray populationNh = generatePopulationNh(); double expResult = 6.4888888888889; double result = StratifiedSampling.mean(sampleDataCollection, populationNh); assertEquals(expResult, result, Constants.DOUBLE_ACCURACY_HIGH); }