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

MultivariateNormalDistribution.density() unnecessarily copies means array in loop

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 3.6.1
    • 4.0
    • None

    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

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

            Dates

              Created:
              Updated:
              Resolved: