private List<Interval> calcIntervals() {
        List<Interval> intervals = new ArrayList<Interval>(numIntervals);

        // Gets collection max an min
        double min = Double.MAX_VALUE;
        double max = Double.MIN_VALUE;
        for (double n : durations) {
            max = Math.max(max, n);
            min = Math.min(min, n);
        }

        initIntervals(intervals, min, max);

        for (Double d : durations) {
            boolean found = false;
            final Iterator<Interval> iterator = intervals.iterator();
            while (iterator.hasNext() && !found) {
                final Interval interval = iterator.next();
                final int startCmp = interval.getStart().compareTo(d);
                final int endCmp = interval.getEnd().compareTo(d);
                if ((startCmp == 0 || startCmp < 0) && (endCmp == 0 || endCmp > 0)) {
                    found = true;
                    interval.incHeight();
                }
            }

            if (!found)
                throw new RuntimeException("Histogram interval not found for value " + d);
        }


        return intervals;
    }