original_string: public static function histogram($values, $edges)
      {
          $bins = [];
          foreach ($edges as $key => $val) {
              if (!isset($edges[$key + 1])) break;
              $bins[] = $val . '-' . ($edges[$key + 1]);
          }
  
          $histogram = array_fill_keys($bins, []);
          foreach ($values as $value) {
              $i = MathHelper::binary_search($edges, $value);
              if ($i == -1) {
                  $message = "Value $value is outside of specified edges array: " . print_r($edges, true) . "\n";
                  throw new \Exception($message);
              }
              $key = $bins[$i];
              $histogram[$key][] = $value;
          }
          return $histogram;
      }
code: public static function histogram($values, $edges)
      {
          $bins = [];
          foreach ($edges as $key => $val) {
              if (!isset($edges[$key + 1])) break;
              $bins[] = $val . '-' . ($edges[$key + 1]);
          }
  
          $histogram = array_fill_keys($bins, []);
          foreach ($values as $value) {
              $i = MathHelper::binary_search($edges, $value);
              if ($i == -1) {
                  $message = "Value $value is outside of specified edges array: " . print_r($edges, true) . "\n";
                  throw new \Exception($message);
              }
              $key = $bins[$i];
              $histogram[$key][] = $value;
          }
          return $histogram;
      }
code_tokens: public static function histogram ( $ values , $ edges ) { $ bins = [ ] ; foreach ( $ edges as $ key => $ val ) { if ( ! isset ( $ edges [ $ key + 1 ] ) ) break ; $ bins [ ] = $ val . '-' . ( $ edges [ $ key + 1 ] ) ; } $ histogram = array_fill_keys ( $ bins , [ ] ) ; foreach ( $ values as $ value ) { $ i = MathHelper :: binary_search ( $ edges , $ value ) ; if ( $ i == - 1 ) { $ message = "Value $value is outside of specified edges array: " . print_r ( $ edges , true ) . "\n" ; throw new \ Exception ( $ message ) ; } $ key = $ bins [ $ i ] ; $ histogram [ $ key ] [ ] = $ value ; } return $ histogram ; }
docstring: Creates a histogram with specified bins out of a given array
  @param array $values , e.g. [11, 12, 20, 25, 20.1, 33.5]
  @param array $edges , e.g. [0, 10, 20, 30, 40]
  @throws \Exception
  @return array histogram, e.g. ['0-10' => [], '10-20' => [11,12], '20-30' => [20,25,20.1], '30-40' => [33.5]]
docstring_tokens: Creates a histogram with specified bins out of a given array