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


001:        /*
002:         * Copyright 2005 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:
017:        package org.apache.commons.math.distribution;
018:
019:        import java.io.Serializable;
020:
021:        /**
022:         * Default implementation of
023:         * {@link org.apache.commons.math.distribution.WeibullDistribution}.
024:         *
025:         * @since 1.1
026:         * @version $Revision: 1.13 $ $Date: 2004-07-24 16:41:37 -0500 (Sat, 24 Jul 2004) $
027:         */
028:        public class WeibullDistributionImpl extends
029:                AbstractContinuousDistribution implements  WeibullDistribution,
030:                Serializable {
031:
032:            /** Serializable version identifier */
033:            private static final long serialVersionUID = 8589540077390120676L;
034:
035:            /** The shape parameter. */
036:            private double alpha;
037:
038:            /** The scale parameter. */
039:            private double beta;
040:
041:            /**
042:             * Creates weibull distribution with the given shape and scale and a
043:             * location equal to zero.
044:             * @param alpha the shape parameter.
045:             * @param beta the scale parameter.
046:             */
047:            public WeibullDistributionImpl(double alpha, double beta) {
048:                super ();
049:                setShape(alpha);
050:                setScale(beta);
051:            }
052:
053:            /**
054:             * For this disbution, X, this method returns P(X &lt; <code>x</code>).
055:             * @param x the value at which the CDF is evaluated.
056:             * @return CDF evaluted at <code>x</code>. 
057:             */
058:            public double cumulativeProbability(double x) {
059:                double ret;
060:                if (x <= 0.0) {
061:                    ret = 0.0;
062:                } else {
063:                    ret = 1.0 - Math.exp(-Math.pow(x / getScale(), getShape()));
064:                }
065:                return ret;
066:            }
067:
068:            /**
069:             * Access the shape parameter.
070:             * @return the shape parameter.
071:             */
072:            public double getShape() {
073:                return alpha;
074:            }
075:
076:            /**
077:             * Access the scale parameter.
078:             * @return the scale parameter.
079:             */
080:            public double getScale() {
081:                return beta;
082:            }
083:
084:            /**
085:             * For this distribution, X, this method returns the critical point x, such
086:             * that P(X &lt; x) = <code>p</code>.
087:             * <p>
088:             * Returns <code>Double.NEGATIVE_INFINITY</code> for p=0 and 
089:             * <code>Double.POSITIVE_INFINITY</code> for p=1.
090:             *
091:             * @param p the desired probability
092:             * @return x, such that P(X &lt; x) = <code>p</code>
093:             * @throws IllegalArgumentException if <code>p</code> is not a valid
094:             *         probability.
095:             */
096:            public double inverseCumulativeProbability(double p) {
097:                double ret;
098:                if (p < 0.0 || p > 1.0) {
099:                    throw new IllegalArgumentException(
100:                            "probability argument must be between 0 and 1 (inclusive)");
101:                } else if (p == 0) {
102:                    ret = 0.0;
103:                } else if (p == 1) {
104:                    ret = Double.POSITIVE_INFINITY;
105:                } else {
106:                    ret = getScale()
107:                            * Math.pow(-Math.log(1.0 - p), 1.0 / getShape());
108:                }
109:                return ret;
110:            }
111:
112:            /**
113:             * Modify the shape parameter.
114:             * @param alpha the new shape parameter value.
115:             */
116:            public void setShape(double alpha) {
117:                if (alpha <= 0.0) {
118:                    throw new IllegalArgumentException(
119:                            "Shape must be positive.");
120:                }
121:                this .alpha = alpha;
122:            }
123:
124:            /**
125:             * Modify the scale parameter.
126:             * @param beta the new scale parameter value.
127:             */
128:            public void setScale(double beta) {
129:                if (beta <= 0.0) {
130:                    throw new IllegalArgumentException(
131:                            "Scale must be positive.");
132:                }
133:                this .beta = beta;
134:            }
135:
136:            /**
137:             * Access the domain value lower bound, based on <code>p</code>, used to
138:             * bracket a CDF root.  This method is used by
139:             * {@link #inverseCumulativeProbability(double)} to find critical values.
140:             * 
141:             * @param p the desired probability for the critical value
142:             * @return domain value lower bound, i.e.
143:             *         P(X &lt; <i>lower bound</i>) &lt; <code>p</code> 
144:             */
145:            protected double getDomainLowerBound(double p) {
146:                return 0.0;
147:            }
148:
149:            /**
150:             * Access the domain value upper bound, based on <code>p</code>, used to
151:             * bracket a CDF root.  This method is used by
152:             * {@link #inverseCumulativeProbability(double)} to find critical values.
153:             * 
154:             * @param p the desired probability for the critical value
155:             * @return domain value upper bound, i.e.
156:             *         P(X &lt; <i>upper bound</i>) &gt; <code>p</code> 
157:             */
158:            protected double getDomainUpperBound(double p) {
159:                return Double.MAX_VALUE;
160:            }
161:
162:            /**
163:             * Access the initial domain value, based on <code>p</code>, used to
164:             * bracket a CDF root.  This method is used by
165:             * {@link #inverseCumulativeProbability(double)} to find critical values.
166:             * 
167:             * @param p the desired probability for the critical value
168:             * @return initial domain value
169:             */
170:            protected double getInitialDomain(double p) {
171:                // use median
172:                return Math.pow(getScale() * Math.log(2.0), 1.0 / getShape());
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.