Source Code Cross Referenced for DescriptiveStatTest.java in  » Code-Analyzer » hammurapi-3.20.0.3 » org » hammurapi » inspectors » metrics » statistics » tests » 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 » Code Analyzer » hammurapi 3.20.0.3 » org.hammurapi.inspectors.metrics.statistics.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Mar 18, 2004
003:         *
004:         * To change the template for this generated file go to
005:         * Window - Preferences - Java - Code Generation - Code and Comments
006:         */
007:        package org.hammurapi.inspectors.metrics.statistics.tests;
008:
009:        import junit.framework.Test;
010:        import junit.framework.TestCase;
011:        import junit.framework.TestSuite;
012:
013:        import org.hammurapi.inspectors.metrics.statistics.DescriptiveStatistic;
014:        import org.hammurapi.inspectors.metrics.statistics.IntVector;
015:
016:        /**
017:         * @author mucbj0
018:         *
019:         * To change the template for this generated type comment go to Window -
020:         * Preferences - Java - Code Generation - Code and Comments
021:         */
022:        public class DescriptiveStatTest extends TestCase {
023:            /**
024:             * The suite() method.
025:             */
026:            public static Test suite() {
027:                //
028:                return new TestSuite(DescriptiveStatTest.class);
029:            }// End o
030:
031:            /**
032:             * This method is the starting point of the test programe
033:             *
034:             * @param strArgsArr
035:             *            The command line parameters passed.
036:             * @exception Exception
037:             *                A Exception object.
038:             */
039:            public static void main(String[] strArgsArr) throws Exception {
040:                junit.textui.TestRunner.run(suite());
041:            }// End of main
042:
043:            public void testFrequency1() {
044:                IntVector sortedData = new IntVector();
045:                sortedData.addElement(1);
046:                sortedData.addElement(1);
047:                sortedData.addElement(1);
048:                sortedData.addElement(3);
049:                sortedData.addElement(3);
050:                sortedData.addElement(5);
051:                sortedData.addElement(5);
052:                sortedData.addElement(7);
053:
054:                IntVector distinctValues = new IntVector();
055:                IntVector frequencies = new IntVector();
056:                new DescriptiveStatistic().frequencies(sortedData,
057:                        distinctValues, frequencies);
058:                System.out.println(frequencies);
059:                assertTrue("", frequencies.elementAt(0) == 3);
060:                assertTrue("", frequencies.elementAt(1) == 2);
061:                assertTrue("", frequencies.elementAt(2) == 2);
062:                assertTrue("", frequencies.elementAt(3) == 1);
063:            }
064:
065:            public void testFrequency2() {
066:                IntVector sortedData = new IntVector();
067:                sortedData.addElement(1);
068:                sortedData.addElement(1);
069:                sortedData.addElement(1);
070:                sortedData.addElement(1);
071:                sortedData.addElement(1);
072:                sortedData.addElement(1);
073:                sortedData.addElement(1);
074:                sortedData.addElement(1);
075:
076:                IntVector distinctValues = new IntVector();
077:                IntVector frequencies = new IntVector();
078:                new DescriptiveStatistic().frequencies(sortedData,
079:                        distinctValues, frequencies);
080:                System.out.println(frequencies);
081:                assertTrue("", frequencies.size() == 1);
082:                assertTrue("", frequencies.elementAt(0) == 8);
083:
084:            }
085:
086:            public void testFrequencyEmptyList() {
087:                IntVector sortedData = new IntVector();
088:
089:                IntVector distinctValues = new IntVector();
090:                IntVector frequencies = new IntVector();
091:                new DescriptiveStatistic().frequencies(sortedData,
092:                        distinctValues, frequencies);
093:                System.out.println(frequencies);
094:                assertTrue("", frequencies.isEmpty());
095:
096:            }
097:
098:            public void testAggregateData() {
099:                // int[] numbers = { 26, 26, 27, 27, 27, 32, 42, 42, 42, 42, 43, 43, 43, 43, 43, 44, 44, 45, 45, 46, 46, 48, 49, 51, 52, 53, 54, 54, 55, 61, 65, 66, 67, 68, 69, 71, 72, 74, 74, 74, 82, 89, 103, 106, 108, 112, 113, 127, 139, 140, 145, 150, 161, 175, 179, 183, 202, 211, 256, 269, 276, 286, 302, 309, 324, 346, 387, 684, 720, 1228, 1229, 2569 };
100:                int[] numbers = { 26, 26, 26, 26, 26, 42, 65, 175, 387, 684,
101:                        720, 1228, 1229, 2569 };
102:                IntVector distribution = new IntVector();
103:                IntVector distinctValues = new IntVector();
104:                IntVector frequencies = new IntVector();
105:                for (int i = 0; i < numbers.length; i++) {
106:                    int index = numbers[i];
107:                    // System.out.println(  index  + " -> "+index % 100);
108:                    int piv = (index / 50) * 50;
109:                    System.out.println(index + " -> " + piv);
110:                    distribution.addElement(piv);
111:                }
112:                System.out
113:                        .println("-------------------------------------------");
114:
115:                new DescriptiveStatistic().frequencies(distribution,
116:                        distinctValues, frequencies);
117:                assertTrue("frequencies.size() is " + frequencies.size(),
118:                        frequencies.size() == 8);
119:                assertTrue("", frequencies.elementAt(0) == 6);
120:                assertTrue("", frequencies.elementAt(7) == 1);
121:                assertTrue("distinctValues.size is " + distinctValues.size(),
122:                        distinctValues.size() == 8);
123:                assertTrue("", distinctValues.elementAt(0) == 0);
124:                assertTrue("", distinctValues.elementAt(7) == 2550);
125:
126:                //System.out.println( distribution );
127:                //System.out.println( distinctValues );
128:                //System.out.println( frequencies );
129:
130:            }
131:
132:            public void testSortIntVector() {
133:                // int[] numbers = { 26, 26, 27, 27, 27, 32, 42, 42, 42, 42, 43, 43, 43, 43, 43, 44, 44, 45, 45, 46, 46, 48, 49, 51, 52, 53, 54, 54, 55, 61, 65, 66, 67, 68, 69, 71, 72, 74, 74, 74, 82, 89, 103, 106, 108, 112, 113, 127, 139, 140, 145, 150, 161, 175, 179, 183, 202, 211, 256, 269, 276, 286, 302, 309, 324, 346, 387, 684, 720, 1228, 1229, 2569 };
134:                int[] numbers = { 684, 26, 26, 720, 1228, 26, 65, 175, 387,
135:                        1229, 2569, 26, 26, 42 };
136:                IntVector distribution = new IntVector(numbers);
137:                // System.out.println( distribution );
138:                distribution.sort();
139:                // System.out.println( distribution );
140:                assertTrue("distribution.size is " + distribution.size(),
141:                        distribution.size() == 14);
142:                assertTrue("", distribution.elementAt(0) == 26);
143:                assertTrue("", distribution.elementAt(13) == 2569);
144:            }
145:
146:            public void testSumIntVector1() {
147:                IntVector sortedData = new IntVector();
148:                sortedData.addElement(1);
149:                sortedData.addElement(1);
150:                sortedData.addElement(1);
151:                sortedData.addElement(3);
152:                sortedData.addElement(3);
153:                sortedData.addElement(5);
154:                sortedData.addElement(5);
155:                sortedData.addElement(7);
156:                int sum = new DescriptiveStatistic().sum(sortedData);
157:                assertTrue("", sum == 26);
158:
159:            }
160:
161:            public void testSumIntVector2() {
162:                IntVector sortedData = new IntVector();
163:                sortedData.addElement(1);
164:                sortedData.addElement(1);
165:                sortedData.addElement(1);
166:                sortedData.addElement(3);
167:                sortedData.addElement(3);
168:                sortedData.addElement(5);
169:                sortedData.addElement(5);
170:                sortedData.addElement(7);
171:                sortedData.addElement(1000);
172:                int sum = new DescriptiveStatistic().sum(sortedData);
173:                assertTrue("", sum == 1026);
174:
175:            }
176:
177:            public void testMeanIntVector1() {
178:                IntVector sortedData = new IntVector();
179:                sortedData.addElement(1);
180:                sortedData.addElement(1);
181:                sortedData.addElement(1);
182:                sortedData.addElement(3);
183:                sortedData.addElement(3);
184:                sortedData.addElement(5);
185:                sortedData.addElement(5);
186:                sortedData.addElement(7);
187:                double mean = new DescriptiveStatistic().mean(sortedData);
188:                assertTrue("Mean is not xx but " + mean, mean == 3.0);
189:            }
190:
191:            public void testMeanEmpytyIntVector() {
192:                IntVector sortedData = new IntVector();
193:                double mean = new DescriptiveStatistic().mean(sortedData);
194:                assertTrue("Mean is not xx but " + mean, mean == 0.0);
195:            }
196:
197:            public void testMeanIntVector2() {
198:                IntVector sortedData = new IntVector();
199:                sortedData.addElement(1);
200:                sortedData.addElement(1);
201:                sortedData.addElement(1);
202:                sortedData.addElement(3);
203:                sortedData.addElement(3);
204:                sortedData.addElement(5);
205:                sortedData.addElement(5);
206:                sortedData.addElement(7);
207:                sortedData.addElement(1000);
208:                double mean = new DescriptiveStatistic().mean(sortedData);
209:                assertTrue("Mean is not xx but " + mean, mean == 114.0);
210:
211:            }
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.