### Question:
BinaryInteractionMetaAnalysis { protected static double weightedZscore(double[] zscores, int[] samples) throws MetaZscoreException { double numerator = 0; double denominator = 0; for (int i = 0; i < zscores.length; ++i) { if (samples[i] == 0) { continue; } else if (samples[i] < 0) { throw new MetaZscoreException(i, "Sample count < 0"); } else if (Double.isNaN(zscores[i])) { throw new MetaZscoreException(i, "Z-score = NaN"); } else if (Double.isInfinite(zscores[i])) { throw new MetaZscoreException(i, "Z-score = Inf"); } else { numerator += zscores[i] * samples[i]; denominator += samples[i] * samples[i]; } } if (denominator < 1) { return Double.NaN; } else { return numerator / Math.sqrt(denominator); } }  static void main(String[] args);  }### Answer:
@Test public void testweightedZscore1() throws Exception { double[] zscore = {2.3263479, 0.8416212, 0.5244005}; int[] samples = {1,1,1}; double expected = 2.13179059; double result = BinaryInteractionMetaAnalysis.weightedZscore(zscore, samples); assertEquals(result, expected, 0.0000001); }
@Test public void testweightedZscore2() throws Exception { double[] zscore = {2.3263479, 0.8416212, 0.5244005}; int[] samples = {10,1,1}; double expected = 2.438683939; double result = BinaryInteractionMetaAnalysis.weightedZscore(zscore, samples); assertEquals(result, expected, 0.0000001); }
@Test public void testweightedZscore3() throws Exception { double[] zscore = {2.3263479, 0.8416212, 0.5244005}; int[] samples = {10,1,0}; double expected = 2.39854709; double result = BinaryInteractionMetaAnalysis.weightedZscore(zscore, samples); assertEquals(result, expected, 0.0000001); }
@Test public void testweightedZscore4() throws Exception { double[] zscore = {2.3263479}; int[] samples = {10}; double expected = 2.3263479; double result = BinaryInteractionMetaAnalysis.weightedZscore(zscore, samples); assertEquals(result, expected, 0.0000001); }