### Question:
CensoredDescriptives { public static double meanVariance(AssociativeArray2D survivalFunction) { double meanVariance=0; int m=0; int n=0; for(Map.Entry<Object, AssociativeArray> entry : survivalFunction.entrySet()) { AssociativeArray row = entry.getValue(); Number mi = (Number)row.get("mi"); n+=mi.intValue(); if(row.get("Sti")==null) { m+=mi.intValue(); } } for(Map.Entry<Object, AssociativeArray> entry : survivalFunction.entrySet()) { AssociativeArray row = entry.getValue(); if(row.get("Sti")==null) { continue; } Number mi = (Number)row.get("mi"); Number r = (Number)row.get("r"); double Ar = ar(survivalFunction,r.intValue()); if(n-r.intValue()>0) { meanVariance+=mi.intValue()*(Ar*Ar)/((n-r.intValue())*(n-r.intValue()+1.0)); } } meanVariance*=m/(m-1.0); return meanVariance; }  static AssociativeArray2D survivalFunction(FlatDataCollection flatDataCollection); static double median(AssociativeArray2D survivalFunction); static double mean(AssociativeArray2D survivalFunction); static double meanVariance(AssociativeArray2D survivalFunction); static double meanStd(AssociativeArray2D survivalFunction); static final String CENSORED_NUMBER_POSTFIX; }### Answer:
@Test public void testMeanVariance() { logger.info("meanVariance"); AssociativeArray2D survivalFunction = CensoredDescriptives.survivalFunction(generateFlatDataCollection()); double expResult = 2.7874113520408; double result = CensoredDescriptives.meanVariance(survivalFunction); assertEquals(expResult, result, Constants.DOUBLE_ACCURACY_HIGH); }