On 10/09/2014 11:07 AM, Thomas Neidhart wrote:
On Thu, Oct 9, 2014 at 6:03 PM, Ole Ersoy <ole.er...@gmail.com> wrote:

I think that, for some distribution, the computation of log(p) is more
accurate. This was a feature request from not long ago.


Just pasting the method below:

      public double logProbability(int x) {
          return FastMath.log(probability(x));
      }

So it retrieves the probability of the index and uses FastMath to compute
the log.  We could do:

FastMath(distribution.probability(x));

It just seems a bit over engineered to have something this trivial in the
API, unless I'm missing something.


This is the default implementation. For some distributions there is a more
efficient way to compute the logProbability directly, and for these
distributions the method is overridden (e.g. GeometricDistribution,
BinomialDistribution, ...).
Otherwise one would have to call probability(x) first, which in many cases
involves calling exp(...) and then compute the log of it, which is just a
waste of cpu.


So I guess my question is "Why is there value in having this as part of
the public API of AbstractIntegerDistribution?".  Not really a big deal,
but it just seems like it's an implementation detail.


We could not yet add it to the interface due to binary / source
compatibility rules, but it will be done for 4.0, see the ticket:
https://issues.apache.org/jira/browse/MATH-1039

OK - Thanks for the explanation.  Based on the description in the ticket it 
seems like it would be better to have it as part of a utility, but that's just 
my 50K foot view.

Cheers,
- Ole

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to