@Test public void testXbarVariance() { logger.info("xbarVariance"); TransposeDataCollection sampleDataCollection = generateSampleDataCollection(); int populationM = 4; double Nbar = 10.0; double expResult = 2.0; double result = ClusterSampling.xbarVariance(sampleDataCollection, populationM, Nbar); assertEquals(expResult, result, Constants.DOUBLE_ACCURACY_HIGH); }
public static double xbarVariance(TransposeDataCollection sampleDataCollection, int populationM, double Nbar) { double xbarVariance = 0.0; int sampleM = sampleDataCollection.size(); double mean = mean(sampleDataCollection); for(Map.Entry<Object, FlatDataCollection> entry : sampleDataCollection.entrySet()) { double sum = 0.0; Iterator<Double> it = entry.getValue().iteratorDouble(); while(it.hasNext()) { sum+=(it.next() - mean); } xbarVariance+= sum*sum/(sampleM-1); } xbarVariance *= (populationM-sampleM)/(populationM*sampleM*Nbar*Nbar); return xbarVariance; }
ClusterSampling { public static double xbarVariance(TransposeDataCollection sampleDataCollection, int populationM, double Nbar) { double xbarVariance = 0.0; int sampleM = sampleDataCollection.size(); double mean = mean(sampleDataCollection); for(Map.Entry<Object, FlatDataCollection> entry : sampleDataCollection.entrySet()) { double sum = 0.0; Iterator<Double> it = entry.getValue().iteratorDouble(); while(it.hasNext()) { sum+=(it.next() - mean); } xbarVariance+= sum*sum/(sampleM-1); } xbarVariance *= (populationM-sampleM)/(populationM*sampleM*Nbar*Nbar); return xbarVariance; } }
ClusterSampling { public static double xbarVariance(TransposeDataCollection sampleDataCollection, int populationM, double Nbar) { double xbarVariance = 0.0; int sampleM = sampleDataCollection.size(); double mean = mean(sampleDataCollection); for(Map.Entry<Object, FlatDataCollection> entry : sampleDataCollection.entrySet()) { double sum = 0.0; Iterator<Double> it = entry.getValue().iteratorDouble(); while(it.hasNext()) { sum+=(it.next() - mean); } xbarVariance+= sum*sum/(sampleM-1); } xbarVariance *= (populationM-sampleM)/(populationM*sampleM*Nbar*Nbar); return xbarVariance; }  }
ClusterSampling { public static double xbarVariance(TransposeDataCollection sampleDataCollection, int populationM, double Nbar) { double xbarVariance = 0.0; int sampleM = sampleDataCollection.size(); double mean = mean(sampleDataCollection); for(Map.Entry<Object, FlatDataCollection> entry : sampleDataCollection.entrySet()) { double sum = 0.0; Iterator<Double> it = entry.getValue().iteratorDouble(); while(it.hasNext()) { sum+=(it.next() - mean); } xbarVariance+= sum*sum/(sampleM-1); } xbarVariance *= (populationM-sampleM)/(populationM*sampleM*Nbar*Nbar); return xbarVariance; }  static double nBar(TransposeDataList clusterIdList); static TransposeDataCollection randomSampling(TransposeDataList clusterIdList, int sampleM); static double mean(TransposeDataCollection sampleDataCollection); static double xbarVariance(TransposeDataCollection sampleDataCollection, int populationM, double Nbar); static double xbarStd(TransposeDataCollection sampleDataCollection, int populationM, double Nbar); }
ClusterSampling { public static double xbarVariance(TransposeDataCollection sampleDataCollection, int populationM, double Nbar) { double xbarVariance = 0.0; int sampleM = sampleDataCollection.size(); double mean = mean(sampleDataCollection); for(Map.Entry<Object, FlatDataCollection> entry : sampleDataCollection.entrySet()) { double sum = 0.0; Iterator<Double> it = entry.getValue().iteratorDouble(); while(it.hasNext()) { sum+=(it.next() - mean); } xbarVariance+= sum*sum/(sampleM-1); } xbarVariance *= (populationM-sampleM)/(populationM*sampleM*Nbar*Nbar); return xbarVariance; }  static double nBar(TransposeDataList clusterIdList); static TransposeDataCollection randomSampling(TransposeDataList clusterIdList, int sampleM); static double mean(TransposeDataCollection sampleDataCollection); static double xbarVariance(TransposeDataCollection sampleDataCollection, int populationM, double Nbar); static double xbarStd(TransposeDataCollection sampleDataCollection, int populationM, double Nbar);  }