Source Code Cross Referenced for AbstractStorelessUnivariateStatistic.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 2003-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 org.apache.commons.math.util.MathUtils;
019:        import java.io.Serializable;
020:
021:        /**
022:         *
023:         * Abstract implementation of the {@link StorelessUnivariateStatistic} interface.
024:         * <p>
025:         * Provides default <code>evaluate()</code> and <code>incrementAll(double[])<code>
026:         * implementations. 
027:         * <p>
028:         * <strong>Note that these implementations are not synchronized.</strong>
029:         *
030:         * @version $Revision: 355770 $ $Date: 2005-12-10 12:48:57 -0700 (Sat, 10 Dec 2005) $
031:         */
032:        public abstract class AbstractStorelessUnivariateStatistic extends
033:                AbstractUnivariateStatistic implements 
034:                StorelessUnivariateStatistic, Serializable {
035:
036:            /** Serialization UID */
037:            private static final long serialVersionUID = -44915725420072521L;
038:
039:            /**
040:             * This default implementation calls {@link #clear}, then invokes 
041:             * {@link #increment} in a loop over the the input array, and then uses 
042:             * {@link #getResult} to compute the return value.  
043:             * <p>
044:             * Note that this implementation changes the internal state of the
045:             * statistic.  Its side effects are the same as invoking {@link #clear} and
046:             * then {@link #incrementAll(double[])}.
047:             * <p>
048:             * Implementations may override this method with a more efficient 
049:             * implementation that works directly with the input array.
050:             * <p>
051:             * If the array is null, an IllegalArgumentException is thrown.
052:             * 
053:             * @see org.apache.commons.math.stat.descriptive.UnivariateStatistic#evaluate(double[])
054:             */
055:            public double evaluate(final double[] values) {
056:                if (values == null) {
057:                    throw new IllegalArgumentException(
058:                            "input value array is null");
059:                }
060:                return evaluate(values, 0, values.length);
061:            }
062:
063:            /**
064:             * This default implementation calls {@link #clear}, then invokes 
065:             * {@link #increment} in a loop over the specified portion of the input 
066:             * array, and then uses {@link #getResult} to compute the return value.  
067:             * <p>
068:             * Note that this implementation changes the internal state of the
069:             * statistic.  Its side effects are the same as invoking {@link #clear} and
070:             * then {@link #incrementAll(double[], int, int)}.
071:             * <p>
072:             * Implementations may override this method with a more efficient 
073:             * implementation that works directly with the input array.
074:             * <p>
075:             * If the array is null or the index parameters are not valid, an 
076:             * IllegalArgumentException is thrown.
077:             * 
078:             * @see org.apache.commons.math.stat.descriptive.UnivariateStatistic#evaluate(double[], int, int)
079:             */
080:            public double evaluate(final double[] values, final int begin,
081:                    final int length) {
082:                if (test(values, begin, length)) {
083:                    clear();
084:                    incrementAll(values, begin, length);
085:                }
086:                return getResult();
087:            }
088:
089:            /**
090:             * @see org.apache.commons.math.stat.descriptive.StorelessUnivariateStatistic#clear()
091:             */
092:            public abstract void clear();
093:
094:            /**
095:             * @see org.apache.commons.math.stat.descriptive.StorelessUnivariateStatistic#getResult()
096:             */
097:            public abstract double getResult();
098:
099:            /**
100:             * @see org.apache.commons.math.stat.descriptive.StorelessUnivariateStatistic#increment(double)
101:             */
102:            public abstract void increment(final double d);
103:
104:            /**
105:             * This default implementation just calls {@link #increment} in a loop over
106:             * the input array.   
107:             * <p>
108:             * Throws IllegalArgumentException if the input values array is null.
109:             * 
110:             * @param values values to add
111:             * @throws IllegalArgumentException if values is null
112:             * @see org.apache.commons.math.stat.descriptive.StorelessUnivariateStatistic#incrementAll(double[])
113:             */
114:            public void incrementAll(double[] values) {
115:                if (values == null) {
116:                    throw new IllegalArgumentException(
117:                            "input values array is null");
118:                }
119:                incrementAll(values, 0, values.length);
120:            }
121:
122:            /**
123:             * This default implementation just calls {@link #increment} in a loop over
124:             * the specified portion of the input array.
125:             * <p>
126:             * Throws IllegalArgumentException if the input values array is null.
127:             * 
128:             * @param values  array holding values to add
129:             * @param begin   index of the first array element to add
130:             * @param length  number of array elements to add
131:             * @throws IllegalArgumentException if values is null
132:             * @see org.apache.commons.math.stat.descriptive.StorelessUnivariateStatistic#incrementAll(double[], int, int)
133:             */
134:            public void incrementAll(double[] values, int begin, int length) {
135:                if (test(values, begin, length)) {
136:                    int k = begin + length;
137:                    for (int i = begin; i < k; i++) {
138:                        increment(values[i]);
139:                    }
140:                }
141:            }
142:
143:            /**
144:             * Returns true iff <code>object</code> is an 
145:             * <code>AbstractStorelessUnivariateStatistic</code> returning the same
146:             * values as this for <code>getResult()</code> and <code>getN()</code>
147:             * @param object object to test equality against.
148:             * @return true if object returns the same value as this
149:             */
150:            public boolean equals(Object object) {
151:                if (object == this ) {
152:                    return true;
153:                }
154:                if (object instanceof  AbstractStorelessUnivariateStatistic == false) {
155:                    return false;
156:                }
157:                AbstractStorelessUnivariateStatistic stat = (AbstractStorelessUnivariateStatistic) object;
158:                return (MathUtils.equals(stat.getResult(), this .getResult()) && MathUtils
159:                        .equals(stat.getN(), this .getN()));
160:            }
161:
162:            /**
163:             * Returns hash code based on getResult() and getN()
164:             * 
165:             * @return hash code
166:             */
167:            public int hashCode() {
168:                return 31 * (31 + MathUtils.hash(getResult()))
169:                        + MathUtils.hash(getN());
170:            }
171:
172:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.