Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 88143 invoked from network); 13 Mar 2004 20:02:32 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 13 Mar 2004 20:02:32 -0000 Received: (qmail 22545 invoked by uid 500); 13 Mar 2004 20:02:19 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 22495 invoked by uid 500); 13 Mar 2004 20:02:19 -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 22481 invoked by uid 500); 13 Mar 2004 20:02:18 -0000 Received: (qmail 22478 invoked from network); 13 Mar 2004 20:02:18 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 13 Mar 2004 20:02:18 -0000 Received: (qmail 88124 invoked by uid 1718); 13 Mar 2004 20:02:28 -0000 Date: 13 Mar 2004 20:02:28 -0000 Message-ID: <20040313200228.88123.qmail@minotaur.apache.org> From: psteitz@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank Percentile.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N psteitz 2004/03/13 12:02:28 Modified: math/src/java/org/apache/commons/math/stat/univariate/rank Percentile.java Log: Renamed internal field, added algorithm documentation. Revision Changes Path 1.15 +65 -32 jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Percentile.java Index: Percentile.java =================================================================== RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Percentile.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- Percentile.java 4 Mar 2004 04:25:09 -0000 1.14 +++ Percentile.java 13 Mar 2004 20:02:28 -0000 1.15 @@ -20,38 +20,51 @@ import org.apache.commons.math.stat.univariate.AbstractUnivariateStatistic; /** + * Provides percentile computation. + *

+ * There are several commonly used methods for estimating percentiles (a.k.a. quantiles) based + * on sample data. For large samples, the different methods agree closely, but when sample sizes + * are small, different methods will give significantly different results. The implementation provided here + * follows the first estimation procedure presented + * here. + * * @version $Revision$ $Date$ */ public class Percentile extends AbstractUnivariateStatistic implements Serializable { static final long serialVersionUID = -8091216485095130416L; - /** */ - private double percentile = 0.0; + /** Determines what percentile is computed when evaluate() is activated with no quantile argument */ + private double quantile = 0.0; /** - * Constructs a Percentile with a default percentile + * Constructs a Percentile with a default quantile * value of 50.0. */ public Percentile() { super(); - percentile = 50.0; + quantile = 50.0; } /** - * Constructs a Percentile with the specific percentile value. - * @param p the percentile + * Constructs a Percentile with the specific quantile value. + * @param p the quantile */ public Percentile(final double p) { - this.percentile = p; + this.quantile = p; } /** - * Evaluates the double[] top the specified percentile. - * This does not alter the interal percentile state of the - * statistic. + * Returns an estimate of the pth percentile of the values + * in the values array. + *

+ * Calls to this method do not modify the internal quantile + * state of this statistic. + *

+ * See {@link Percentile} for a description of the percentile estimation algorithm used. + * * @param values Is a double[] containing the values - * @param p Is the percentile to evaluate to. + * @param p Is the quantile to evaluate to. * @return the result of the evaluation or Double.NaN * if the array is empty */ @@ -60,24 +73,42 @@ } /** - * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int) + * Returns an estimate of the quantileth percentile of the values + * in the values array. The quantile estimated is determined by + * the quantile property. + *

+ * See {@link Percentile} for a description of the percentile estimation algorithm used. + * + * @param values array of input values + * @param start the first (0-based) element to include in the computation + * @param length the number of array elements to include + * @return the result of the evaluation or Double.NaN + * if the array is empty + * */ public double evaluate( final double[] values, final int start, final int length) { - return evaluate(values, start, length, percentile); + return evaluate(values, start, length, quantile); } - /** - * Evaluates the double[] top the specified percentile. - * This does not alter the interal percentile state of the - * statistic. + /** + * Returns an estimate of the pth percentile of the values + * in the values array, starting with the element in (0-based) + * position begin in the array and including length + * values. + *

+ * Calls to this method do not modify the internal quantile + * state of this statistic. + *

+ * See {@link Percentile} for a description of the percentile estimation algorithm used. + * * @param values Is a double[] containing the values - * @param begin processing at this point in the array - * @param length the number of elements to include - * @param p Is the percentile to evaluate to.* + * @param p Is the quantile to evaluate to. + * @param start the first (0-based) element to include in the computation + * @param length the number of array elements to include * @return the result of the evaluation or Double.NaN * if the array is empty */ @@ -90,7 +121,7 @@ test(values, begin, length); if ((p > 100) || (p <= 0)) { - throw new IllegalArgumentException("invalid percentile value"); + throw new IllegalArgumentException("invalid quantile value"); } double n = (double) length; if (n == 0) { @@ -119,21 +150,23 @@ } /** - * The default internal state of this percentile can be set. - * This will return that value. - * @return percentile + * Returns the value of the quantile field (determines what percentile is computed when evaluate() + * is called with no quantile argument) + * + * @return quantile */ - public double getPercentile() { - return percentile; + public double getQuantile() { + return quantile; } /** - * The default internal state of this percentile can be set. - * This will setthat value. - * @param p a value between 0 <= p <= 100 + * Sets the value of the quantile field (determines what percentile is computed when evaluate() + * is called with no quantile argument) + * + * @param p a value between 0 <= p <= 100 */ - public void setPercentile(final double p) { - percentile = p; + public void setQuantile(final double p) { + quantile = p; } } --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org