private long makeUpRuntime ( List < LoggedDiscreteCDF > mapAttemptCDFs ) { int total = 0 ; for ( LoggedDiscreteCDF cdf : mapAttemptCDFs ) { total += cdf . getNumberValues ( ) ; } if ( total == 0 ) { return - 1 ; } int index = random . nextInt ( total ) ; for ( LoggedDiscreteCDF cdf : mapAttemptCDFs ) { if ( index >= cdf . getNumberValues ( ) ) { index -= cdf . getNumberValues ( ) ; } else { if ( index < 0 ) { throw new IllegalStateException ( "application error" ) ; } return makeUpRuntime ( cdf ) ; } } throw new IllegalStateException ( "not possible to get here" ) ; }
Perform a weighted random selection on a list of CDFs and produce a random variable using the selected CDF .