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

Provide a way to copy all instances of StorelessUnivariateStatistic (e.g. Mean, Variance, Max, Kurtoise, etc), perhaps via a copy-constructor

Rank to TopRank to BottomBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersConvert to sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.0
    • None
    • None
    • N/A

    Description

      Below is the conversation related to this topic that was posted to the Commons Users group. As soon as I figure out how, I'll attach my patch that adds copy constructors to all intended classes exception GeometricMean and SummaryStatistic, which both allow the user to specify arbitrary implementations and thus cannot be copied. See below for details.

      Phil,

      Well, that was easy in some cases and I'm not sure how it went in others and could use help. I had issue with creating a copy constructor for GeometricMean and SummaryStatistic. Both of these classes allow the user to, via the API, set a StorelessUnivariateStatistic as the implementation. For instance take the following method in Geometric mean:

      public void setSumLogImpl(
      StorelessUnivariateStatistic sumLogImpl)

      { checkEmpty(); this.sumOfLogs = sumLogImpl; }

      There is no way to create a true deep copy of sumLogImpl, as we only know it to be an instance of StorelessUnivariateStatistic. I think the solution is to allow the copy constructors for the below classes into the baseline, but not provide a copy constructor for GeometricMean or SummaryStatistic unless you want to (1) deprecate the implementation business or (2) create a abstract copy method in StorelessUnivariateStatistic forcing all implementations to be 'copyable'.

      The following classes were able to be given copy constructors without issue:
      Max
      SumOfSquares
      Sum
      Product
      FirstMoment
      SecondMoment
      ThirdMoment
      FourthMoment
      Median
      Min
      SumOfLogs
      Percentile
      Skewness
      Variance
      Mean
      Kurtois
      StandardDeviation

      Phil Steitz wrote:
      > Jason C. HandUber wrote:
      >> Hello,
      >>
      >> I'm writing an evolutionary algorithm in which each individual contains StandardDeviations and Means. From time to time I need a deep copy / clone of an individual. Thus far I've actually had to keep a list of all data and, when cloning, generate a new statistic and increment it with all that data. Now that I'm moving to production level, turns out I'm running out of memory (no huge surprise). I'm going to extend Mean, Variance, StandardDeviation, FirstMoment, and SecondMoment for my application to provide a copy constructor (which, according to Item 10, page 51 of Bloch's effective java, beats out clone, and I buy that) for each. Anyway, I think that addition would be easy and general enough to introduce into the trunk. Any thoughts?
      > +1 on this enhancement, also for SummaryStatistics, implemented as you describe.
      >
      > Please follow instructions here <http://commons.apache.org/math/developers.html> to create a patch against either trunk or the 2.0 development branch (/branches/MATH_2_0) and attach it to a JIRA ticket.
      >
      > Thanks!
      >
      > Phil

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            psteitz Phil Steitz
            wherisat jason
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment