### Question:
ConditionalProbabilityBasedWeighter implements Weighter { @Override public double[] createWeights(SubsetProbabilities probabilities) { int pos = 0; for (int i = 0; i < probabilities.segments.length; ++i) { pos += probabilities.conditions[i].length; } double weights[] = new double[pos]; pos = 0; for (int i = 0; i < probabilities.segments.length; ++i) { for (int j = 0; j < probabilities.conditions[i].length; ++j) { weights[pos] = probabilities.probabilities[probabilities.conditions[i][j]]; ++pos; } } return weights; }  @Override double[] createWeights(SubsetProbabilities probabilities); @Override String getName();  }### Answer:
@Test public void test() { SegmentationDefinition subsets = subsetCreator.getSubsetDefinition(wordsetSize); SubsetProbabilities subProbs = new SubsetProbabilities(subsets.segments, subsets.conditions, probabilities); Weighter weighter = new ConditionalProbabilityBasedWeighter(); Assert.assertArrayEquals(expectedWeightings, weighter.createWeights(subProbs), DOUBLE_PRECISION_DELTA); }