question: public Percentiles percentiles ( ConstantRange range ) { SortedSet < Constant > sorted = values ( ) ; SortedSet < Constant > contained = new TreeSet < Constant > ( ) ; Constant prev = null ; for ( Constant pct : sorted ) { if ( range . contains ( pct ) ) { contained . add ( pct ) ; } else if ( contained . isEmpty ( ) ) prev = pct ; } if ( contained . isEmpty ( ) ) return null ; double prevPercent = prev == null ? 0.0 : pcts . get ( prev ) ; double totalPercent = pcts . get ( contained . last ( ) ) - prevPercent ; Map < Constant , Double > newPcts = new HashMap < Constant , Double > ( ) ; for ( Constant p : contained ) newPcts . put ( p , ( pcts . get ( p ) - prevPercent ) / totalPercent ) ; return new Percentiles ( newPcts ) ; }
target:  Returns a new instance that keeps only the percentiles with values falling within the specified range. All new percentiles are adjusted such that the last value has the 100% percentage.