Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 36539 invoked from network); 24 Oct 2004 20:19:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 24 Oct 2004 20:19:39 -0000 Received: (qmail 12625 invoked by uid 500); 24 Oct 2004 20:19:34 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 12304 invoked by uid 500); 24 Oct 2004 20:19:29 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 12291 invoked by uid 99); 24 Oct 2004 20:19:28 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [209.249.229.10] (HELO ricouer.tsdinc.steitz.com) (209.249.229.10) by apache.org (qpsmtpd/0.28) with ESMTP; Sun, 24 Oct 2004 13:19:26 -0700 Received: from Lavoie.tsdinc.steitz.com ([209.249.229.4]) by ricouer.tsdinc.steitz.com with Microsoft SMTPSVC(5.0.2195.6713); Sun, 24 Oct 2004 16:19:21 -0400 Received: from [192.168.1.197] ([130.13.71.41]) by Lavoie.tsdinc.steitz.com with Microsoft SMTPSVC(5.0.2195.6713); Sun, 24 Oct 2004 16:19:21 -0400 Message-ID: <417BE418.9080305@steitz.com> Date: Sun, 24 Oct 2004 13:19:20 -0400 From: Phil Steitz User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Developers List Subject: [math] Changes to distribution package Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 24 Oct 2004 20:19:21.0460 (UTC) FILETIME=[BF429B40:01C4BA06] X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Frank has pointed out some limitations in the distribution package. Unfortunately, the problems require interface changes to fix, so we need to solve them now (i.e., before 1.0 final). There are basically two problems that we need to deal with: 1) There is no way to represent a "mixed" distribution (one which is neither continuous nor discrete, e.g. point mass with p = 0.5 at 0, uniform density with p = 0.5 between 0 and 1.) 2) There is no way to represent the distribution of a discrete random variable that takes non-integer values. To solve 1), we can add a ProbabilityDistribution interface like so: public interface ProbabilityDistribution { /** * For a random variable X whose values are distributed according * to this distribution, this method returns P(X ≤ x). In other words, * this method represents the (cumulative) distribution function, or * CDF, for this distribution. * * @param x the value at which the distribution function is evaluated. * @return cumulative probability that a random variable with this * distribution takes a value less than or equal to x * @throws MathException if the cumulative probability can not be * computed due to convergence or other numerical errors. */ double cumulativeProbability(double x) throws MathException; /** * For a random variable X whose values are distributed according * to this distribution, this method returns P(x0 ≤ X ≤ x1). *

* This method should always return the same value as * cumulativeProbability(x1) - cumulativeProbaility(x0) * * @param x0 the (inclusive) lower bound * @param x1 the (inclusive) upper bound * @return the probability that a random variable with this distribution * will take a value between x0 and x1, * including the endpoints * @throws MathException if the cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if x0 > x1 */ double cumulativeProbability(int x0, int x1) throws MathException; } the second method is not really necessary, but convenient. A default implementation could be provided in an AbstractProbabilityDistribution class. Then the natural thing to do would be to have ContinuousDistribution and DiscreteDistribution interfaces extend ProbabilityDistribution and the Abstract*Distribution classes extend AbstractProbabilityDistribution. To solve 2), I think we need to do something like this: ProbabilityDistribution (as above) | -DiscreteDistribution (adds *only* probability(double x)) | -IntegerDistribution (methods now in DiscreteDistribution) AbstractDiscreteDistribution would become AbstractIntegerDistribution and would add default implementations for the inherited methods taking doubles as arguments. Might be tricky for probability(double), but the CDF functions should be OK using floors and ceils. Any objections to these changes? Any better ideas? One more thing. Frank has suggested that we introduce a Probability class to represent the return values of the various distribution and probability functions. I have been -0 to introducing this, though I understand the value. What do others think? Phil --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org