question: public EnumeratedDistribution ( final List < Pair < T , Double > > pmf ) throws MathIllegalArgumentException { singletons = new ArrayList < > ( pmf . size ( ) ) ; final double [ ] probs = new double [ pmf . size ( ) ] ; for ( int i = 0 ; i < pmf . size ( ) ; i ++ ) { final Pair < T , Double > sample = pmf . get ( i ) ; singletons . add ( sample . getKey ( ) ) ; final double p = sample . getValue ( ) ; probs [ i ] = p ; } probabilities = checkAndNormalize ( probs ) ; cumulativeProbabilities = new double [ probabilities . length ] ; double sum = 0 ; for ( int i = 0 ; i < probabilities . length ; i ++ ) { sum += probabilities [ i ] ; cumulativeProbabilities [ i ] = sum ; } }
target:  Create an enumerated distribution using the given probability mass function enumeration.