Java Doc for Percentile.java in  » Science » Apache-commons-math-1.1 » org » apache » commons » math » stat » descriptive » rank » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » Apache commons math 1.1 » org.apache.commons.math.stat.descriptive.rank 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.math.stat.descriptive.AbstractUnivariateStatistic
      org.apache.commons.math.stat.descriptive.rank.Percentile

All known Subclasses:   org.apache.commons.math.stat.descriptive.rank.Median,
Percentile
public class Percentile extends AbstractUnivariateStatistic implements Serializable(Code)
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 algorithm implemented here works as follows:

  1. Let n be the length of the (sorted) array and 0 < p <= 100 be the desired percentile.
  2. If n = 1 return the unique array element (regardless of the value of p); otherwise
  3. Compute the estimated percentile position pos = p * (n + 1) / 100 and the difference, d between pos and floor(pos) (i.e. the fractional part of pos). If pos >= n return the largest element in the array; otherwise
  4. Let lower be the element in position floor(pos) in the array and let upper be the next element in the array. Return lower + d * (upper - lower)

To compute percentiles, the data must be (totally) ordered. Input arrays are copied and then sorted using java.util.Arrays.sort(double[]) . The ordering used by Arrays.sort(double[]) is the one determined by java.lang.Double.compareTo(Double) . This ordering makes Double.NaN larger than any other value (including Double.POSITIVE_INFINITY). Therefore, for example, the median (50th percentile) of {0, 1, 2, 3, 4, Double.NaN} evaluates to 2.5.

Since percentile estimation usually involves interpolation between array elements, arrays containing NaN or infinite values will often result in NaN or infinite values returned.

Note that this implementation is not synchronized. If multiple threads access an instance of this class concurrently, and at least one of the threads invokes the increment() or clear() method, it must be synchronized externally.
version:
   $Revision: 348519 $ $Date: 2005-11-23 12:12:18 -0700 (Wed, 23 Nov 2005) $




Constructor Summary
public  Percentile()
     Constructs a Percentile with a default quantile value of 50.0.
public  Percentile(double p)
     Constructs a Percentile with the specific quantile value.

Method Summary
public  doubleevaluate(double[] values, double p)
     Returns an estimate of the pth percentile of the values in the values array.
public  doubleevaluate(double[] values, int start, int length)
     Returns an estimate of the quantileth percentile of the designated values in the values array.
public  doubleevaluate(double[] values, int begin, int length, double p)
     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.
public  doublegetQuantile()
     Returns the value of the quantile field (determines what percentile is computed when evaluate() is called with no quantile argument).
public  voidsetQuantile(double p)
     Sets the value of the quantile field (determines what percentile is computed when evaluate() is called with no quantile argument).


Constructor Detail
Percentile
public Percentile()(Code)
Constructs a Percentile with a default quantile value of 50.0.



Percentile
public Percentile(double p)(Code)
Constructs a Percentile with the specific quantile value.
Parameters:
  p - the quantile
throws:
  IllegalArgumentException - if p is not greater than 0 and lessthan or equal to 100




Method Detail
evaluate
public double evaluate(double[] values, double p)(Code)
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.

  • Returns Double.NaN if values has length 0
  • Returns (for any value of p) values[0] if values has length 1
  • Throws IllegalArgumentException if values is null or p is not a valid quantile value (p must be greater than 0 and less than or equal to 100)

See Percentile for a description of the percentile estimation algorithm used.
Parameters:
  values - input array of values
Parameters:
  p - the percentile value to compute the percentile value or Double.NaN if the array is empty
throws:
  IllegalArgumentException - if values is null or p is invalid




evaluate
public double evaluate(double[] values, int start, int length)(Code)
Returns an estimate of the quantileth percentile of the designated values in the values array. The quantile estimated is determined by the quantile property.

  • Returns Double.NaN if length = 0
  • Returns (for any value of quantile) values[begin] if length = 1
  • Throws IllegalArgumentException if values is null, or start or length is invalid

See Percentile for a description of the percentile estimation algorithm used.
Parameters:
  values - the input array
Parameters:
  start - index of the first array element to include
Parameters:
  length - the number of elements to include the percentile value
throws:
  IllegalArgumentException - if the parameters are not valid




evaluate
public double evaluate(double[] values, int begin, int length, double p)(Code)
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.

  • Returns Double.NaN if length = 0
  • Returns (for any value of p) values[begin] if length = 1
  • Throws IllegalArgumentException if values is null , begin or length is invalid, or p is not a valid quantile value (p must be greater than 0 and less than or equal to 100)

See Percentile for a description of the percentile estimation algorithm used.
Parameters:
  values - array of input values
Parameters:
  p - the percentile to compute
Parameters:
  begin - the first (0-based) element to include in the computation
Parameters:
  length - the number of array elements to include the percentile value
throws:
  IllegalArgumentException - if the parameters are not valid or theinput array is null




getQuantile
public double getQuantile()(Code)
Returns the value of the quantile field (determines what percentile is computed when evaluate() is called with no quantile argument). quantile



setQuantile
public void setQuantile(double p)(Code)
Sets the value of the quantile field (determines what percentile is computed when evaluate() is called with no quantile argument).
Parameters:
  p - a value between 0 < p <= 100
throws:
  IllegalArgumentException - if p is not greater than 0 and lessthan or equal to 100



Methods inherited from org.apache.commons.math.stat.descriptive.AbstractUnivariateStatistic
public double evaluate(double[] values)(Code)(Java Doc)
abstract public double evaluate(double[] values, int begin, int length)(Code)(Java Doc)
protected boolean test(double[] values, int begin, int length)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

w_ww.___j_a___va__2s.__co___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.