Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1279

Avoid unexpected errors in EmpiricalDistribution

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 3.5
    • Fix Version/s: 4.0, 3.6
    • Labels:
      None
    • Environment:

      Ubuntu 14.04

      Description

      Loading an empirical distributions results in an ArrayIndexOutOfBoundsException when giving 0 as bin size, for example in:

      double values[] = new double[]

      { 1, 2 }

      ;
      EmpiricalDistribution distribution = new EmpiricalDistribution(0);
      distribution.load(values);

      To keep the error more understandable to the user, it would be nice if an RuntimeException or something like this would be thrown when initializing the EmpiricalDistribution with 0 bins. Especially when following the rule of thumb that there should be values size / 10 bins, it is hard to find out that the error is caused by a wrong bin size and not by some error in the load-call.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              DaGeRe David Georg Reichelt
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified