code: public static IntRange GetRange( int[] values, double percent ){
          int total = 0, n = values.length;
  
          // for all values
          for ( int i = 0; i < n; i++ )
          {
              // accumalate total
              total += values[i];
          }
  
          int min, max, hits;
          int h = (int) ( total * ( percent + ( 1 - percent ) / 2 ) );
  
          // get range min value
          for ( min = 0, hits = total; min < n; min++ )
          {
              hits -= values[min];
              if ( hits < h )
                  break;
          }
          // get range max value
          for ( max = n - 1, hits = total; max >= 0; max-- )
          {
              hits -= values[max];
              if ( hits < h )
                  break;
          }
          return new IntRange( min, max );
      }
docs: Get range around median containing specified percentage of values.
  @param values Values.
  @param percent Values percentage around median.
  @return Returns the range which containes specifies percentage of values.