Added user guide sections for complex numbers and distributions.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141198 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brent Worden 2004-04-26 20:06:51 +00:00
parent 1d0286e297
commit ee53ecd19a
6 changed files with 208 additions and 73 deletions

View File

@ -47,6 +47,8 @@
<item name="Numerical Analysis" href="/userguide/analysis.html"/>
<item name="Special Functions" href="/userguide/special.html"/>
<item name="Utilities" href="/userguide/utilities.html"/>
<item name="Complex Numbers" href="/userguide/complex.html"/>
<item name="Distributions" href="/userguide/distribution.html"/>
</menu>
&common-menus;

View File

@ -0,0 +1,84 @@
<?xml version="1.0"?>
<!--
Copyright 2003-2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
<!-- $Revision: 1.1 $ $Date: 2004/04/26 20:06:50 $ -->
<document url="stat.html">
<properties>
<title>The Commons Math User Guide - Statistics</title>
</properties>
<body>
<section name="7 Complex Numbers">
<subsection name="7.1 Overview" href="overview">
<p>
The complex packages provides a complex number type as well as complex
versions of common transcendental functions and complex number
formatting.
</p>
</subsection>
<subsection name="7.2 Complex Numbers" href="complex">
<p>
<a href="../apidocs/org/apache/commons/math/complex/Complex.html">
org.apache.commons.math.complex.Complex</a> provides a complex number
type that forms the basis for the complex functionality found in
commons-math.
</p>
<p>
To create a complex number, simply call the constructor passing in two
floating-point arguments, the first being the real part of the
complex number and the second being the imaginary part:
<source>Complex c = new Complex(1.0, 3.0); // 1 + 3i</source>
</p>
<p>
The <code>Complex</code> class provides many unary and binary
complex number operations. These operations provide the means to add,
subtract, multiple and, divide complex numbers along with other
complex number functions similar to the real number functions found in
<code>java.math.BigDecimal</code>:
<source>Complex lhs = new Complex(1.0, 3.0);
Complex rhs = new Complex(2.0, 5.0);
Complex answer = lhs.add(rhs); // add two complex numbers
answer = lhs.subtract(rhs); // subtract two complex numbers
answer = lhs.abs(); // absolute value
answer = lhs.conjugate(rhs); // complex conjugate</source>
</p>
</subsection>
<subsection name="7.3 Complex Transcendental Functions" href="function">
<p>
<a href="../apidocs/org/apache/commons/math/complex/ComplexMath.html">
org.apache.commons.math.complex.ComplexMath</a> provides
implementations of serveral transcendental functions involving complex
number arguments. These operations provide the means to compute the
log, sine, tangent and, other complex values similar to the real
number functions found in <code>java.lang.Math</code>:
<source>Complex first = new Complex(1.0, 3.0);
Complex second = new Complex(2.0, 5.0);
Complex answer = ComplexMath.log(first); // natural logarithm.
answer = ComplexMath.cos(first); // cosine
answer = ComplexMath.pow(first, second); // first raised to the power of second</source>
</p>
</subsection>
<subsection name="7.4 Complex Formatting" href="formatting">
<p>This is yet to be written. Any contributions will be gratefully
accepted!</p>
</subsection>
</section>
</body>
</document>

View File

@ -0,0 +1,94 @@
<?xml version="1.0"?>
<!--
Copyright 2003-2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
<!-- $Revision: 1.1 $ $Date: 2004/04/26 20:06:50 $ -->
<document url="stat.html">
<properties>
<title>The Commons Math User Guide - Statistics</title>
</properties>
<body>
<section name="8 Probability Distributions">
<subsection name="8.1 Overview" href="overview">
<p>
The distributions package provide a framework for some commonly used
probability distributions.
</p>
</subsection>
<subsection name="8.2 Distribution Framework" href="distributions">
<p>
The distribution framework provides the means to compute probability density
function (PDF) probabilities and cumulative distribution function (CDF)
probabilities for common probability distributions. Along with the direct
computation of PDF and CDF probabilities, the framework also allows for the
computation of inverse PDF and inverse CDF values.
</p>
<p>
In order to use the distribution framework, first a distribution object must
be created. It is encouraged that all distribution object creation occurs via
the <code>org.apache.commons.math.distribution.DistributionFactory</code>
class. <code>DistributionFactory</code> is a simple factory used to create all
of the distribution objects supported by Commons-Math. The typical usage of
<code>DistributionFactory</code> to create a distribution object would be:
</p>
<source>DistributionFactory factory = DistributionFactory.newInstance();
BinomialDistribution binomial = factory.createBinomialDistribution(10, .75);</source>
<p>
The distributions that can be instantiated via the <code>DistributionFactory</code>
are detailed below:
<table>
<tr><th>Distribution</th><th>Factory Method</th><th>Parameters</th></tr>
<tr><td>Binomial</td><td>createBinomialDistribution</td><td><div>Number of trials</div><div>Probability of success</div></td></tr>
<tr><td>Chi-Squared</td><td>createChiSquaredDistribution</td><td><div>Degrees of freedom</div></td></tr>
<tr><td>Exponential</td><td>createExponentialDistribution</td><td><div>Mean</div></td></tr>
<tr><td>F</td><td>createFDistribution</td><td><div>Numerator degrees of freedom</div><div>Denominator degrees of freedom</div></td></tr>
<tr><td>Gamma</td><td>createGammaDistribution</td><td><div>Alpha</div><div>Beta</div></td></tr>
<tr><td>Hypergeometric</td><td>createHypogeometricDistribution</td><td><div>Population size</div><div>Number of successes in population</div><div>Sample size</div></td></tr>
<tr><td>Normal (Gaussian)</td><td>createNormalDistribution</td><td><div>Mean</div><div>Standard Deviation</div></td></tr>
<tr><td>t</td><td>createTDistribution</td><td><div>Degrees of freedom</div></td></tr>
</table>
</p>
<p>
Using a distribution object, PDF and CDF probabilities are easily computed
using the <code>cumulativeProbability</code> methods. For a distribution <code>X</code>,
and a domain value, <code>x</code>, <code>cumulativeProbability</code> computes
<code>P(X &lt;= x)</code> (i.e. the lower tail probability of <code>X</code>).
</p>
<source>DistributionFactory factory = DistributionFactory.newInstance();
TDistribution t = factory.createBinomialDistribution(29);
double lowerTail = t.cumulativeProbability(-2.656); // P(T &lt;= -2.656)
double upperTail = 1.0 - t.cumulativeProbability(2.75); // P(T &gt;= 2.75)</source>
<p>
The inverse PDF and CDF values are just as easily computed using the
<code>inverseCumulativeProbability</code>methods. For a distribution <code>X</code>,
and a probability, <code>p</code>, <code>inverseCumulativeProbability</code>
computes the domain value <code>x</code>, such that:
<ul>
<li><code>P(X &lt;= x) = p</code>, for continuous distributions</li>
<li><code>P(X &lt;= x) &lt;= p</code>, for discrete distributions</li>
</ul>
Notice the different cases for continuous and discrete distributions. This is the result
of PDFs not being invertible functions. As such, for discrete distributions, an exact
domain value can not be returned. Only the "best" domain value. For Commons-Math, the "best"
domain value is determined by the largest domain value whose cumulative probability is
less-than or equal to the given probability.
</p>
</subsection>
</section>
</body>
</document>

View File

@ -17,7 +17,7 @@
-->
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
<!-- $Revision: 1.7 $ $Date: 2004/02/29 21:25:08 $ -->
<!-- $Revision: 1.8 $ $Date: 2004/04/26 20:06:50 $ -->
<document url="index.html">
<properties>
<title>The Commons Math User Guide - Table of Contents</title>
@ -36,7 +36,7 @@
<li><a href="overview.html#dependencies">0.5 Dependencies</a></li>
</ul></li>
<li><a href="stat.html">1. Statistics and Distributions</a>
<li><a href="stat.html">1. Statistics</a>
<ul>
<li><a href="stat.html#overview">1.1 Overview</a></li>
<li><a href="stat.html#univariate">1.2 Univariate statistics</a></li>
@ -79,6 +79,18 @@
<li><a href="utilities.html#math_utils">6.4 binomial coefficients, factorials and other common math functions</a></li>
<li><a href="utilities.html#stat_utils">6.5 statistical computation utiliities</a></li>
</ul></li>
<li><a href="complex.html">7. Complex Numbers</a>
<ul>
<li><a href="complex.html#overview">7.1 Overview</a></li>
<li><a href="complex.html#complex">7.2 Complex Numbers</a></li>
<li><a href="complex.html#functions">7.3 Complex Transcendental Functions</a></li>
<li><a href="complex.html#formatting">7.4 Complex Formatting</a></li>
</ul></li>
<li><a href="distribution.html">8. Probability Distributions</a>
<ul>
<li><a href="distribution.html#overview">8.1 Overview</a></li>
<li><a href="distribution.html#distributions">8.2 Distribution Framework</a></li>
</ul></li>
</ul>
</section>

View File

@ -17,7 +17,7 @@
-->
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
<!-- $Revision: 1.9 $ $Date: 2004/04/25 17:12:05 $ -->
<!-- $Revision: 1.10 $ $Date: 2004/04/26 20:06:50 $ -->
<document>
<properties>
<title>User Guide - Overview</title>
@ -67,15 +67,18 @@
<subsection name="0.3 How commons-math is organized" href="organization">
<p>
Commons Math is divided into 6 subpackages, based on functionality provided.
<ol><li><a href="stat.html">org.apache.commons.math.stat</a> - statistics, statistical tests, probability distributions</li>
<li><a href="analysis.html">org.apache.commons.math.analysis</a> - rootfinding and interpolation</li>
<li><a href="random.html">org.apache.commons.math.random</a> - random numbers, strings and data generation</li>
<li><a href="special.html">org.apache.commons.math.special</a> - special functions (Gamma, Beta) </li>
<li><a href="linear.html">org.apache.commons.math.linear</a> - matrices, solving linear systems </li>
<li><a href="utilities.html">org.apache.commons.math.util</a> - common math/stat functions extending java.lang.Math </li>
</ol>
Package javadocs are <a href="../apidocs/index.html">here</a>
Commons Math is divided into eight subpackages, based on functionality provided.
<ol>
<li><a href="stat.html">org.apache.commons.math.stat</a> - statistics, statistical tests</li>
<li><a href="analysis.html">org.apache.commons.math.analysis</a> - rootfinding and interpolation</li>
<li><a href="random.html">org.apache.commons.math.random</a> - random numbers, strings and data generation</li>
<li><a href="special.html">org.apache.commons.math.special</a> - special functions (Gamma, Beta) </li>
<li><a href="linear.html">org.apache.commons.math.linear</a> - matrices, solving linear systems </li>
<li><a href="utilities.html">org.apache.commons.math.util</a> - common math/stat functions extending java.lang.Math </li>
<li><a href="complex.html">org.apache.commons.math.complex</a> - complex numbers</li>
<li><a href="distribution.html">org.apache.commons.math.distribution</a> - probability distributions</li>
</ol>
Package javadocs are <a href="../apidocs/index.html">here</a>
</p>
</subsection>

View File

@ -17,7 +17,7 @@
-->
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
<!-- $Revision: 1.15 $ $Date: 2004/04/26 05:16:35 $ -->
<!-- $Revision: 1.16 $ $Date: 2004/04/26 20:06:50 $ -->
<document url="stat.html">
<properties>
<title>The Commons Math User Guide - Statistics</title>
@ -345,66 +345,6 @@ System.out.println(regression.getSlopeStdErr()); // displays slope standard erro
<p>This is yet to be written. Any contributions will be gratefully
accepted!</p>
</subsection>
<subsection name="1.6 Distribution framework" href="distributions">
<p>
The distribution framework provides the means to compute probability density
function (PDF) probabilities and cumulative distribution function (CDF)
probabilities for common probability distributions. Along with the direct
computation of PDF and CDF probabilities, the framework also allows for the
computation of inverse PDF and inverse CDF values.
</p>
<p>
In order to use the distribution framework, first a distribution object must
be created. It is encouraged that all distribution object creation occurs via
the <code>org.apache.commons.math.stat.distribution.DistributionFactory</code>
class. <code>DistributionFactory</code> is a simple factory used to create all
of the distribution objects supported by Commons-Math. The typical usage of
<code>DistributionFactory</code> to create a distribution object would be:
</p>
<source>DistributionFactory factory = DistributionFactory.newInstance();
BinomialDistribution binomial = factory.createBinomialDistribution(10, .75);</source>
<p>
The distributions that can be instantiated via the <code>DistributionFactory</code>
are detailed below:
<table>
<tr><th>Distribution</th><th>Factory Method</th><th>Parameters</th></tr>
<tr><td>Binomial</td><td>createBinomialDistribution</td><td><div>Number of trials</div><div>Probability of success</div></td></tr>
<tr><td>Chi-Squared</td><td>createChiSquaredDistribution</td><td><div>Degrees of freedom</div></td></tr>
<tr><td>Exponential</td><td>createExponentialDistribution</td><td><div>Mean</div></td></tr>
<tr><td>F</td><td>createFDistribution</td><td><div>Numerator degrees of freedom</div><div>Denominator degrees of freedom</div></td></tr>
<tr><td>Gamma</td><td>createGammaDistribution</td><td><div>Alpha</div><div>Beta</div></td></tr>
<tr><td>Hypergeometric</td><td>createHypogeometricDistribution</td><td><div>Population size</div><div>Number of successes in population</div><div>Sample size</div></td></tr>
<tr><td>Normal (Gaussian)</td><td>createNormalDistribution</td><td><div>Mean</div><div>Standard Deviation</div></td></tr>
<tr><td>t</td><td>createTDistribution</td><td><div>Degrees of freedom</div></td></tr>
</table>
</p>
<p>
Using a distribution object, PDF and CDF probabilities are easily computed
using the <code>cumulativeProbability</code> methods. For a distribution <code>X</code>,
and a domain value, <code>x</code>, <code>cumulativeProbability</code> computes
<code>P(X &lt;= x)</code> (i.e. the lower tail probability of <code>X</code>).
</p>
<source>DistributionFactory factory = DistributionFactory.newInstance();
TDistribution t = factory.createBinomialDistribution(29);
double lowerTail = t.cumulativeProbability(-2.656); // P(T &lt;= -2.656)
double upperTail = 1.0 - t.cumulativeProbability(2.75); // P(T &gt;= 2.75)</source>
<p>
The inverse PDF and CDF values are just as easily computed using the
<code>inverseCumulativeProbability</code>methods. For a distribution <code>X</code>,
and a probability, <code>p</code>, <code>inverseCumulativeProbability</code>
computes the domain value <code>x</code>, such that:
<ul>
<li><code>P(X &lt;= x) = p</code>, for continuous distributions</li>
<li><code>P(X &lt;= x) &lt;= p</code>, for discrete distributions</li>
</ul>
Notice the different cases for continuous and discrete distributions. This is the result
of PDFs not being invertible functions. As such, for discrete distributions, an exact
domain value can not be returned. Only the "best" domain value. For Commons-Math, the "best"
domain value is determined by the largest domain value whose cumulative probability is
less-than or equal to the given probability.
</p>
</subsection>
</section>
</body>
</document>