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

AbstractStorelessUnivariateStatistic should not extend AbstractUnivariateStatistic

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.4.1
    • Fix Version/s: 4.0
    • Labels:
      None

      Description

      For a storeless statistic it is wrong to extend AbstractUnivariateStatistic as various fields and methods are inherited that do not make sense in case of a storeless statistic.

      This means a user can accidentially use a storeless statistic in a wrong way:

              Mean mean = new Mean();
              
              mean.increment(1);
              mean.increment(2);
              
              mean.setData(new double[] { 1, 2, 3});
              
              System.out.println(mean.getResult());
              System.out.println(mean.evaluate());
      

      will output

      1.5
      2.0
      

        Attachments

        1. AbstractCachingUnivariateStatistic.java
          4 kB
          Thomas Neidhart
        2. MATH-1205_v2.patch
          89 kB
          Thomas Neidhart

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              tn Thomas Neidhart
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: