### Question:
CensoredDescriptives { public static double median(AssociativeArray2D survivalFunction) { Double ApointTi = null; Double BpointTi = null; int n = survivalFunction.size(); if(n==0) { throw new IllegalArgumentException("The provided collection can't be empty."); } for(Map.Entry<Object, AssociativeArray> entry : survivalFunction.entrySet()) { Object ti = entry.getKey(); AssociativeArray row = entry.getValue(); Double Sti = row.getDouble("Sti"); if(Sti==null) { continue; } Double point = Double.valueOf(ti.toString()); if(Math.abs(Sti-0.5) < 0.0000001) { return point; } else if(Sti>0.5) { ApointTi=point; } else { BpointTi=point; break; } } if(n==1) { return (ApointTi!=null)?ApointTi:BpointTi; } else if(ApointTi == null || BpointTi == null) { throw new IllegalArgumentException("Invalid A and B points."); } double ApointTiValue = TypeInference.toDouble(survivalFunction.get2d(ApointTi.toString(), "Sti")); double BpointTiValue = TypeInference.toDouble(survivalFunction.get2d(BpointTi.toString(), "Sti")); double median=BpointTi-(BpointTiValue-0.5)*(BpointTi-ApointTi)/(BpointTiValue-ApointTiValue); return median; }  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 testMedian() { logger.info("median"); AssociativeArray2D survivalFunction = CensoredDescriptives.survivalFunction(generateFlatDataCollection()); double expResult = 9.6111111111111; double result = CensoredDescriptives.median(survivalFunction); assertEquals(expResult, result, Constants.DOUBLE_ACCURACY_HIGH); }