Source Code Cross Referenced for SummaryStatistics.java in  » Science » Apache-commons-math-1.1 » org » apache » commons » math » stat » descriptive » 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 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.apache.commons.math.stat.descriptive;
017:
018:        import java.io.Serializable;
019:
020:        import org.apache.commons.discovery.tools.DiscoverClass;
021:        import org.apache.commons.math.util.MathUtils;
022:
023:        /**
024:         * Abstract factory class for univariate statistical summaries.
025:         *
026:         * @version $Revision: 348519 $ $Date: 2005-11-23 12:12:18 -0700 (Wed, 23 Nov 2005) $
027:         */
028:        public abstract class SummaryStatistics implements  StatisticalSummary,
029:                Serializable {
030:
031:            /** Serialization UID */
032:            private static final long serialVersionUID = -6400596334135654825L;
033:
034:            /**
035:             * Create an instance of a <code>SummaryStatistics</code>
036:             * 
037:             * @param cls the type of <code>SummaryStatistics</code> object to
038:             *        create. 
039:             * @return a new factory. 
040:             * @throws InstantiationException is thrown if the object can not be
041:             *            created.
042:             * @throws IllegalAccessException is thrown if the type's default
043:             *            constructor is not accessible.
044:             */
045:            public static SummaryStatistics newInstance(Class cls)
046:                    throws InstantiationException, IllegalAccessException {
047:                return (SummaryStatistics) cls.newInstance();
048:            }
049:
050:            /**
051:             * Create an instance of a <code>SummaryStatistics</code>
052:             * 
053:             * @return a new SummaryStatistics instance. 
054:             */
055:            public static SummaryStatistics newInstance() {
056:                SummaryStatistics instance = null;
057:                try {
058:                    DiscoverClass dc = new DiscoverClass();
059:                    instance = (SummaryStatistics) dc
060:                            .newInstance(SummaryStatistics.class,
061:                                    "org.apache.commons.math.stat.descriptive.SummaryStatisticsImpl");
062:                } catch (Throwable t) {
063:                    return new SummaryStatisticsImpl();
064:                }
065:                return instance;
066:            }
067:
068:            /**
069:             * Return a {@link StatisticalSummaryValues} instance reporting current
070:             * statistics.
071:             * 
072:             * @return Current values of statistics 
073:             */
074:            public StatisticalSummary getSummary() {
075:                return new StatisticalSummaryValues(getMean(), getVariance(),
076:                        getN(), getMax(), getMin(), getSum());
077:            }
078:
079:            /**
080:             * Adds the value to the data to be summarized
081:             * @param v the value to be added 
082:             */
083:            public abstract void addValue(double v);
084:
085:            /** 
086:             * Returns the <a href="http://www.xycoon.com/arithmetic_mean.htm">
087:             * arithmetic mean </a> of the available values 
088:             * @return The mean or Double.NaN if no values have been added.
089:             */
090:            public abstract double getMean();
091:
092:            /** 
093:             * Returns the <a href="http://www.xycoon.com/geometric_mean.htm">
094:             * geometric mean </a> of the available values
095:             * @return The geometricMean, Double.NaN if no values have been added, 
096:             * or if the productof the available values is less than or equal to 0.
097:             */
098:            public abstract double getGeometricMean();
099:
100:            /** 
101:             * Returns the variance of the available values.
102:             * @return The variance, Double.NaN if no values have been added 
103:             * or 0.0 for a single value set.  
104:             */
105:            public abstract double getVariance();
106:
107:            /** 
108:             * Returns the standard deviation of the available values.
109:             * @return The standard deviation, Double.NaN if no values have been added 
110:             * or 0.0 for a single value set. 
111:             */
112:            public abstract double getStandardDeviation();
113:
114:            /** 
115:             * Returns the maximum of the available values
116:             * @return The max or Double.NaN if no values have been added.
117:             */
118:            public abstract double getMax();
119:
120:            /** 
121:             * Returns the minimum of the available values
122:             * @return The min or Double.NaN if no values have been added.
123:             */
124:            public abstract double getMin();
125:
126:            /** 
127:             * Returns the number of available values
128:             * @return The number of available values
129:             */
130:            public abstract long getN();
131:
132:            /**
133:             * Returns the sum of the values that have been added to Univariate.
134:             * @return The sum or Double.NaN if no values have been added
135:             */
136:            public abstract double getSum();
137:
138:            /**
139:             * Returns the sum of the squares of the available values.
140:             * @return The sum of the squares or Double.NaN if no 
141:             * values have been added.
142:             */
143:            public abstract double getSumsq();
144:
145:            /** 
146:             * Resets all statistics
147:             */
148:            public abstract void clear();
149:
150:            /**
151:             * Returns true iff <code>object</code> is a <code>SummaryStatistics</code>
152:             * instance and all statistics have the same values as this.
153:             * @param object the object to test equality against.
154:             * @return true if object equals this
155:             */
156:            public boolean equals(Object object) {
157:                if (object == this ) {
158:                    return true;
159:                }
160:                if (object instanceof  SummaryStatistics == false) {
161:                    return false;
162:                }
163:                SummaryStatistics stat = (SummaryStatistics) object;
164:                return (MathUtils.equals(stat.getGeometricMean(), this 
165:                        .getGeometricMean())
166:                        && MathUtils.equals(stat.getMax(), this .getMax())
167:                        && MathUtils.equals(stat.getMean(), this .getMean())
168:                        && MathUtils.equals(stat.getMin(), this .getMin())
169:                        && MathUtils.equals(stat.getN(), this .getN())
170:                        && MathUtils.equals(stat.getSum(), this .getSum())
171:                        && MathUtils.equals(stat.getSumsq(), this .getSumsq()) && MathUtils
172:                        .equals(stat.getVariance(), this .getVariance()));
173:            }
174:
175:            /**
176:             * Returns hash code based on values of statistics
177:             * 
178:             * @return hash code
179:             */
180:            public int hashCode() {
181:                int result = 31 + MathUtils.hash(getGeometricMean());
182:                result = result * 31 + MathUtils.hash(getGeometricMean());
183:                result = result * 31 + MathUtils.hash(getMax());
184:                result = result * 31 + MathUtils.hash(getMean());
185:                result = result * 31 + MathUtils.hash(getMin());
186:                result = result * 31 + MathUtils.hash(getN());
187:                result = result * 31 + MathUtils.hash(getSum());
188:                result = result * 31 + MathUtils.hash(getSumsq());
189:                result = result * 31 + MathUtils.hash(getVariance());
190:                return result;
191:            }
192:
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.