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;
    }