### Question:
AbstractPearson implements Correlation { public static double getZeroRank(Vector v){ if ( v instanceof DenseVector ){ return 0; } else if ( v instanceof SparseVector ){ int numZeroes = v.size() - ((SparseVector) v).getUsed(); if ( numZeroes == 0 ) { return 0; } else { return (double) ( (1 + numZeroes) * numZeroes ) / (2 * numZeroes); } } else { throw new RuntimeException( "unexpected vector type of " + v.getClass().getName() ); } }  double computeCorrelations(int i, int j); void init(ProfileData data); double getThresholdValue(); static double getZeroRank(Vector v); static final double MIN_STDEV; }### Answer:
@Test public void testGetZeroRank(){ Vector v = new DenseVector(new double[]{1, 2, 3, 4, 5}); assertEquals( AbstractPearson.getZeroRank(v), 0.0, 0d ); v = new SparseVector(5, new int[]{2, 3}, new double[]{1,1}); assertEquals( AbstractPearson.getZeroRank(v), 2.0, 0d); v = new SparseVector(5, new int[]{2}, new double[]{1}); assertEquals( AbstractPearson.getZeroRank(v), 2.5, 0d); }