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

MultivariateNormalDistribution.density() unnecessarily copies means array in loop

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 3.6.1
    • Fix Version/s: 4.0
    • Labels:

      Description

      In the class MultivariateNormalDistribution, the public method density() calls the private method getExponentTerm(), which first centers the given instance by the mean.
      However, it is using the method getMeans(), which creates a copy of means array each time, just for reading the i-th index.
      See https://github.com/apache/commons-math/blob/3.6.1-release/src/main/java/org/apache/commons/math3/distribution/MultivariateNormalDistribution.java#L238

      A solution should use the private variable `means` directly.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              knub Stefan Bunk
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: