alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Commons Math example source code file (distribution.xml)

This example Commons Math source code file (distribution.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Commons Math tags/keywords

apache, cdf, cdf, commons-math, distributions, for, license, license, notice, p, pdf, pdf, the, the

The Commons Math distribution.xml source code

<?xml version="1.0"?>

<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You 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: 925826 $ $Date: 2010-03-21 13:01:31 -0400 (Sun, 21 Mar 2010) $ -->
<document url="stat.html">
  <properties>
    <title>The Commons Math User Guide - Statistics
  </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>
          Using a distribution object, PDF and CDF probabilities are easily computed
          using the <code>cumulativeProbability methods.  For a distribution X,
          and a domain value, <code>x,  cumulativeProbability computes
          <code>P(X <= x) (i.e. the lower tail probability of X).
        </p>
<source>TDistribution t = new TDistributionImpl(29);
double lowerTail = t.cumulativeProbability(-2.656);     // P(T <= -2.656)
double upperTail = 1.0 - t.cumulativeProbability(2.75); // P(T >= 2.75)</source>
        <p>
          The inverse PDF and CDF values are just as easily computed using the
          <code>inverseCumulativeProbability methods.  For a distribution X,
          and a probability, <code>p, inverseCumulativeProbability
          computes the domain value <code>x, such that:
          <ul>
            <li>P(X <= x) = p, for continuous distributions
            <li>P(X <= x) <= p, for discrete distributions
          </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>
      <subsection name="8.3 User Defined Distributions" href="userdefined">
        <p>
        Since there are numerous distributions and Commons-Math only directly supports a handful,
        it may be necessary to extend the distribution framework to satisfy individual needs.  It
        is recommended that the <code>Distribution, ContinuousDistribution,
        <code>DiscreteDistribution, and IntegerDistribution interfaces serve as
        base types for any extension.  These serve as the basis for all the distributions directly
        supported by Commons-Math and using those interfaces for implementation purposes will
        insure any extension is compatible with the remainder of Commons-Math.  To aid in
        implementing a distribution extension, the <code>AbstractDistribution,
        <code>AbstractContinuousDistribution, and AbstractIntegerDistribution
        provide implementation building blocks and offer a lot of default distribution
        functionality.  By extending these abstract classes directly, a good portion of the
        repetitive distribution implementation is already developed and should save time and effort
        in developing user defined distributions.
        </p>
      </subsection>
    </section>
  </body>
</document>

Other Commons Math examples (source code examples)

Here is a short list of links related to this Commons Math distribution.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.