Hello. Le dim. 1 août 2021 à 16:45, Alex Herbert <alex.d.herb...@gmail.com> a écrit : > > The ContinuousDistribution interface has the method: > > /** > * For a random variable {@code X} whose values are distributed according > * to this distribution, this method returns {@code P(X = x)}. > * In other words, this method represents the probability mass function > * (PMF) for the distribution. > * > * @param x Point at which the PMF is evaluated. > * @return the value of the probability mass function at point {@code x}. > */ > default double probability(double x) { > return 0; > } > > This is not overridden by any distribution. The javadoc is a direct copy > from the DiscreteDistribution interface where the PMF has relevance. All > the continuous distributions provide implementations for the related > density method: > > /** > * Returns the probability density function (PDF) of this distribution > * evaluated at the specified point {@code x}. > * In general, the PDF is the derivative of the {@link > #cumulativeProbability(double) CDF}. > * If the derivative does not exist at {@code x}, then an appropriate > * replacement should be returned, e.g. {@code Double.POSITIVE_INFINITY}, > * {@code Double.NaN}, or the limit inferior or limit superior of the > * difference quotient. > * > * @param x Point at which the PDF is evaluated. > * @return the value of the probability density function at {@code x}. > */ > double density(double x); > > It appears odd that the ContinuousDistribution has a probability(x) method > which returns 0 for all implementations, i.e. why have this method? It > could be implemented for the ConstantContinuousDistribution. At least in > this case for a constant value it should return 1 when x is the value of > the distribution. > > I have had no luck finding another library that implements this > distribution (e.g. R, matlab, python) and I do not know a use case other > than to implement a Dirac delta function [1]. In this case it is useful to > have the density return 1 such that multiplication by the density is a > linear functional that maps every function to its value at zero: > > f(x) * delta(x) = f(0) for x=0, zero otherwise
Do you think that the API defined in the "commons-statistics-distribution" module is suitable for implementing this concept: https://en.wikipedia.org/wiki/Distribution_(mathematics) ? > In other libraries for continuous functions they implement only the > probability density function (PDF) and the cumulative distribution function > (CDF) for both continuous and discrete distributions. There is no > additional probability function. > > Thus the method has no use in the current library. Here are two options: > > 1. Remove the method +1 Thanks, Gilles > 2. Implement the method in the ConstantContinuousDistribution to return 1 > when the value equals the constant value. It currently does this for the > density function but probability(x) will return zero for all values so it a > bug. This behaviour was ported from Commons Math 3. I find no continuous > distributions that override the probability method there either. > > Alex > > [1] https://en.wikipedia.org/wiki/Dirac_delta_function --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org