diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index b7c59a3d8..f9d833674 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -4,6 +4,9 @@ # http://www.boost.org/LICENSE_1_0.txt. import testing ; +import pch ; + +cpp-pch pch : ../src/tr1/pch.hpp : ../src/tr1 shared:BOOST_MATH_TR1_DYN_LINK=1 ; C99_SOURCES = acosh asinh @@ -56,40 +59,44 @@ if --disable-long-double in [ modules.peek : ARGV ] long-double-opts = no ; } -compile has_long_double_support.cpp : $(long-double-opts) ; - -lib boost_math_tr1 : ../src/tr1/$(TR1_SOURCES).cpp +lib boost_math_tr1 : ../src/tr1/$(TR1_SOURCES).cpp pch : shared:BOOST_MATH_TR1_DYN_LINK=1 + ../src/tr1 ; -lib boost_math_tr1f : ../src/tr1/$(TR1_SOURCES)f.cpp +lib boost_math_tr1f : ../src/tr1/$(TR1_SOURCES)f.cpp pch : shared:BOOST_MATH_TR1_DYN_LINK=1 + ../src/tr1 ; -lib boost_math_tr1l : ../src/tr1/$(TR1_SOURCES)l.cpp +lib boost_math_tr1l : ../src/tr1/$(TR1_SOURCES)l.cpp pch : shared:BOOST_MATH_TR1_DYN_LINK=1 - has_long_double_support - $(long-double-opts) + ../config//has_long_double_support + ../src/tr1 + $(long-double-opts) ; -lib boost_math_c99 : ../src/tr1/$(C99_SOURCES).cpp +lib boost_math_c99 : ../src/tr1/$(C99_SOURCES).cpp pch : shared:BOOST_MATH_TR1_DYN_LINK=1 + ../src/tr1 ; -lib boost_math_c99f : ../src/tr1/$(C99_SOURCES)f.cpp +lib boost_math_c99f : ../src/tr1/$(C99_SOURCES)f.cpp pch : shared:BOOST_MATH_TR1_DYN_LINK=1 + ../src/tr1 ; -lib boost_math_c99l : ../src/tr1/$(C99_SOURCES)l.cpp +lib boost_math_c99l : ../src/tr1/$(C99_SOURCES)l.cpp pch : shared:BOOST_MATH_TR1_DYN_LINK=1 - has_long_double_support - $(long-double-opts) + ../config//has_long_double_support + ../src/tr1 + $(long-double-opts) ; diff --git a/config/Jamfile.v2 b/config/Jamfile.v2 new file mode 100644 index 000000000..78e7c657e --- /dev/null +++ b/config/Jamfile.v2 @@ -0,0 +1,20 @@ +# copyright John Maddock 2008 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt. + +import modules ; +import path ; + +local ntl-path = [ modules.peek : NTL_PATH ] ; +local gmp_path = [ modules.peek : GMP_PATH ] ; + +obj has_long_double_support : has_long_double_support.cpp ; +obj has_mpfr_class : has_mpfr_class.cpp : + $(gmp_path) $(gmp_path)/mpfr $(gmp_path)/gmpfrxx ; +obj has_ntl_rr : has_ntl_rr.cpp : $(ntl-path)/include ; + + + + + diff --git a/build/has_long_double_support.cpp b/config/has_long_double_support.cpp similarity index 100% rename from build/has_long_double_support.cpp rename to config/has_long_double_support.cpp diff --git a/config/has_mpfr_class.cpp b/config/has_mpfr_class.cpp new file mode 100644 index 000000000..8eb3c7b26 --- /dev/null +++ b/config/has_mpfr_class.cpp @@ -0,0 +1,14 @@ +// Copyright John Maddock 2008. +// Copyright Paul A. Britow 2009 +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifdef _MSC_VER +# pragma warning (disable : 4127) // conditional expression is constant +# pragma warning (disable : 4800) // 'int' : forcing value to bool 'true' or 'false' (performance warning) +# pragma warning (disable : 4512) // assignment operator could not be generated +#endif + +#include + diff --git a/config/has_ntl_rr.cpp b/config/has_ntl_rr.cpp new file mode 100644 index 000000000..f3844217e --- /dev/null +++ b/config/has_ntl_rr.cpp @@ -0,0 +1,12 @@ +// Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#ifdef _MSC_VER +# pragma warning (disable : 4100) // unreferenced formal parameter +#endif + +#include + diff --git a/doc/complex/Jamfile.v2 b/doc/complex/Jamfile.v2 index f43fb240f..3e1556067 100644 --- a/doc/complex/Jamfile.v2 +++ b/doc/complex/Jamfile.v2 @@ -62,7 +62,6 @@ boostbook standalone pdf:use.role.for.mediaobject=1 pdf:preferred.mediaobject.role=print pdf:img.src.path=$(images_location)/ - pdf:admon.graphics.path=$(images_location)/../../svg-admon/ pdf:draft.mode="no" ; @@ -78,3 +77,5 @@ boostbook standalone + + diff --git a/doc/distexplorer/Jamfile.v2 b/doc/distexplorer/Jamfile.v2 new file mode 100644 index 000000000..a1474dc2d --- /dev/null +++ b/doc/distexplorer/Jamfile.v2 @@ -0,0 +1,60 @@ +# Copyright Paul A. Bristow 2008 +# Copyright John Maddock 2008 + +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt +# or copy at http://www.boost.org/LICENSE_1_0.txt) + +# Reminder: whitespace MUST terminate variable name! +# so space BEFORE ; and : + +# Distexplorer documentation as html from Quickbook. + +# project boost/doc ; + +using quickbook ; + +#path-constant images_location : html ; +# location of SVG images referenced by Quickbook. +# screenshots installed as recomended by Sourceforge. + +xml distexplorer + : + distexplorer.qbk + : +; + +# import boostbook : boostbook ; + +boostbook standalone + : + distexplorer + : + # Path for links to Boost: + boost.root=../../../../.. + # Path for libraries index: + boost.libraries=../../../../../libs/libraries.htm + # Use the main Boost stylesheet: + html.stylesheet=../../../../../doc/html/boostbook.css + + # Some general style settings: + table.footnote.number.format=1 + footnote.number.format=1 + + # HTML options first: + # Use graphics not text for navigation: + navig.graphics=1 + # How far down we chunk nested sections, basically all of them: + chunk.section.depth=10 + # Don't put the first section on the same page as the TOC: + chunk.first.sections=1 + # How far down sections get TOC's + toc.section.depth=10 + # Max depth in each TOC: + toc.max.depth=4 + # How far down we go with TOC's + generate.section.toc.level=10 + #root.filename="distexplorer" +; + + diff --git a/doc/distexplorer/distexplorer.qbk b/doc/distexplorer/distexplorer.qbk new file mode 100644 index 000000000..f76ef7fca --- /dev/null +++ b/doc/distexplorer/distexplorer.qbk @@ -0,0 +1,105 @@ +[article Statistical Distribution Explorer + [quickbook 1.4] + [copyright 2008 Paul A. Bristow, John Maddock] + [license + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + [@http://www.boost.org/LICENSE_1_0.txt]) + ] + [authors [Bristow, Paul A.], [Maddock, John]] + [category math] + [purpose mathematics] + [/last-revision $Date$] +] + +A Windows utility to show the properties of statistical distributions +using parameters provided interactively by the user. + +The distributions provided are: + +*bernoulli +*beta_distribution +*binomial_distribution +*cauchy +*chi_squared +*exponential +*extreme_value +*fisher_f +*gamma_distribution +*lognormal_distribution +*negative_binomial_distribution +*normal_distribution +*pareto +*poisson +*rayleigh +*students_t +*triangular +*uniform +*weibull + +Properties of distributions computed are: + +*mean +*mode +*median +*variance +*standard deviation +*coefficient of variation, +*skewness +*kurtosis +*excess +*range supported + +Calculated, from values provided, are: + +*probability density (or mass) function (PDF) +*cumulative distribution function (CDF), and complement +*Quantiles (percentiles) are calculated for typical risk (alpha) probabilities (0.001, 0.01, 0.5, 0.1, 0.333) +and for additional probabilities provided by the user. + +Results can be saved to text files using Save or SaveAs. +All the values on the four tabs are output to the file chosen, +and are tab separated to assist input to other programs, +for example, spreadsheets or text editors. + +Note: Excel (for example), only shows 10 decimal digits, by default: +to display the maximum possible precision (abotu 15 decimal digits), +it is necessary to format all cells to display this precision. +Although unusually accurate, not all values computed by Distexplorer will be as accurate as this. +Values shown as NaN cannot be calculated from the value(s) given, +most commonly because the value input is outside the range for the distribution. + +For more information, including downloads, see + +[@http://distexplorer.sourceforge.net/ Distexplorer at Sourceforge] + +This Microsoft Windows 32 package distribution.exe +was generated from a C# program +and uses a boost_math.dll generated using the +Boost.Math C++ source code from the Boost.Math Toolkit, compiled in CLI mode, +containing the underlying statistical distribution classes and functions. + +All source code is freely available for view and use under the +[@http://www.boost.org/LICENSE_1_0.txt Boost Open Source License]. + +[@https://svn.boost.org/svn/boost/sandbox\math_toolkit\libs\math\dot_net_example +Math Toolkit C++ source code] +to produce boost_math.dll is in the most recent [@http://www.boost.org Boost] release, initially 1.35.0. + +It is distributed as a single Windows Installer package Setupdistex.msi. +Unzip the distexplorer.zip to a temporary location of your choice and run setup.exe. + +(Note that .NET framework 2.0 and VCredist are requirements for this program. +Most recent and updated Windows environments will already have these, +but they are quickly, easily and safely installed from the Microsoft site if required.) + +(The package cannot be run on other platforms at present but it should be possible +to build an equivalent utility on any C/C++ platform if anyone would like to undertake this task.) + +[/ Distexplorer.qbk + Copyright 2008 John Maddock and Paul A. Bristow. + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +] + diff --git a/doc/distexplorer/html/index.html b/doc/distexplorer/html/index.html new file mode 100644 index 000000000..0a21d5ffe --- /dev/null +++ b/doc/distexplorer/html/index.html @@ -0,0 +1,216 @@ + + + +Statistical Distribution Explorer + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+
+
+
+

+Statistical Distribution Explorer

+
+

+Paul A. Bristow +

+

+John Maddock +

+
+
+
+

+ Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +

+
+
+
+
+

+ A Windows utility to show the properties of statistical distributions using parameters + provided interactively by the user. +

+

+ The distributions provided are: +

+
    +
  • + bernoulli +
  • +
  • + beta_distribution +
  • +
  • + binomial_distribution +
  • +
  • + cauchy +
  • +
  • + chi_squared +
  • +
  • + exponential +
  • +
  • + extreme_value +
  • +
  • + fisher_f +
  • +
  • + gamma_distribution +
  • +
  • + lognormal_distribution +
  • +
  • + negative_binomial_distribution +
  • +
  • + normal_distribution +
  • +
  • + pareto +
  • +
  • + poisson +
  • +
  • + rayleigh +
  • +
  • + students_t +
  • +
  • + triangular +
  • +
  • + uniform +
  • +
  • + weibull +
  • +
+

+ Properties of distributions computed are: +

+
    +
  • + mean +
  • +
  • + mode +
  • +
  • + median +
  • +
  • + variance +
  • +
  • + standard deviation +
  • +
  • + coefficient of variation, +
  • +
  • + skewness +
  • +
  • + kurtosis +
  • +
  • + excess +
  • +
  • + range supported +
  • +
+

+ Calculated, from values provided, are: +

+
    +
  • + probability density (or mass) function (PDF) +
  • +
  • + cumulative distribution function (CDF), and complement +
  • +
  • + Quantiles (percentiles) are calculated for typical risk (alpha) probabilities + (0.001, 0.01, 0.5, 0.1, 0.333) and for additional probabilities provided by + the user. +
  • +
+

+ Results can be saved to text files using Save or SaveAs. All the values on the + four tabs are output to the file chosen, and are tab separated to assist input + to other programs, for example, spreadsheets or text editors. +

+

+ Note: Excel (for example), only shows 10 decimal digits, by default: to display + the maximum possible precision (abotu 15 decimal digits), it is necessary to + format all cells to display this precision. Although unusually accurate, not + all values computed by Distexplorer will be as accurate as this. Values shown + as NaN cannot be calculated from the value(s) given, most commonly because the + value input is outside the range for the distribution. +

+

+ For more information, including downloads, see +

+

+ Distexplorer at Sourceforge +

+

+ This Microsoft Windows 32 package distribution.exe was generated from a C# program + and uses a boost_math.dll generated using the Boost.Math C++ source code from + the Boost.Math Toolkit, compiled in CLI mode, containing the underlying statistical + distribution classes and functions. +

+

+ All source code is freely available for view and use under the Boost + Open Source License. +

+

+ Math + Toolkit C++ source code to produce boost_math.dll is in the most recent + Boost release, initially 1.35.0. +

+

+ It is distributed as a single Windows Installer package Setupdistex.msi. Unzip + the distexplorer.zip to a temporary location of your choice and run setup.exe. +

+

+ (Note that .NET framework 2.0 and VCredist are requirements for this program. + Most recent and updated Windows environments will already have these, but they + are quickly, easily and safely installed from the Microsoft site if required.) +

+

+ (The package cannot be run on other platforms at present but it should be possible + to build an equivalent utility on any C/C++ platform if anyone would like to + undertake this task.) +

+
+ + + +

Last revised: February 26, 2009 at 17:08:18 GMT

+
+
+ + diff --git a/doc/gcd/Jamfile.v2 b/doc/gcd/Jamfile.v2 index c7c1361bb..a714bf36b 100644 --- a/doc/gcd/Jamfile.v2 +++ b/doc/gcd/Jamfile.v2 @@ -62,7 +62,6 @@ boostbook standalone pdf:use.role.for.mediaobject=1 pdf:preferred.mediaobject.role=print pdf:img.src.path=$(images_location)/ - pdf:admon.graphics.path=$(images_location)/../../svg-admon/ pdf:draft.mode="no" pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/libs/math/doc/gcd/html ; diff --git a/doc/octonion/Jamfile.v2 b/doc/octonion/Jamfile.v2 index a65abe233..30f206ac8 100644 --- a/doc/octonion/Jamfile.v2 +++ b/doc/octonion/Jamfile.v2 @@ -62,7 +62,6 @@ boostbook standalone pdf:use.role.for.mediaobject=1 pdf:preferred.mediaobject.role=print pdf:img.src.path=$(images_location)/ - pdf:admon.graphics.path=$(images_location)/../../svg-admon/ pdf:draft.mode="no" pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/libs/math/doc/octonion/html ; diff --git a/doc/quaternion/Jamfile.v2 b/doc/quaternion/Jamfile.v2 index 90a258ce9..5b65a19e7 100644 --- a/doc/quaternion/Jamfile.v2 +++ b/doc/quaternion/Jamfile.v2 @@ -62,7 +62,6 @@ boostbook standalone pdf:use.role.for.mediaobject=1 pdf:preferred.mediaobject.role=print pdf:img.src.path=$(images_location)/ - pdf:admon.graphics.path=$(images_location)/../../svg-admon/ pdf:draft.mode="no" pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/libs/math/doc/quaternion/html ; diff --git a/doc/sf_and_dist/Jamfile.v2 b/doc/sf_and_dist/Jamfile.v2 index 1a28f7b2e..477112a03 100644 --- a/doc/sf_and_dist/Jamfile.v2 +++ b/doc/sf_and_dist/Jamfile.v2 @@ -36,7 +36,12 @@ boostbook standalone toc.max.depth=4 # How far down we go with TOC's generate.section.toc.level=10 + # Index on type: + index.on.type=1 + #root.filename="sf_dist_and_tools" + #graphicsize.extension=1 + #use.extensions=1 # PDF Options: # TOC Generation: this is needed for FOP-0.9 and later: @@ -62,10 +67,9 @@ boostbook standalone pdf:use.role.for.mediaobject=1 pdf:preferred.mediaobject.role=print pdf:img.src.path=$(images_location)/ - pdf:admon.graphics.path=$(images_location)/../../svg-admon/ pdf:draft.mode="no" pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/libs/math/doc/sf_and_dist/html ; - +install pdf-install : standalone : . PDF ; diff --git a/doc/sf_and_dist/building.qbk b/doc/sf_and_dist/building.qbk new file mode 100644 index 000000000..bc133550e --- /dev/null +++ b/doc/sf_and_dist/building.qbk @@ -0,0 +1,101 @@ +[section:building If and How to Build the Library and its Examples and Tests] + +[h4 Building the Library] + +The first thing you need to ask yourself is "Do I need to build anything at all?" +as the bulk of this library is header only: meaning you can use it just by +#including the necessary header(s). Refer to +[link math_toolkit.extern_c C99 and C++ TR1 C-style Functions] +for pros and cons of using +the TR1 components as opposed to the header only ones. + +The ['only] time you ['need] to build the library is if you want to use the +`extern "C"` functions declared in ``. To build this +using Boost.Build, from a commandline boost-root directory issue a command like: + + bjam toolset=gcc --with-math install + +will do the job on Linux, while: + + bjam toolset=msvc --with-math --build-type=complete stage + +will work better on Windows (leaving libraries built +in sub-folder `/stage` below your Boost root directory). +Either way you should consult the +[@http://www.boost.org/doc/libs/release/more/getting_started/index.html +getting started guide] for more information. + +You can also build the libraries from your favourite IDE or command line tool: +each `extern "C"` function declared in `` has its own +source file with the same name in `libs/math/src/tr1`. Just select the +sources corresponding to the functions you are using and build them into +a library, or else add them directly to your project. Note that the +directory `libs/math/src/tr1` will need to be in your compiler's +#include path as well as the boost-root directory +(MSVC Tools, Options, Projects and Solutions, VC++ Directories, Include files). + +[note If you are using +a Windows compiler that supports auto-linking and you have built the sources +yourself (or added them directly to your project) then you will need to +prevent `` from trying to auto-link to the binaries +that Boost.Build generates. You can do this by defining either +BOOST_MATH_NO_LIB or BOOST_ALL_NO_LIB at project level +(so the defines get passed to each compiler invocation). +] + +Optionally the sources in `libs/math/src/tr1` have support for using +`libs/math/src/tr1/pch.hpp` as a precompiled header +['if your compiler supports precompiled headers.] Note that normally +this header is a do-nothing include: to activate the header so that +it #includes everything required by all the sources you will need to +define BOOST_BUILD_PCH_ENABLED on the command line, both when building +the pre-compiled header and when building the sources. Boost.Build +will do this automatically when appropriate. + +[h4 Building the Examples] + +The examples are all located in `libs/math/example`, they can all +be built without reference to any external libraries, either with +Boost.Build using the supplied Jamfile, or from your compiler's +command line. The only requirement is that the Boost headers are +in your compilers #include search path. + +[h4 Building the Tests] + +The tests are located in `libs/math/test` and are best built +using Boost.Build and the supplied Jamfile. If you plan to +build them separately from your favourite IDE then you will +need to add `libs/math/test` to the list of your compiler's +search paths. + +You will also need to build and link to +the Boost.Regex library for many of the tests: this can built +from the command line by following the +[@http://www.boost.org/doc/libs/release/more/getting_started/index.html +getting started guide], using a command such as: + + bjam toolset=gcc --with-regex install + +or + + bjam toolset=msvc --with-regex --build-type=complete stage + +depending on whether you are on Linux or Windows. + +Many of the tests have optional precompiled header support +using the header `libs/math/test/pch.hpp`. +Note that normally +this header is a do-nothing include: to activate the header so that +it #includes everything required by all the sources you will need to +define BOOST_BUILD_PCH_ENABLED on the command line, both when building +the pre-compiled header and when building the sources. Boost.Build +will do this automatically when appropriate. + +[endsect] + +[/ building.qbk + Copyright 2006, 2007, 2008 John Maddock and Paul A. Bristow. + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +] diff --git a/doc/sf_and_dist/c99_ref.qbk b/doc/sf_and_dist/c99_ref.qbk index dd90e37a6..d58774c7e 100644 --- a/doc/sf_and_dist/c99_ref.qbk +++ b/doc/sf_and_dist/c99_ref.qbk @@ -286,6 +286,8 @@ Returns /x/ truncated to the nearest integer. See also __trunc for the full template (header only) version of this function. +See also [@http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf C99 ISO Standard] + [endsect] [/ diff --git a/doc/sf_and_dist/common_overviews.qbk b/doc/sf_and_dist/common_overviews.qbk index 4ba048323..236331ca9 100644 --- a/doc/sf_and_dist/common_overviews.qbk +++ b/doc/sf_and_dist/common_overviews.qbk @@ -61,7 +61,7 @@ of breed" algorithms as many other libraries: the principle difference is that this library is implemented in C++ - taking advantage of all the abstraction mechanisms that C++ offers - where as most traditional numeric libraries are implemented in C or FORTRAN. Traditionally -languages such as C or FORTAN are perceived as easier to optimise +languages such as C or FORTRAN are perceived as easier to optimise than more complex languages like C++, so in a sense this library provides a good test of current compiler technology, and the "abstraction penalty" - if any - of C++ compared to other languages. diff --git a/doc/sf_and_dist/concepts.qbk b/doc/sf_and_dist/concepts.qbk index 3345006c7..775345154 100644 --- a/doc/sf_and_dist/concepts.qbk +++ b/doc/sf_and_dist/concepts.qbk @@ -14,17 +14,58 @@ replacement for the "real" NTL::RR that adds some syntactic sugar to keep this library happy, plus some of the standard library functions not implemented in NTL. -Finally there is a high precision __lanczos suitable for use with `boost::math::ntl::RR`, -used at 1000-bit precision in -[@../../../tools/ntl_rr_lanczos.hpp libs/math/tools/ntl_rr_lanczos.hpp]. -The approximation has a theoretical precision of > 90 decimal digits, -and an experimental precision of > 100 decimal digits. To use that -approximation, just include that header before any of the special -function headers (if you don't use it, you'll get a slower, but -fully generic implementation for all of the gamma-like functions). +For those functions that are based upon the __lanczos, the bindings +defines a series of approximations with up to 61 terms and accuracy +up to approximately 3e-113. This therefore sets the upper limit for accuracy +to the majority of functions defined this library when used with `NTL::RR`. + +There is a concept checking test program for NTL support +[@../../../../../libs/math/test/ntl_concept_check.cpp here]. [endsect][/section:use_ntl Using With NTL - a High Precision Floating-Point Library] +[section:use_mpfr Using With MPFR / GMP - a High-Precision Floating-Point Library] + +The special functions and tools in this library can be used with +[@http://www.mpfr.org MPFR (an arbitrary precision number type based on the GMP library)], +via the bindings in [@../../../../../boost/math/bindings/mpfr.hpp boost/math/bindings/mpfr.hpp]. + +In order to use these binings you will need to have installed [@http://www.mpfr.org MPFR] +plus it's dependency the [@http://gmplib.org GMP library] and the C++ wrapper for MPFR known as +[@http://math.berkeley.edu/~wilken/code/gmpfrxx/ gmpfrxx (or mpfr_class)]. + +Unfortunately `mpfr_class` doesn't quite satisfy our conceptual requirements, +so there is a very thin set of additional interfaces and some helper traits defined in +[@../../../../../boost/math/bindings/mpfr.hpp boost/math/bindings/mpfr.hpp] that you +should use in place of including 'gmpfrxx.h' directly. The existing mpfr_class is +then usable unchanged once this header is included, so it's performance-enhancing +expression templates are preserved and fully supported by this library: + + #include + #include + + int main() + { + mpfr_class::set_dprec(500); // 500 bit precision + // + // Note that the argument to tgamma is an expression template, + // that's just fine here: + // + mpfr_class v = boost::math::tgamma(sqrt(mpfr_class(2))); + std::cout << std::setprecision(50) << v << std::endl; + } + + +For those functions that are based upon the __lanczos, the bindings +defines a series of approximations with up to 61 terms and accuracy +up to approximately 3e-113. This therefore sets the upper limit for accuracy +to the majority of functions defined this library when used with `mpfr_class`. + +There is a concept checking test program for mpfr support +[@../../../../../libs/math/test/mpfr_concept_check.cpp here]. + +[endsect][/section:use_mpfr Using With MPFR / GMP - a High-Precision Floating-Point Library] + [section:concepts Conceptual Requirements for Real Number Types] The functions, and statistical distributions in this library can be used with diff --git a/doc/sf_and_dist/credits.qbk b/doc/sf_and_dist/credits.qbk index 0cea15f5b..bc708e7ae 100644 --- a/doc/sf_and_dist/credits.qbk +++ b/doc/sf_and_dist/credits.qbk @@ -7,13 +7,13 @@ John Maddock started this library, the beta, gamma, erf, polynomial, and factorial functions are his, as is the "Toolkit" section, and many of the statistical distributions. -Paul A. Bristow threw down the challenge in -[@http://www2.open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1668.pdf -A Proposal to add Mathematical Functions for Statistics to the C++ +Paul A. Bristow threw down the challenge in +[@http://www2.open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1668.pdf +A Proposal to add Mathematical Functions for Statistics to the C++ Standard Library] to add the key math functions, especially those essential for -statistics. After JM accepted and solved the difficult problems, +statistics. After JM accepted and solved the difficult problems, not only numerically, but in full C++ template style, PAB -implemented a few of the statistical distributions. PAB also tirelessly +implemented a few of the statistical distributions. PAB also tirelessly proof-read everything that JM threw at him (so that all remaining editorial mistakes are his fault). @@ -25,16 +25,20 @@ Bruno Lalande submitted the "compile time power of a runtime base" code. Johan R'''å'''de wrote the optimised floating point classification code. +Gautam Sewani coded the logistic distribution as part of a Google Summer of Code project 2008. + +M. A. (Thijs) van den Berg coded the Laplace distribution. +(Thijs has also threatened to implement some multivariate distributions). + Professor Nico Temme for advice on the inverse incomplete beta function. -[@http://www.shoup.net Victor Shoup for NTL], -without which it would have much difficult to +[@http://www.shoup.net Victor Shoup for NTL], +without which it would have much more difficult to produce high accuracy constants, and especially the tables of accurate values for testing. -We are grateful to Joel Guzman for helping us stress-test -his -[@http://www.boost.org/tools/quickbook/index.htm Boost.Quickbook] +We are grateful to Joel Guzman for helping us stress-test his +[@http://www.boost.org/tools/quickbook/index.htm Boost.Quickbook] program used to generate the html and pdf versions of this document, adding several new features en route. @@ -48,17 +52,17 @@ Since browser support for rendering SVG is still not universal but can be made to work with [@http://www.adobe.com/svg/viewer/install/ Adobe's free SVG viewer] plugin), so the SVG files were batch converted to JPEG using -[@http://www.inkscape.org/ Inkscape]. +[@http://www.inkscape.org/ Inkscape]. We are also indebted to Matthias Schabel for managing the formal Boost-review of this library, and to all the reviewers - including Guillaume Melquiond, -Arnaldur Gylfason, John Phillips, Stephan Tolksdorf and Jeff Garland +Arnaldur Gylfason, John Phillips, Stephan Tolksdorf and Jeff Garland - for their many helpful comments. [endsect] [/section:credits Credits and Acknowledgements] -[/ - Copyright 2006, 2007, 2008 John Maddock and Paul A. Bristow. +[/ + Copyright 2006, 2007, 2008, 2009 John Maddock and Paul A. Bristow. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). diff --git a/doc/sf_and_dist/dist_reference.qbk b/doc/sf_and_dist/dist_reference.qbk index ecb4e1260..9ca5a249e 100644 --- a/doc/sf_and_dist/dist_reference.qbk +++ b/doc/sf_and_dist/dist_reference.qbk @@ -13,6 +13,9 @@ [include distributions/extreme_value.qbk] [include distributions/fisher.qbk] [include distributions/gamma.qbk] +[include distributions/hypergeometric.qbk] +[include distributions/laplace.qbk] +[include distributions/logistic.qbk] [include distributions/lognormal.qbk] [include distributions/negative_binomial.qbk] [include distributions/nc_beta.qbk] diff --git a/doc/sf_and_dist/dist_tutorial.qbk b/doc/sf_and_dist/dist_tutorial.qbk index f09d9b521..2fd24633c 100644 --- a/doc/sf_and_dist/dist_tutorial.qbk +++ b/doc/sf_and_dist/dist_tutorial.qbk @@ -5,17 +5,17 @@ [def __F_distrib [link math_toolkit.dist.dist_ref.dists.f_dist Fisher F Distribution]] [def __students_t_distrib [link math_toolkit.dist.dist_ref.dists.students_t_dist Students t Distribution]] -[def __handbook [@http://www.itl.nist.gov/div898/handbook/ +[def __handbook [@http://www.itl.nist.gov/div898/handbook/ NIST/SEMATECH e-Handbook of Statistical Methods.]] [section:stat_tut Statistical Distributions Tutorial] This library is centred around statistical distributions, this tutorial -will give you an overview of what they are, how they can be used, and +will give you an overview of what they are, how they can be used, and provides a few worked examples of applying the library to statistical tests. -[section:overview Overview] +[section:overview Overview of Distributions] -[h4 Headers and Namespaces] +[section:headers Headers and Namespaces] All the code in this library is inside namespace boost::math. @@ -27,27 +27,29 @@ For example, to use the Students-t distribution include either or -[h4 Distributions are Objects] +[endsect] [/ section:headers Headers and Namespaces] -Each kind of distribution in this library is a class type. +[section:objects Distributions are Objects] -[link math_toolkit.policy Policies] provide fine-grained control +Each kind of distribution in this library is a class type - an object. + +[link math_toolkit.policy Policies] provide fine-grained control of the behaviour of these classes, allowing the user to customise behaviour such as how errors are handled, or how the quantiles of discrete distribtions behave. [tip If you are familiar with statistics libraries using functions, and 'Distributions as Objects' seem alien, see -[link math_toolkit.dist.stat_tut.weg.nag_library the comparison to -other statistics libraries.] +[link math_toolkit.dist.stat_tut.weg.nag_library the comparison to +other statistics libraries.] ] [/tip] Making distributions class types does two things: -* It encapsulates the kind of distribution in the C++ type system; -so, for example, Students-t distributions are always a different C++ type from +* It encapsulates the kind of distribution in the C++ type system; +so, for example, Students-t distributions are always a different C++ type from Chi-Squared distributions. -* The distribution objects store any parameters associated with the +* The distribution objects store any parameters associated with the distribution: for example, the Students-t distribution has a ['degrees of freedom] parameter that controls the shape of the distribution. This ['degrees of freedom] parameter has to be provided @@ -57,60 +59,63 @@ Although the distribution classes in this library are templates, there are typedefs on type /double/ that mostly take the usual name of the distribution (except where there is a clash with a function of the same name: beta and gamma, -in which case using the default template arguments - `RealType = double` - +in which case using the default template arguments - `RealType = double` - is nearly as convenient). Probably 95% of uses are covered by these typedefs: using namespace boost::math; - + // Construct a students_t distribution with 4 degrees of freedom: students_t d1(4); - - // Construct a double-precision beta distribution + + // Construct a double-precision beta distribution // with parameters a = 10, b = 20 beta_distribution<> d2(10, 20); // Note: _distribution<> suffix ! - + If you need to use the distributions with a type other than `double`, -then you can instantiate the template directly: the names of the +then you can instantiate the template directly: the names of the templates are the same as the `double` typedef but with `_distribution` appended, for example: __students_t_distrib or __binomial_distrib: // Construct a students_t distribution, of float type, // with 4 degrees of freedom: students_t_distribution d3(4); - + // Construct a binomial distribution, of long double type, // with probability of success 0.3 // and 20 trials in total: binomial_distribution d4(20, 0.3); - + The parameters passed to the distributions can be accessed via getter member functions: - d1.degrees_of_freedom(); // returns 4.0 - + d1.degrees_of_freedom(); // returns 4.0 + This is all well and good, but not very useful so far. What we often want is to be able to calculate the /cumulative distribution functions/ and /quantiles/ etc for these distributions. -[h4 Generic operations common to all distributions are non-member functions] +[endsect] [/section:objects Distributions are Objects] + + +[section:generic Generic operations common to all distributions are non-member functions] Want to calculate the PDF (Probability Density Function) of a distribution? No problem, just use: pdf(my_dist, x); // Returns PDF (density) at point x of distribution my_dist. - + Or how about the CDF (Cumulative Distribution Function): cdf(my_dist, x); // Returns CDF (integral from -infinity to point x) // of distribution my_dist. - + And quantiles are just the same: quantile(my_dist, p); // Returns the value of the random variable x // such that cdf(my_dist, x) == p. - -If you're wondering why these aren't member functions, it's to + +If you're wondering why these aren't member functions, it's to make the library more easily extensible: if you want to add additional generic operations - let's say the /n'th moment/ - then all you have to do is add the appropriate non-member functions, overloaded for each @@ -124,9 +129,9 @@ If you want random numbers that are distributed in a specific way, for example in a uniform, normal or triangular, see [@http://www.boost.org/libs/random/ Boost.Random]. -Whilst in principal there's nothing to prevent you from using the +Whilst in principal there's nothing to prevent you from using the quantile function to convert a uniformly distributed random -number to another distribution, in practice there are much more +number to another distribution, in practice there are much more efficient algorithms available that are specific to random number generation. ] [/tip Random numbers that approximate Quantiles of Distributions] @@ -136,7 +141,7 @@ n (the number of trials) and p (the probability of success on one trial). The `binomial_distribution` constructor therefore has two parameters: `binomial_distribution(RealType n, RealType p);` - + For this distribution the random variate is k: the number of successes observed. The probability density\/mass function (pdf) is therefore written as ['f(k; n, p)]. @@ -153,15 +158,15 @@ to separate the variate from the parameter(s) that defines the shape of the dist ] [/tip Random Variates and Distribution Parameters] As noted above the non-member function `pdf` has one parameter for the distribution object, -and a second for the random variate. So taking our binomial distribution +and a second for the random variate. So taking our binomial distribution example, we would write: `pdf(binomial_distribution(n, p), k);` -The ranges of random variate values that are permitted and are supported can be +The ranges of random variate values that are permitted and are supported can be tested by using two functions `range` and `support`. -The distribution (effectively the random variate) is said to be 'supported' +The distribution (effectively the random variate) is said to be 'supported' over a range that is [@http://en.wikipedia.org/wiki/Probability_distribution "the smallest closed set whose complement has probability zero"]. @@ -180,15 +185,15 @@ If you are plotting the PDF, or otherwise calculating, zero is not the most useful value for the lower limit of supported, as we discovered. So for this, and similar distributions, we have decided it is most numerically useful to use -the closest value to zero, min_value, for the limit of the supported range. +the closest value to zero, min_value, for the limit of the supported range. (The `range` remains from zero, so you will still get `pdf(weibull, 0) == 0`). (Exponential and gamma distributions have similarly discontinuous functions). Mathematically, the functions may make sense with an (+ or -) infinite value, but except for a few special cases (in the Normal and Cauchy distributions) -this implementation limits random variates to finite values from the `max` +this implementation limits random variates to finite values from the `max` to `min` for the `RealType`. -(See [link math_toolkit.backgrounders.implementation.handling_of_floating_point_infinity +(See [link math_toolkit.backgrounders.implementation.handling_of_floating_point_infinity Handling of Floating-Point Infinity] for rationale). @@ -196,23 +201,23 @@ Handling of Floating-Point Infinity] for rationale). [*Discrete Probability Distributions] -Note that the [@http://en.wikipedia.org/wiki/Discrete_probability_distribution +Note that the [@http://en.wikipedia.org/wiki/Discrete_probability_distribution discrete distributions], including the binomial, negative binomial, Poisson & Bernoulli, are all mathematically defined as discrete functions: -that is to say the functions `cdf` and `pdf` are only defined for integral values +that is to say the functions `cdf` and `pdf` are only defined for integral values of the random variate. However, because the method of calculation often uses continuous functions it is convenient to treat them as if they were continuous functions, and permit non-integral values of their parameters. -Users wanting to enforce a strict mathematical model may use `floor` -or `ceil` functions on the random variate prior to calling the distribution +Users wanting to enforce a strict mathematical model may use `floor` +or `ceil` functions on the random variate prior to calling the distribution function. The quantile functions for these distributions are hard to specify in a manner that will satisfy everyone all of the time. The default -behaviour is to return an integer result, that has been rounded +behaviour is to return an integer result, that has been rounded /outwards/: that is to say, lower quantiles - where the probablity is less than 0.5 are rounded down, while upper quantiles - where the probability is greater than 0.5 - are rounded up. This behaviour @@ -221,17 +226,17 @@ coverage will be present in the central region, and /no more than/ the requested coverage will be present in the tails. This behaviour can be changed so that the quantile functions are rounded -differently, or return a real-valued result using +differently, or return a real-valued result using [link math_toolkit.policy.pol_overview Policies]. It is strongly -recommended that you read the tutorial +recommended that you read the tutorial [link math_toolkit.policy.pol_tutorial.understand_dis_quant Understanding Quantiles of Discrete Distributions] before using the quantile function on a discrete distribtion. The -[link math_toolkit.policy.pol_ref.discrete_quant_ref reference docs] +[link math_toolkit.policy.pol_ref.discrete_quant_ref reference docs] describe how to change the rounding policy for these distributions. -For similar reasons continuous distributions with parameters like +For similar reasons continuous distributions with parameters like "degrees of freedom" that might appear to be integral, are treated as real values (and are promoted from integer to floating-point if necessary). @@ -239,16 +244,17 @@ In this case however, there are a small number of situations where non-integral degrees of freedom do have a genuine meaning. ] +[endsect] [/ section:generic Generic operations common to all distributions are non-member functions] + [#complements] -[h4 Complements are supported too] +[section:complements Complements are supported too - and when to use them] Often you don't want the value of the CDF, but its complement, which is -to say `1-p` rather than `p`. You could calculate the CDF and subtract +to say `1-p` rather than `p`. It is tempting to calculate the CDF and subtract it from `1`, but if `p` is very close to `1` then cancellation error -will cause you to lose significant digits. In extreme cases, `p` may -actually be equal to `1`, even though the true value of the complement is non-zero. +will cause you to lose accuracy, perhaps totally. -[link why_complements See also ['"Why complements?"]] +[link why_complements See below ['"Why and when to use complements?"]] In this library, whenever you want to receive a complement, just wrap all the function arguments in a call to `complement(...)`, for example: @@ -262,7 +268,7 @@ Any function that accepts a probability as an argument can also accept a complem by wrapping all of its arguments in a call to `complement(...)`, for example: students_t dist(5); - + for(double i = 10; i < 1e10; i *= 10) { // Calculate the quantile for a 1 in i chance: @@ -271,12 +277,12 @@ by wrapping all of its arguments in a call to `complement(...)`, for example: cout << "Quantile of students-t with 5 degrees of freedom\n" "for a 1 in " << i << " chance is " << t << endl; } - + [tip [*Critical values are just quantiles] -Some texts talk about quantiles, others about critical values, the basic rule is: +Some texts talk about quantiles, or percentiles, others about critical values, the basic rule is: ['Lower critical values] are the same as the quantile. @@ -284,7 +290,7 @@ Some texts talk about quantiles, others about critical values, the basic rule is of the probability. For example, suppose we have a Bernoulli process, giving rise to a binomial -distribution with success ratio 0.1 and 100 trials in total. The +distribution with success ratio 0.1 and 100 trials in total. The ['lower critical value] for a probability of 0.05 is given by: `quantile(binomial(100, 0.1), 0.05)` @@ -311,7 +317,7 @@ bit that didn't cancel out! Or to look at this another way: consider that we want the risk of falsely rejecting the null-hypothesis in the Student's t test to be 1 in 1 billion, for a sample size of 10,000. -This gives a probability of 1 - 10[super -9], which is exactly 1 when +This gives a probability of 1 - 10[super -9], which is exactly 1 when calculated at float precision. In this case calculating the quantile from the complement neatly solves the problem, so for example: @@ -326,11 +332,32 @@ raises an overflow error, since it is the same as: `quantile(students_t(10000), 1)` Which has no finite result. -] -[h4 Parameters can be calculated] +With all distributions, even for more reasonable probability +(unless the value of p can be represented exactly in the floating-point type) +the loss of accuracy quickly becomes significant if you simply calculate probability from 1 - p +(because it will be mostly garbage digits for p ~ 1). -Sometimes it's the parameters that define the distribution that you +So always avoid, for example, using a probability near to unity like 0.99999 + +`quantile(my_distribution, 0.99999)` + +and instead use + +`quantile(complement(my_distribution, 0.00001))` + +since 1 - 0.99999 is not exactly equal to 0.00001 when using floating-point arithmetic. + +This assumes that the 0.00001 value is either a constant, +or can be computed by some manner other than subtracting 0.99999 from 1. + +] [/ tip *Why bother with complements anyway?] + +[endsect] [/ section:complements Complements are supported too - and why] + +[section:parameters Parameters can be calculated] + +Sometimes it's the parameters that define the distribution that you need to find. Suppose, for example, you have conducted a Students-t test for equal means and the result is borderline. Maybe your two samples differ from each other, or maybe they don't; based on the result @@ -346,7 +373,7 @@ of the distributions, for example: 0.05, // maximum risk of falsely rejecting the null-hypothesis. 0.1, // maximum risk of falsely failing to reject the null-hypothesis. 0.13); // sample standard deviation - + Returns the number of degrees of freedom required to obtain a 95% probability that the observed differences in means is not down to chance alone. In the case that a borderline Students-t test result @@ -354,8 +381,10 @@ was previously obtained, this can be used to estimate how large the sample size would have to become before the observed difference was considered significant. It assumes, of course, that the sample mean and standard deviation are invariant with sample size. - -[h4 Summary] + +[endsect] [/ section:parameters Parameters can be calculated] + +[section:summary Summary] * Distributions are objects, which are constructed from whatever parameters the distribution may have. @@ -372,6 +401,7 @@ to be found from other information. Now that you have the basics, the next section looks at some worked examples. +[endsect] [/section:summary Summary] [endsect] [/section:overview Overview] [section:weg Worked Examples] @@ -386,6 +416,7 @@ Now that you have the basics, the next section looks at some worked examples. [include distributions/error_handling_example.qbk] [include distributions/find_location_and_scale.qbk] [include distributions/nag_library.qbk] +[include distributions/c_sharp.qbk] [endsect] [/section:weg Worked Examples] [include background.qbk] diff --git a/doc/sf_and_dist/distributions/c_sharp.qbk b/doc/sf_and_dist/distributions/c_sharp.qbk new file mode 100644 index 000000000..874675739 --- /dev/null +++ b/doc/sf_and_dist/distributions/c_sharp.qbk @@ -0,0 +1,20 @@ +[section:c_sharp Using the Distributions from Within C#] + +The distributions in this library can be used from the C# programming language +when they are built using Microsofts Common Language Runtime option. + +An example of this kind of usage is given in the +[@../../distexplorer/html/index.html distribution_explorer] example: +see =boost-root/libs/math/dot_net_example= +for the source code: the application consists of a C++ dll that contains the +actual distributions, and a C# GUI that allows you to explore their properties. + +[endsect] [/section:c_sharp] + +[/ + Copyright 2006 John Maddock and Paul A. Bristow. + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +] + diff --git a/doc/sf_and_dist/distributions/hypergeometric.qbk b/doc/sf_and_dist/distributions/hypergeometric.qbk new file mode 100644 index 000000000..24664c67f --- /dev/null +++ b/doc/sf_and_dist/distributions/hypergeometric.qbk @@ -0,0 +1,229 @@ +[section:hypergeometric_dist Hypergeometric Distribution] + +``#include `` + + namespace boost{ namespace math{ + + template + class hypergeometric_distribution; + + template + class hypergeometric_distribution + { + public: + typedef RealType value_type; + typedef Policy policy_type; + // Construct: + hypergeometric_distribution(unsigned r, unsigned n, unsigned N); + // Accessors: + unsigned total()const; + unsigned defective()const; + unsigned sample_count()const; + }; + + typedef hypergeometric_distribution<> hypergeometric; + + }} // namespaces + +The hypergeometric distribution describes the number of "events" /k/ +from a sample /n/ drawn from a total population /N/ ['without replacement]. + +Imagine we have a sample of /N/ objects of which /r/ are "defective" +and N-r are "not defective" +(the terms "success\/failure" or "red\/blue" are also used). If we sample /n/ +items /without replacement/ then what is the probability that exactly +/k/ items in the sample are defective? The answer is given by the pdf of the +hypergeometric distribution `f(k; r, n, N)`, whilst the probability of +/k/ defectives or fewer is given by F(k; r, n, N), where F(k) is the +CDF of the hypergeometric distribution. + +[note Unlike almost all of the other distributions in this library, +the hypergeometric distribution is strictly discrete: it can not be +extended to real valued arguments of its parameters or random variable.] + +The following graph shows how the distribution changes as the proportion +of "defective" items changes, while keeping the population and sample sizes +constant: + +[graph hypergeometric_pdf_1] + +Note that since the distribution is symmetrical in parameters /n/ and /r/, if we +change the sample size and keep the population and proportion "defective" the same +then we obtain basically the same graphs: + +[graph hypergeometric_pdf_2] + +[h4 Member Functions] + + hypergeometric_distribution(unsigned r, unsigned n, unsigned N); + +Constructs a hypergeometric distribution with with a population of /N/ objects, +of which /r/ are defective, and from which /n/ are sampled. + + unsigned total()const; + +Returns the total number of objects /N/. + + unsigned defective()const; + +Returns the number of objects /r/ in population /N/ which are defective. + + unsigned sample_count()const; + +Returns the number of objects /n/ which are sampled from the population /N/. + +[h4 Non-member Accessors] + +All the [link math_toolkit.dist.dist_ref.nmp usual non-member accessor functions] +that are generic to all distributions are supported: __usual_accessors. + +The domain of the random variable is the unsigned integers in the range +\[max(0, n + r - N), min(n, r)\]. A __domain_error is raised if the +random variable is outside this range, or is not an integral value. + +[caution +The quantile function will by default return an integer result that has been +/rounded outwards/. That is to say lower quantiles (where the probability is +less than 0.5) are rounded downward, and upper quantiles (where the probability +is greater than 0.5) are rounded upwards. This behaviour +ensures that if an X% quantile is requested, then /at least/ the requested +coverage will be present in the central region, and /no more than/ +the requested coverage will be present in the tails. + +This behaviour can be changed so that the quantile functions are rounded +differently using +[link math_toolkit.policy.pol_overview Policies]. It is strongly +recommended that you read the tutorial +[link math_toolkit.policy.pol_tutorial.understand_dis_quant +Understanding Quantiles of Discrete Distributions] before +using the quantile function on the Hypergeometric distribution. The +[link math_toolkit.policy.pol_ref.discrete_quant_ref reference docs] +describe how to change the rounding policy +for these distributions. + +However, note that the implementation method of the quantile function +always returns an integral value, therefore attempting to use a __Policy +that requires (or produces) a real valued result will result in a +compile time error. +] [/ caution] + + +[h4 Accuracy] + +For small N such that +`N < boost::math::max_factorial::value` then table based +lookup of the results gives an accuracy to a few epsilon. +`boost::math::max_factorial::value` is 170 at double or long double +precision. + +For larger N such that `N < boost::math::prime(boost::math::max_prime)` +then only basic arithmetic is required for the calculation +and the accuracy is typically < 20 epsilon. This takes care of N +up to 104729. + +For `N > boost::math::prime(boost::math::max_prime)` then accuracy quickly +degrades, with 5 or 6 decimal digits being lost for N = 110000. + +In general for very large N, the user should expect to loose log[sub 10]N +decimal digits of precision during the calculation, with the results +becoming meaningless for N >= 10[super 15]. + +[h4 Testing] + +There are three sets of tests: our implementation is tested against a table of values +produced by Mathematica's implementation of this distribution. We also sanity check +our implementation against some spot values computed using the online calculator +here [@http://stattrek.com/Tables/Hypergeometric.aspx http://stattrek.com/Tables/Hypergeometric.aspx]. +Finally we test accuracy against some high precision test data using +this implementation and NTL::RR. + +[h4 Implementation] + +The PDF can be calculated directly using the formula: + +[equation hypergeometric1] + +However, this can only be used directly when the largest of the factorials +is guaranteed not to overflow the floating point representation used. +This formula is used directly when `N < max_factorial::value` +in which case table lookup of the factorials gives a rapid and accurate +implementation method. + +For larger /N/ the method described in +"An Accurate Computation of the Hypergeometric Distribution Function", +Trong Wu, ACM Transactions on Mathematical Software, Vol. 19, No. 1, +March 1993, Pages 33-43 is used. The method relies on the fact that +there is an easy method for factorising a factorial into the product +of prime numbers: + +[equation hypergeometric2] + +Where p[sub i] is the i'th prime number, and e[sub i] is a small +positive integer or zero, which can be calculated via: + +[equation hypergeometric3] + +Further we can combine the factorials in the expression for the PDF +to yield the PDF directly as the product of prime numbers: + +[equation hypergeometric4] + +With this time the exponents e[sub i] being either positive, negative +or zero. Indeed such a degree of cancellation occurs in the calculation +of the e[sub i] that many are zero, and typically most have a magnitude +or no more than 1 or 2. + +Calculation of the product of the primes requires some care to prevent +numerical overflow, we use a novel recursive method which splits the +calculation into a series of sub-products, with a new sub-product +started each time the next multiplication would cause either overflow +or underflow. The sub-products are stored in a linked list on the +program stack, and combined in an order that will guarantee no overflow +or unnecessary-underflow once the last sub-product has been calculated. + +This method can be used as long as N is smaller than the largest prime +number we have stored in our table of primes (currently 104729). The method +is relatively slow (calculating the exponents requires the most time), but +requires only a small number of arithmetic operations to +calculate the result (indeed there is no shorter method involving only basic +arithmetic once the exponents have been found), the method is therefore +much more accurate than the alternatives. + +For much larger N, we can calculate the PDF from the factorials using +either lgamma, or by directly combining lanczos approximations to avoid +calculating via logarithms. We use the latter method, as it is usually +1 or 2 decimal digits more accurate than computing via logarithms with +lgamma. However, in this area where N > 104729, the user should expect +to loose around log[sub 10]N decimal digits during the calculation in +the worst case. + +The CDF and its complement is calculated by directly summing the PDF's. +We start by deciding whether the CDF, or its complement, is likely to be +the smaller of the two and then calculate the PDF at /k/ (or /k+1/ if we're +calculating the complement) and calculate successive PDF values via the +recurrence relations: + +[equation hypergeometric5] + +Until we either reach the end of the distributions domain, or the next +PDF value to be summed would be too small to affect the result. + +The quantile is calculated in a similar manner to the CDF: we first guess +which end of the distribution we're nearer to, and then sum PDFs starting +from the end of the distribution this time, until we have some value /k/ that +gives the required CDF. + +The median is simply the quantile at 0.5, and the remaining properties are +calculated via: + +[equation hypergeometric6] + +[endsect] + +[/ hypergeometric.qbk + Copyright 2008 John Maddock. + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +] diff --git a/doc/sf_and_dist/distributions/laplace.qbk b/doc/sf_and_dist/distributions/laplace.qbk new file mode 100644 index 000000000..ce912480e --- /dev/null +++ b/doc/sf_and_dist/distributions/laplace.qbk @@ -0,0 +1,145 @@ +[section:laplace_dist Laplace Distribution] + +``#include `` + + namespace boost{ namespace math{ + + template + class laplace_distribution; + + typedef laplace_distribution<> laplace; + + template + class laplace_distribution + { + public: + typedef RealType value_type; + typedef Policy policy_type; + // Construct: + laplace_distribution(RealType location = 0, RealType scale = 1); + // Accessors: + RealType location()const; + RealType scale()const; + }; + + }} // namespaces + +Laplace distribution is the distribution of differences between two independent variates +with identical exponential distributions (Abramowitz and Stegun 1972, p. 930). +It is also called the double exponential distribution. + +[/ Wikipedia definition is The difference between two independent identically distributed +exponential random variables is governed by a Laplace distribution.] + +For location parameter [mu][space] and scale parameter [sigma][space] it is defined by the +probability density function: + +[equation laplace_pdf] + +The location and scale parameters are equivalent to the mean and +standard deviation of the normal or Gaussian distribution. + +The following graph illustrates the effect of the location +parameter [mu][space] on the PDF. Note that the range of the random +variable remains \[-[infin],+[infin]\] irrespective of the value of the +location parameter: + +[graph laplace_pdf_mu] + +The next graph illustrates the effect of the scale parameter [sigma][space] on the PDF: + +[graph laplace_pdf_sigma] + +[h4 Member Functions] + + laplace_distribution(RealType location = 0, RealType scale = 1); + +Constructs a laplace distribution with location /location/ and +scale /scale/. + +The location parameter is the same as the mean of the random variate. + +The scale parameter is proportional to the standard deviation of the random variate. + +Requires that the scale parameter is greater than zero, otherwise calls +__domain_error. + + RealType location()const; + +Returns the /location/ parameter of this distribution. + + RealType scale()const; + +Returns the /scale/ parameter of this distribution. + +[h4 Non-member Accessors] + +All the [link math_toolkit.dist.dist_ref.nmp usual non-member accessor functions] that are generic to all +distributions are supported: __usual_accessors. + +The domain of the random variable is \[-[infin],+[infin]\]. + +[h4 Accuracy] + +The laplace distribution is implemented in terms of the +standard library log and exp functions and as such should have very small errors. + +[h4 Implementation] + +In the following table [mu] is the location parameter of the distribution, +[sigma] is its scale parameter, /x/ is the random variate, /p/ is the probability +and its complement /q = 1-p/. + +[table +[[Function][Implementation Notes]] +[[pdf][Using the relation: pdf = e[super -abs(x-[mu]) \/ [sigma]] \/ (2 * [sigma]) ]] +[[cdf][Using the relations: + +x < [mu] : p = e[super (x-[mu])/[sigma] ] \/ [sigma] + +x >= [mu] : p = 1 - e[super ([mu]-x)/[sigma] ] \/ [sigma] +]] +[[cdf complement][Using the relation: + +-x < [mu] : q = e[super (-x-[mu])/[sigma] ] \/ [sigma] + +-x >= [mu] : q = 1 - e[super ([mu]+x)/[sigma] ] \/ [sigma] +]] +[[quantile][Using the relations: + +p < 0.5 : x = [mu] + [sigma] * log(2*p) + +p >= 0.5 : x = [mu] - [sigma] * log(2-2*p) +]] +[[quantile from the complement][Using the relation: + +q > 0.5: x = [mu] + [sigma]*log(2-2*q) + +q <=0.5: x = [mu] - [sigma]*log( 2*q ) +]] +[[mean][[mu]]] +[[variance][2 * [sigma][super 2] ]] +[[mode][[mu]]] +[[skewness][0]] +[[kurtosis][6]] +[[kurtosis excess][3]] +] + +[h4 References] + +* [@http://mathworld.wolfram.com/LaplaceDistribution.html Weisstein, Eric W. "Laplace Distribution."] From MathWorld--A Wolfram Web Resource. + +* [@http://en.wikipedia.org/wiki/Laplace_distribution Laplace Distribution] + +* M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions, 1972, p. 930. + +[endsect][/section:laplace_dist laplace] + +[/ + Copyright 2008, 2009 John Maddock, Paul A. Bristow and M.A. (Thijs) van den Berg. + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +] + diff --git a/doc/sf_and_dist/distributions/logistic.qbk b/doc/sf_and_dist/distributions/logistic.qbk new file mode 100644 index 000000000..e73343b35 --- /dev/null +++ b/doc/sf_and_dist/distributions/logistic.qbk @@ -0,0 +1,103 @@ +[section:logistic_dist Logistic Distribution] + +``#include `` + + namespace boost{ namespace math{ + + template + class logistic_distribution; + + template + class logistic_distribution + { + public: + typedef RealType value_type; + typedef Policy policy_type; + // Construct: + logistic_distribution(RealType location = 0, RealType scale = 1); + // Accessors: + RealType location()const; // location. + RealType scale()const; // scale. + + }; + + typedef logistic_distribution<> logistic; + + }} // namespaces + +The logistic distribution is a continous probability distribution. +It has two parameters - location and scale. The cumulative distribution +function of the logistic distribution appears in logistic regression +and feedforward neural networks. Among other applications, +United State Chess Federation and FIDE use it to calculate chess ratings. + +The following graph shows how the distribution changes as the +parameters change: + +[graph logistic_pdf] + +[h4 Member Functions] + + logistic_distribution(RealType u = 0, RealType s = 1); + +Constructs a logistic distribution with location /u/ and scale /s/. + +Requires `scale > 0`, otherwise a __domain_error is raised. + + RealType location()const; + +Returns the location of this distribution. + + RealType scale()const; + +Returns the scale of this distribution. + +[h4 Non-member Accessors] + +All the [link math_toolkit.dist.dist_ref.nmp usual non-member accessor functions] +that are generic to all distributions are supported: __usual_accessors. + +The domain of the random variable is \[-\[max_value\], +\[min_value\]\]. +However, the pdf and cdf support inputs of +[infin] and -[infin] +as special cases if RealType permits. + +At `p=1` and `p=0`, the quantile function returns the result of ++__overflow_error and -__overflow_error, while the complement +quantile function returns the result of -__overflow_error and ++__overflow_error respectively. + +[h4 Accuracy] + +The logistic distribution is implemented in terms of the `std::exp` +and the `std::log` functions, so its accuracy is related to the +accurate implementations of those functions on a given platform. +When calculating the quantile with a non-zero /position/ parameter +catastrophic cancellation errors can occur: +in such cases, only a low /absolute error/ can be guarenteed. + +[h4 Implementation] + +[table +[[Function][Implementation Notes]] +[[pdf][Using the relation: pdf = e[super -(x-u)/s] / (s*(1+e[super -(x-u)/s])[super 2])]] +[[cdf][Using the relation: p = 1/(1+e[super -(x-u)/s])]] +[[cdf complement][Using the relation: q = 1/(1+e[super (x-u)/s])]] +[[quantile][Using the relation: x = u - s*log(1/p-1)]] +[[quantile from the complement][Using the relation: x = u + s*log(p/1-p)]] +[[mean][u]] +[[mode][The same as the mean.]] +[[skewness][0]] +[[kurtosis excess][6/5]] +[[variance][ ([pi]*s)[super 2] / 3]] +] + +[endsect] + +[/ logistic.qbk + Copyright 2006, 2007 John Maddock and Paul A. Bristow. + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +] + diff --git a/doc/sf_and_dist/distributions/pareto.qbk b/doc/sf_and_dist/distributions/pareto.qbk index 82de7fc0e..4e7e2c417 100644 --- a/doc/sf_and_dist/distributions/pareto.qbk +++ b/doc/sf_and_dist/distributions/pareto.qbk @@ -3,41 +3,42 @@ ``#include `` - namespace boost{ namespace math{ - - template class pareto_distribution; - + typedef pareto_distribution<> pareto; - + template class pareto_distribution { public: typedef RealType value_type; // Constructor: - pareto_distribution(RealType location = 1, RealType shape = 1) + pareto_distribution(RealType scale = 1, RealType shape = 1) // Accessors: - RealType location()const; + RealType scale()const; RealType shape()const; }; - + }} // namespaces - + The [@http://en.wikipedia.org/wiki/pareto_distribution Pareto distribution] -is a continuous distribution with the +is a continuous distribution with the [@http://en.wikipedia.org/wiki/Probability_density_function probability density function (pdf)]: f(x; [alpha], [beta]) = [alpha][beta][super [alpha]] / x[super [alpha]+ 1] -For shape parameter [alpha][space] > 0, and location parameter [beta][space] > 0, and [alpha][space] > 0. +For shape parameter [alpha][space] > 0, and scale parameter [beta][space] > 0. +If x < [beta][space], the pdf is zero. -The [@http://mathworld.wolfram.com/paretoDistribution.html Pareto distribution] +The [@http://mathworld.wolfram.com/ParetoDistribution.html Pareto distribution] often describes the larger compared to the smaller. A classic example is that 80% of the wealth is owned by 20% of the population. -The following graph illustrates how the PDF varies with the location parameter [beta]: +The following graph illustrates how the PDF varies with the scale parameter [beta]: [graph pareto_pdf1] @@ -48,23 +49,23 @@ And this graph illustrates how the PDF varies with the shape parameter [alpha]: [h4 Related distributions] - + [h4 Member Functions] - pareto_distribution(RealType location = 1, RealType shape = 1); - -Constructs a [@http://en.wikipedia.org/wiki/pareto_distribution + pareto_distribution(RealType scale = 1, RealType shape = 1); + +Constructs a [@http://en.wikipedia.org/wiki/pareto_distribution pareto distribution] with shape /shape/ and scale /scale/. -Requires that the /shape/ and /scale/ parameters are both greater than zero, +Requires that the /shape/ and /scale/ parameters are both greater than zero, otherwise calls __domain_error. - - RealType location()const; - -Returns the /location/ parameter of this distribution. + + RealType scale()const; + +Returns the /scale/ parameter of this distribution. RealType shape()const; - + Returns the /shape/ parameter of this distribution. [h4 Non-member Accessors] @@ -72,19 +73,20 @@ Returns the /shape/ parameter of this distribution. All the [link math_toolkit.dist.dist_ref.nmp usual non-member accessor functions] that are generic to all distributions are supported: __usual_accessors. -The supported domain of the random variable is \[location, [infin]\]. +The supported domain of the random variable is \[scale, [infin]\]. [h4 Accuracy] -The pareto distribution is implemented in terms of the +The Pareto distribution is implemented in terms of the standard library `exp` functions plus __expm1 -and as such should have very low error rates -except when probability is very close to unity. +and so should have very small errors, usually only a few epsilon. + +If probability is near to unity (or the complement of a probability near zero) see also __why_complements. [h4 Implementation] In the following table [alpha][space] is the shape parameter of the distribution, and -[beta][space] is its location parameter, /x/ is the random variate, /p/ is the probability +[beta][space] is its scale parameter, /x/ is the random variate, /p/ is the probability and its complement /q = 1-p/. [table @@ -92,24 +94,26 @@ and its complement /q = 1-p/. [[pdf][Using the relation: pdf p = [alpha][beta][super [alpha]]/x[super [alpha] +1] ]] [[cdf][Using the relation: cdf p = 1 - ([beta][space] / x)[super [alpha]] ]] [[cdf complement][Using the relation: q = 1 - p = -([beta][space] / x)[super [alpha]] ]] -[[quantile][Using the relation: x = [alpha] / (1 - p)[super 1/[beta]] ]] -[[quantile from the complement][Using the relation: x = [alpha] / (q)[super 1/[beta]] ]] +[[quantile][Using the relation: x = [beta] / (1 - p)[super 1/[alpha]] ]] +[[quantile from the complement][Using the relation: x = [beta] / (q)[super 1/[alpha]] ]] [[mean][[alpha][beta] / ([beta] - 1) ]] [[variance][[beta][alpha][super 2] / ([beta] - 1)[super 2] ([beta] - 2) ]] [[mode][[alpha]]] -[[skewness][Refer to [@http://mathworld.wolfram.com/paretoDistribution.html Weisstein, Eric W. "Pareto Distribution." From MathWorld--A Wolfram Web Resource.] ]] -[[kurtosis][Refer to [@http://mathworld.wolfram.com/paretoDistribution.html Weisstein, Eric W. "Pareto Distribution." From MathWorld--A Wolfram Web Resource.] ]] -[[kurtosis excess][Refer to [@http://mathworld.wolfram.com/paretoDistribution.html Weisstein, Eric W. "pareto Distribution." From MathWorld--A Wolfram Web Resource.] ]] +[[skewness][Refer to [@http://mathworld.wolfram.com/ParetoDistribution.html Weisstein, Eric W. "Pareto Distribution." From MathWorld--A Wolfram Web Resource.] ]] +[[kurtosis][Refer to [@http://mathworld.wolfram.com/ParetoDistribution.html Weisstein, Eric W. "Pareto Distribution." From MathWorld--A Wolfram Web Resource.] ]] +[[kurtosis excess][Refer to [@http://mathworld.wolfram.com/ParetoDistribution.html Weisstein, Eric W. "pareto Distribution." From MathWorld--A Wolfram Web Resource.] ]] ] [h4 References] * [@http://en.wikipedia.org/wiki/pareto_distribution Pareto Distribution] * [@http://mathworld.wolfram.com/paretoDistribution.html Weisstein, Eric W. "Pareto Distribution." From MathWorld--A Wolfram Web Resource.] +* Handbook of Statistical Distributions with Applications, K Krishnamoorthy, ISBN 1-58488-635-8, Chapter 23, pp 257 - 267. +(Note the meaning of a and b is reversed in Wolfram and Krishnamoorthy). [endsect][/section:pareto pareto] -[/ - Copyright 2006 John Maddock and Paul A. Bristow. +[/ + Copyright 2006, 2009 John Maddock and Paul A. Bristow. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). diff --git a/doc/sf_and_dist/distributions/students_t_examples.qbk b/doc/sf_and_dist/distributions/students_t_examples.qbk index bc4c35dea..354b6a5e9 100644 --- a/doc/sf_and_dist/distributions/students_t_examples.qbk +++ b/doc/sf_and_dist/distributions/students_t_examples.qbk @@ -509,14 +509,13 @@ Confidence Estimated Estimated Value (%) Sample Size Sample Size (one sided test) (two sided test) _______________________________________________________________ - 50.000 2 3 - 75.000 4 5 - 90.000 8 10 - 95.000 12 14 - 99.000 21 23 - 99.900 36 38 - 99.990 51 54 - 99.999 67 69 + 75.000 3 4 + 90.000 7 9 + 95.000 11 13 + 99.000 20 22 + 99.900 35 37 + 99.990 50 53 + 99.999 66 68 '''] So in this case, many more measurements would have had to be made, diff --git a/doc/sf_and_dist/ellint_legendre.qbk b/doc/sf_and_dist/ellint_legendre.qbk index b964391cd..0808058df 100644 --- a/doc/sf_and_dist/ellint_legendre.qbk +++ b/doc/sf_and_dist/ellint_legendre.qbk @@ -257,11 +257,6 @@ would be complex). [optional_policy] -[caution In addition, the region where ['n > 1] and [phi][space] ['is not in the range] -\[0, [pi]\/2\] is currently unsupported and returns the result of __domain_error. -For this reason it is recomended that you keep [phi][space] inside its "natural" range -of \[0, [pi]\/2\].] - template ``__sf_result`` ellint_3(T1 k, T2 n); @@ -275,7 +270,7 @@ Returns the complete elliptic integral of the first kind ['[Pi](n, k)]: Requires ['-1 <= k <= 1] and ['n < 1], otherwise returns the result of __domain_error (outside this range the result would be complex). -[opitonal_policy] +[optional_policy] [heading Accuracy] @@ -322,7 +317,13 @@ Then the relations: ['[Pi](n, -[phi], k) = -[Pi](n, [phi], k)] -['[Pi](n, [phi]+m[pi], k) = [Pi](n, [phi], k) + 2m[Pi](n, k)] +['[Pi](n, [phi]+m[pi], k) = [Pi](n, [phi], k) + 2m[Pi](n, k) ; n <= 1] + +['[Pi](n, [phi]+m[pi], k) = [Pi](n, [phi], k) ; n > 1] +[footnote I haven't been able to find a literature reference for this +relation, but it appears to be the convention used by Mathematica. +Intuitively the first ['2 * m * [Pi](n, k)] terms cancel out as the +derivative alternates between +[infin] and -[infin].] are used to move [phi][space] to the range \[0, [pi]\/2\]. @@ -335,9 +336,4 @@ and [equation ellint26] -The remaining problem area occurs when n > 1 and [phi][space] is outside -the range \[0, [pi]\/2\]. In this range the reduction formula for -large [phi][space] can no longer be applied. Likewise the identities 17.7.7/8 -in A&S for reducing n to the range \[0,1\] appear to be no longer applicable. - [endsect] diff --git a/doc/sf_and_dist/equations/generate.sh b/doc/sf_and_dist/equations/generate.sh index 677ab577f..e936908d5 100755 --- a/doc/sf_and_dist/equations/generate.sh +++ b/doc/sf_and_dist/equations/generate.sh @@ -7,8 +7,8 @@ # # Paths to tools come first, change these to match your system: # -math2svg='C:\download\open\SVGMath-0.3.1\math2svg.py' -python=/cygdrive/c/Python25/python.exe +math2svg='d:\download\open\SVGMath-0.3.1\math2svg.py' +python=/cygdrive/c/Python26/python.exe inkscape=/cygdrive/c/progra~1/Inkscape/inkscape # Image DPI: dpi=120 @@ -29,3 +29,4 @@ done + diff --git a/doc/sf_and_dist/equations/hypergeometric1.mml b/doc/sf_and_dist/equations/hypergeometric1.mml new file mode 100644 index 000000000..91605ca26 --- /dev/null +++ b/doc/sf_and_dist/equations/hypergeometric1.mml @@ -0,0 +1,117 @@ + +]> + +hypergeometric1 + + + + + + f + + + k + ; + r + , + n + , + N + + + + = + + + + n + ! + r + ! + + + N + + n + + + ! + + + N + + r + + + ! + + + N + ! + k + ! + + + n + + k + + + ! + + + r + + k + + + ! + + + N + + n + + r + + + k + + + ! + + + + ; + + max + + + 0, + N + + r + + n + + + k + + + < + = + k + < + = + min + + + r + , + n + + + + + + diff --git a/doc/sf_and_dist/equations/hypergeometric1.png b/doc/sf_and_dist/equations/hypergeometric1.png new file mode 100644 index 000000000..8d40b1f53 Binary files /dev/null and b/doc/sf_and_dist/equations/hypergeometric1.png differ diff --git a/doc/sf_and_dist/equations/hypergeometric1.svg b/doc/sf_and_dist/equations/hypergeometric1.svg new file mode 100644 index 000000000..8f273d9d3 --- /dev/null +++ b/doc/sf_and_dist/equations/hypergeometric1.svg @@ -0,0 +1,2 @@ + +f(k;r,n,N)=n!r!(N−n)!(N−r)!N!k!(n−k)!(r−k)!(N−n−r+k)!;max(0,N−r−n+k)<=k<=min(r,n) \ No newline at end of file diff --git a/doc/sf_and_dist/equations/hypergeometric2.mml b/doc/sf_and_dist/equations/hypergeometric2.mml new file mode 100644 index 000000000..6af01b75d --- /dev/null +++ b/doc/sf_and_dist/equations/hypergeometric2.mml @@ -0,0 +1,50 @@ + +]> + +hypergeometric2 + + + + + + N + ! + + = + + + + + i + = + 0 + + + + p + i + + < + N + + + + + + p + i + + + + + e + i + + + + + + + diff --git a/doc/sf_and_dist/equations/hypergeometric2.png b/doc/sf_and_dist/equations/hypergeometric2.png new file mode 100644 index 000000000..3629a13eb Binary files /dev/null and b/doc/sf_and_dist/equations/hypergeometric2.png differ diff --git a/doc/sf_and_dist/equations/hypergeometric2.svg b/doc/sf_and_dist/equations/hypergeometric2.svg new file mode 100644 index 000000000..b2c918eb5 --- /dev/null +++ b/doc/sf_and_dist/equations/hypergeometric2.svg @@ -0,0 +1,2 @@ + +N!=âˆi=0pi<Npiei \ No newline at end of file diff --git a/doc/sf_and_dist/equations/hypergeometric3.mml b/doc/sf_and_dist/equations/hypergeometric3.mml new file mode 100644 index 000000000..b81424687 --- /dev/null +++ b/doc/sf_and_dist/equations/hypergeometric3.mml @@ -0,0 +1,60 @@ + +]> + +hypergeometric3 + + + + + + + + e + i + + + + = + + + + + j + = + 1 + + + + p + + i + + j + + + N + + + flοor + + + + N + + + p + + i + + j + + + + + + + + + diff --git a/doc/sf_and_dist/equations/hypergeometric3.png b/doc/sf_and_dist/equations/hypergeometric3.png new file mode 100644 index 000000000..b9f76aea5 Binary files /dev/null and b/doc/sf_and_dist/equations/hypergeometric3.png differ diff --git a/doc/sf_and_dist/equations/hypergeometric3.svg b/doc/sf_and_dist/equations/hypergeometric3.svg new file mode 100644 index 000000000..2d53025e2 --- /dev/null +++ b/doc/sf_and_dist/equations/hypergeometric3.svg @@ -0,0 +1,2 @@ + +ei=∑j=1pij≤Nflοor(Npij) \ No newline at end of file diff --git a/doc/sf_and_dist/equations/hypergeometric4.mml b/doc/sf_and_dist/equations/hypergeometric4.mml new file mode 100644 index 000000000..6da4a4373 --- /dev/null +++ b/doc/sf_and_dist/equations/hypergeometric4.mml @@ -0,0 +1,60 @@ + +]> + +hypergeometric4 + + + + + + f + + + k + ; + r + , + n + , + N + + + + = + + + + + i + = + 0 + + + + p + i + + < + N + + + + + + p + i + + + + + e + i + + + + + + + diff --git a/doc/sf_and_dist/equations/hypergeometric4.png b/doc/sf_and_dist/equations/hypergeometric4.png new file mode 100644 index 000000000..a3e219b92 Binary files /dev/null and b/doc/sf_and_dist/equations/hypergeometric4.png differ diff --git a/doc/sf_and_dist/equations/hypergeometric4.svg b/doc/sf_and_dist/equations/hypergeometric4.svg new file mode 100644 index 000000000..8814d8618 --- /dev/null +++ b/doc/sf_and_dist/equations/hypergeometric4.svg @@ -0,0 +1,2 @@ + +f(k;r,n,N)=âˆi=0pi<Npiei \ No newline at end of file diff --git a/doc/sf_and_dist/equations/hypergeometric5.mml b/doc/sf_and_dist/equations/hypergeometric5.mml new file mode 100644 index 000000000..a1fc31392 --- /dev/null +++ b/doc/sf_and_dist/equations/hypergeometric5.mml @@ -0,0 +1,159 @@ + +]> + +hypergeometric5 + + + + + + + + + f + + + k + + + 1 + ; + r + , + n + , + N + + + + = + + + + + + n + + k + + + + + r + + k + + + + + + + k + + + 1 + + + + + N + + n + + r + + + k + + + 1 + + + + + f + + + k + ; + r + , + n + , + N + + + + + + + f + + + k + + 1 + ; + r + , + n + , + N + + + + = + + + + x + + + N + + n + + r + + + k + + + + + + + n + + k + + + 1 + + + + + r + + k + + + 1 + + + + + f + + + k + ; + r + , + n + , + N + + + + + + + + + diff --git a/doc/sf_and_dist/equations/hypergeometric5.png b/doc/sf_and_dist/equations/hypergeometric5.png new file mode 100644 index 000000000..7e83643fe Binary files /dev/null and b/doc/sf_and_dist/equations/hypergeometric5.png differ diff --git a/doc/sf_and_dist/equations/hypergeometric5.svg b/doc/sf_and_dist/equations/hypergeometric5.svg new file mode 100644 index 000000000..143e46d5b --- /dev/null +++ b/doc/sf_and_dist/equations/hypergeometric5.svg @@ -0,0 +1,2 @@ + +f(k+1;r,n,N)=(n−k)(r−k)(k+1)(N−n−r+k+1)f(k;r,n,N)f(k−1;r,n,N)=x(N−n−r+k)(n−k+1)(r−k+1)f(k;r,n,N) \ No newline at end of file diff --git a/doc/sf_and_dist/equations/hypergeometric6.mml b/doc/sf_and_dist/equations/hypergeometric6.mml new file mode 100644 index 000000000..f58fa107e --- /dev/null +++ b/doc/sf_and_dist/equations/hypergeometric6.mml @@ -0,0 +1,295 @@ + +]> + +hypergeometric6 + + + + + + + + + mean + + = + + + + r + n + + N + + + + + + mode + + = + + floor + + + + + + + r + + + 1 + + + + + n + + + 1 + + + + + N + + + 2 + + + + + + + + + variance + + = + + + + r + + + + n + N + + + + + + 1 + + + n + N + + + + + + N + + r + + + + + + N + + 1 + + + + + + + + skewness + + = + + + + + + N + + 2 + n + + + + + + N + + 1 + + + + + + N + + 2 + r + + + + + + + r + n + + + N + + n + + + + + N + + r + + + + + + + N + + 2 + + + + + + + + + kurtosis excess + + = + + + + + + + N + 2 + + + + N + + 1 + + + + + r + + + N + + 2 + + + + + N + + 3 + + + + + N + + r + + + + + + + + + + + N + + + N + + + 1 + + + + 6 + N + + + N + + r + + + + + n + + + N + + n + + + + + + + + + 3 + r + + + N + + r + + + + + N + + + 6 + + + + + + N + 2 + + + + + 6 + + + + + + + + + diff --git a/doc/sf_and_dist/equations/hypergeometric6.png b/doc/sf_and_dist/equations/hypergeometric6.png new file mode 100644 index 000000000..d6a7f0c7f Binary files /dev/null and b/doc/sf_and_dist/equations/hypergeometric6.png differ diff --git a/doc/sf_and_dist/equations/hypergeometric6.svg b/doc/sf_and_dist/equations/hypergeometric6.svg new file mode 100644 index 000000000..ee36304bd --- /dev/null +++ b/doc/sf_and_dist/equations/hypergeometric6.svg @@ -0,0 +1,2 @@ + +mean=rnNmode=floor((r+1)(n+1)N+2)variance=r(nN)(1−nN)(N−r)(N−1)skewness=(N−2n)(N−1)(N−2r)rn(N−n)(N−r)(N−2)kurtosis excess=(N2(N−1)r(N−2)(N−3)(N−r))(N(N+1)−6N(N−r)n(N−n)+3r(N−r)(N+6)N2−6) \ No newline at end of file diff --git a/doc/sf_and_dist/equations/laplace_pdf.mml b/doc/sf_and_dist/equations/laplace_pdf.mml new file mode 100644 index 000000000..6ba8cc8d2 --- /dev/null +++ b/doc/sf_and_dist/equations/laplace_pdf.mml @@ -0,0 +1,52 @@ + +]> + +laplace_pdf + + + + + f + + + x + ; + μ + , + σ + + + + = + + + 1 + + 2 + σ + + + + e + + + + + | + x + + μ + | + + + σ + + + + + + + + \ No newline at end of file diff --git a/doc/sf_and_dist/equations/laplace_pdf.png b/doc/sf_and_dist/equations/laplace_pdf.png new file mode 100644 index 000000000..b299820f8 Binary files /dev/null and b/doc/sf_and_dist/equations/laplace_pdf.png differ diff --git a/doc/sf_and_dist/equations/laplace_pdf.svg b/doc/sf_and_dist/equations/laplace_pdf.svg new file mode 100644 index 000000000..579645acb --- /dev/null +++ b/doc/sf_and_dist/equations/laplace_pdf.svg @@ -0,0 +1,2 @@ + +f(x;μ,σ)=12σe−|x−μ|σ \ No newline at end of file diff --git a/doc/sf_and_dist/graphs/dist_graphs.cpp b/doc/sf_and_dist/graphs/dist_graphs.cpp index 195d9401a..d2b02b05f 100644 --- a/doc/sf_and_dist/graphs/dist_graphs.cpp +++ b/doc/sf_and_dist/graphs/dist_graphs.cpp @@ -1,5 +1,16 @@ -// (C) Copyright John Maddock 2008. -// Copyright Paul A. Bristow 2008 +/*! \file dist_graphs.cpp + \brief Produces Scalable Vector Graphic (.svg) files for all distributions. + \details These files can be viewed using most browsers, + though MS Internet Explorer requires a plugin from Adobe. + These file can be converted to .png using Inkscape + (see www.inkscape.org) Export Bit option which by default produces + a Portable Network Graphic file with that same filename but .png suffix instead of .svg. + Using Python, generate.sh does this conversion automatically for all .svg files in a folder. + + \author John Maddock and Paul A. Bristow + */ +// Copyright John Maddock 2008. +// Copyright Paul A. Bristow 2008, 2009 // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -23,27 +34,30 @@ #include template -struct is_discrete_distribution +struct is_discrete_distribution : public boost::mpl::false_{}; template -struct is_discrete_distribution > +struct is_discrete_distribution > : public boost::mpl::true_{}; template -struct is_discrete_distribution > +struct is_discrete_distribution > : public boost::mpl::true_{}; template -struct is_discrete_distribution > +struct is_discrete_distribution > : public boost::mpl::true_{}; template -struct is_discrete_distribution > +struct is_discrete_distribution > + : public boost::mpl::true_{}; +template +struct is_discrete_distribution > : public boost::mpl::true_{}; template struct value_finder { - value_finder(Dist const& d, typename Dist::value_type v) + value_finder(Dist const& d, typename Dist::value_type v) : m_dist(d), m_value(v) {} inline typename Dist::value_type operator()(const typename Dist::value_type& x) @@ -79,9 +93,9 @@ public: // double mod; try - { - mod = mode(d); - } + { + mod = mode(d); + } catch(const std::domain_error& ) { mod = a; @@ -96,7 +110,7 @@ public: double peek_y = pdf(d, mod); double min_y = peek_y / 20; // - // If the extent is "infinite" then find out how large it + // If the extent is "infinite" then find out how large it // has to be for the PDF to decay to min_y: // if(a <= -(std::numeric_limits::max)()) @@ -130,7 +144,7 @@ public: } // // Recalculate peek_y and location of mod so that - // it's not too close to one end of the graph: + // it's not too close to one end of the graph: // otherwise we may be shooting off to infinity. // if(!is_discrete_distribution::value) @@ -157,7 +171,7 @@ public: } else { - if(a < m_min_x) + if(a < m_min_x) m_min_x = a; if(b > m_max_x) m_max_x = b; @@ -168,7 +182,7 @@ public: { using namespace boost::svg; - static const svg_color colors[5] = + static const svg_color colors[5] = { darkblue, darkred, @@ -291,7 +305,7 @@ public: .line_color(colors[color_index]) .line_width(1.) .shape(none) - .area_fill(colors[color_index]); + .area_fill(colors[color_index]); ++color_index; color_index = color_index % (sizeof(colors)/sizeof(colors[0])); } @@ -307,21 +321,21 @@ private: int main() { - distribution_plotter > + distribution_plotter > gamma_plotter; gamma_plotter.add(boost::math::gamma_distribution<>(1), "shape = 0.5"); gamma_plotter.add(boost::math::gamma_distribution<>(2), "shape = 1"); gamma_plotter.add(boost::math::gamma_distribution<>(4), "shape = 3"); gamma_plotter.plot("Gamma Distribution PDF With Scale = 1", "gamma1_pdf.svg"); - distribution_plotter > + distribution_plotter > gamma_plotter2; gamma_plotter2.add(boost::math::gamma_distribution<>(2, 0.5), "scale = 2"); gamma_plotter2.add(boost::math::gamma_distribution<>(2, 1), "scale = 0.5"); gamma_plotter2.add(boost::math::gamma_distribution<>(2, 2), "scale = 2"); gamma_plotter2.plot("Gamma Distribution PDF With Shape = 2", "gamma2_pdf.svg"); - distribution_plotter + distribution_plotter normal_plotter; normal_plotter.add(boost::math::normal(0, 1), "μ = 0, σ = 1"); normal_plotter.add(boost::math::normal(0, 0.5), "μ = 0, σ = 0.5"); @@ -330,7 +344,16 @@ int main() normal_plotter.add(boost::math::normal(1, 1), "μ = 1, σ = 1"); normal_plotter.plot("Normal Distribution PDF", "normal_pdf.svg"); - distribution_plotter + distribution_plotter + laplace_plotter; + laplace_plotter.add(boost::math::laplace(0, 1), "μ = 0, σ = 1"); + laplace_plotter.add(boost::math::laplace(0, 0.5), "μ = 0, σ = 0.5"); + laplace_plotter.add(boost::math::laplace(0, 2), "μ = 0, σ = 2"); + laplace_plotter.add(boost::math::laplace(-1, 1), "μ = -1, σ = 1"); + laplace_plotter.add(boost::math::laplace(1, 1), "μ = 1, σ = 1"); + laplace_plotter.plot("Laplace Distribution PDF", "laplace_pdf.svg"); + + distribution_plotter nc_cs_plotter; nc_cs_plotter.add(boost::math::non_central_chi_squared(20, 0), "v=20, λ=0"); nc_cs_plotter.add(boost::math::non_central_chi_squared(20, 1), "v=20, λ=1"); @@ -340,7 +363,7 @@ int main() nc_cs_plotter.add(boost::math::non_central_chi_squared(20, 100), "v=20, λ=100"); nc_cs_plotter.plot("Non Central Chi Squared PDF", "nccs_pdf.svg"); - distribution_plotter + distribution_plotter nc_beta_plotter; nc_beta_plotter.add(boost::math::non_central_beta(10, 15, 0), "α=10, β=15, δ=0"); nc_beta_plotter.add(boost::math::non_central_beta(10, 15, 1), "α=10, β=15, δ=1"); @@ -350,7 +373,7 @@ int main() nc_beta_plotter.add(boost::math::non_central_beta(10, 15, 100), "α=10, β=15, δ=100"); nc_beta_plotter.plot("Non Central Beta PDF", "nc_beta_pdf.svg"); - distribution_plotter + distribution_plotter nc_f_plotter; nc_f_plotter.add(boost::math::non_central_f(10, 20, 0), "v1=10, v2=20, λ=0"); nc_f_plotter.add(boost::math::non_central_f(10, 20, 1), "v1=10, v2=20, λ=1"); @@ -360,7 +383,7 @@ int main() nc_f_plotter.add(boost::math::non_central_f(10, 20, 100), "v1=10, v2=20, λ=100"); nc_f_plotter.plot("Non Central F PDF", "nc_f_pdf.svg"); - distribution_plotter + distribution_plotter nc_t_plotter; nc_t_plotter.add(boost::math::non_central_t(10, -10), "v=10, δ=-10"); nc_t_plotter.add(boost::math::non_central_t(10, -5), "v=10, δ=-5"); @@ -369,7 +392,7 @@ int main() nc_t_plotter.add(boost::math::non_central_t(10, 10), "v=10, δ=10"); nc_t_plotter.plot("Non Central T PDF", "nc_t_pdf.svg"); - distribution_plotter > + distribution_plotter > beta_plotter; beta_plotter.add(boost::math::beta_distribution<>(0.5, 0.5), "alpha=0.5, beta=0.5"); beta_plotter.add(boost::math::beta_distribution<>(5, 1), "alpha=5, beta=1"); @@ -378,21 +401,21 @@ int main() beta_plotter.add(boost::math::beta_distribution<>(2, 5), "alpha=2, beta=5"); beta_plotter.plot("Beta Distribution PDF", "beta_pdf.svg"); - distribution_plotter > + distribution_plotter > cauchy_plotter; cauchy_plotter.add(boost::math::cauchy_distribution<>(-5, 1), "location = -5"); cauchy_plotter.add(boost::math::cauchy_distribution<>(0, 1), "location = 0"); cauchy_plotter.add(boost::math::cauchy_distribution<>(5, 1), "location = 5"); cauchy_plotter.plot("Cauchy Distribution PDF (scale = 1)", "cauchy_pdf1.svg"); - distribution_plotter > + distribution_plotter > cauchy_plotter2; cauchy_plotter2.add(boost::math::cauchy_distribution<>(0, 0.5), "scale = 0.5"); cauchy_plotter2.add(boost::math::cauchy_distribution<>(0, 1), "scale = 1"); cauchy_plotter2.add(boost::math::cauchy_distribution<>(0, 2), "scale = 2"); cauchy_plotter2.plot("Cauchy Distribution PDF (location = 0)", "cauchy_pdf2.svg"); - distribution_plotter > + distribution_plotter > chi_squared_plotter; //chi_squared_plotter.add(boost::math::chi_squared_distribution<>(1), "v=1"); chi_squared_plotter.add(boost::math::chi_squared_distribution<>(2), "v=2"); @@ -400,28 +423,28 @@ int main() chi_squared_plotter.add(boost::math::chi_squared_distribution<>(10), "v=10"); chi_squared_plotter.plot("Chi Squared Distribution PDF", "chi_squared_pdf.svg"); - distribution_plotter > + distribution_plotter > exponential_plotter; exponential_plotter.add(boost::math::exponential_distribution<>(0.5), "λ=1"); exponential_plotter.add(boost::math::exponential_distribution<>(1), "λ=2"); exponential_plotter.add(boost::math::exponential_distribution<>(2), "λ=5"); exponential_plotter.plot("Exponential Distribution PDF", "exponential_pdf.svg"); - distribution_plotter > + distribution_plotter > extreme_value_plotter; extreme_value_plotter.add(boost::math::extreme_value_distribution<>(-5), "location=1"); extreme_value_plotter.add(boost::math::extreme_value_distribution<>(0), "location=2"); extreme_value_plotter.add(boost::math::extreme_value_distribution<>(5), "location=5"); extreme_value_plotter.plot("Extreme Value Distribution PDF (shape=1)", "extreme_value_pdf1.svg"); - distribution_plotter > + distribution_plotter > extreme_value_plotter2; extreme_value_plotter2.add(boost::math::extreme_value_distribution<>(0, 0.5), "shape=0.5"); extreme_value_plotter2.add(boost::math::extreme_value_distribution<>(0, 1), "shape=1"); extreme_value_plotter2.add(boost::math::extreme_value_distribution<>(0, 2), "shape=2"); extreme_value_plotter2.plot("Extreme Value Distribution PDF (location=0)", "extreme_value_pdf2.svg"); - distribution_plotter > + distribution_plotter > fisher_f_plotter; fisher_f_plotter.add(boost::math::fisher_f_distribution<>(4, 4), "n=4, m=4"); fisher_f_plotter.add(boost::math::fisher_f_distribution<>(10, 4), "n=10, m=4"); @@ -429,35 +452,35 @@ int main() fisher_f_plotter.add(boost::math::fisher_f_distribution<>(4, 10), "n=4, m=10"); fisher_f_plotter.plot("F Distribution PDF", "fisher_f_pdf.svg"); - distribution_plotter > + distribution_plotter > lognormal_plotter; lognormal_plotter.add(boost::math::lognormal_distribution<>(-1), "location=-1"); lognormal_plotter.add(boost::math::lognormal_distribution<>(0), "location=0"); lognormal_plotter.add(boost::math::lognormal_distribution<>(1), "location=1"); lognormal_plotter.plot("Lognormal Distribution PDF (scale=1)", "lognormal_pdf1.svg"); - distribution_plotter > + distribution_plotter > lognormal_plotter2; lognormal_plotter2.add(boost::math::lognormal_distribution<>(0, 0.5), "scale=0.5"); lognormal_plotter2.add(boost::math::lognormal_distribution<>(0, 1), "scale=1"); lognormal_plotter2.add(boost::math::lognormal_distribution<>(0, 2), "scale=2"); lognormal_plotter2.plot("Lognormal Distribution PDF (location=0)", "lognormal_pdf2.svg"); - distribution_plotter > - pareto_plotter; - pareto_plotter.add(boost::math::pareto_distribution<>(1), "location=1"); - pareto_plotter.add(boost::math::pareto_distribution<>(2), "location=2"); - pareto_plotter.add(boost::math::pareto_distribution<>(3), "location=3"); - pareto_plotter.plot("Pareto Distribution PDF (scale=1)", "pareto_pdf1.svg"); + distribution_plotter > + pareto_plotter; // Rely on 2nd parameter shape = 1 default. + pareto_plotter.add(boost::math::pareto_distribution<>(1), "scale=1"); + pareto_plotter.add(boost::math::pareto_distribution<>(2), "scale=2"); + pareto_plotter.add(boost::math::pareto_distribution<>(3), "scale=3"); + pareto_plotter.plot("Pareto Distribution PDF (shape=1)", "pareto_pdf1.svg"); - distribution_plotter > + distribution_plotter > pareto_plotter2; - pareto_plotter2.add(boost::math::pareto_distribution<>(1, 0.5), "scale=0.5"); - pareto_plotter2.add(boost::math::pareto_distribution<>(1, 1), "scale=1"); - pareto_plotter2.add(boost::math::pareto_distribution<>(1, 2), "scale=2"); - pareto_plotter2.plot("Pareto Distribution PDF (location=1)", "pareto_pdf2.svg"); + pareto_plotter2.add(boost::math::pareto_distribution<>(1, 0.5), "shape=0.5"); + pareto_plotter2.add(boost::math::pareto_distribution<>(1, 1), "shape=1"); + pareto_plotter2.add(boost::math::pareto_distribution<>(1, 2), "shape=2"); + pareto_plotter2.plot("Pareto Distribution PDF (scale=1)", "pareto_pdf2.svg"); - distribution_plotter > + distribution_plotter > rayleigh_plotter; rayleigh_plotter.add(boost::math::rayleigh_distribution<>(0.5), "σ=0.5"); rayleigh_plotter.add(boost::math::rayleigh_distribution<>(1), "σ=1"); @@ -466,7 +489,7 @@ int main() rayleigh_plotter.add(boost::math::rayleigh_distribution<>(10), "σ=10"); rayleigh_plotter.plot("Rayleigh Distribution PDF", "rayleigh_pdf.svg"); - distribution_plotter > + distribution_plotter > rayleigh_cdf_plotter(false); rayleigh_cdf_plotter.add(boost::math::rayleigh_distribution<>(0.5), "σ=0.5"); rayleigh_cdf_plotter.add(boost::math::rayleigh_distribution<>(1), "σ=1"); @@ -475,7 +498,7 @@ int main() rayleigh_cdf_plotter.add(boost::math::rayleigh_distribution<>(10), "σ=10"); rayleigh_cdf_plotter.plot("Rayleigh Distribution CDF", "rayleigh_cdf.svg"); - distribution_plotter > + distribution_plotter > triangular_plotter; triangular_plotter.add(boost::math::triangular_distribution<>(-1,0,1), "{-1,0,1}"); triangular_plotter.add(boost::math::triangular_distribution<>(0,1,1), "{0,1,1}"); @@ -484,7 +507,7 @@ int main() triangular_plotter.add(boost::math::triangular_distribution<>(-2,0,3), "{-2,0,3}"); triangular_plotter.plot("Triangular Distribution PDF", "triangular_pdf.svg"); - distribution_plotter > + distribution_plotter > triangular_cdf_plotter(false); triangular_cdf_plotter.add(boost::math::triangular_distribution<>(-1,0,1), "{-1,0,1}"); triangular_cdf_plotter.add(boost::math::triangular_distribution<>(0,1,1), "{0,1,1}"); @@ -493,14 +516,14 @@ int main() triangular_cdf_plotter.add(boost::math::triangular_distribution<>(-2,0,3), "{-2,0,3}"); triangular_cdf_plotter.plot("Triangular Distribution CDF", "triangular_cdf.svg"); - distribution_plotter > + distribution_plotter > students_t_plotter; students_t_plotter.add(boost::math::students_t_distribution<>(1), "v=1"); students_t_plotter.add(boost::math::students_t_distribution<>(5), "v=5"); students_t_plotter.add(boost::math::students_t_distribution<>(30), "v=30"); students_t_plotter.plot("Students T Distribution PDF", "students_t_pdf.svg"); - distribution_plotter > + distribution_plotter > weibull_plotter; weibull_plotter.add(boost::math::weibull_distribution<>(0.75), "shape=0.75"); weibull_plotter.add(boost::math::weibull_distribution<>(1), "shape=1"); @@ -508,14 +531,14 @@ int main() weibull_plotter.add(boost::math::weibull_distribution<>(10), "shape=10"); weibull_plotter.plot("Weibull Distribution PDF (scale=1)", "weibull_pdf1.svg"); - distribution_plotter > + distribution_plotter > weibull_plotter2; weibull_plotter2.add(boost::math::weibull_distribution<>(3, 0.5), "scale=0.5"); weibull_plotter2.add(boost::math::weibull_distribution<>(3, 1), "scale=1"); weibull_plotter2.add(boost::math::weibull_distribution<>(3, 2), "scale=2"); weibull_plotter2.plot("Weibull Distribution PDF (shape=3)", "weibull_pdf2.svg"); - distribution_plotter > + distribution_plotter > uniform_plotter; uniform_plotter.add(boost::math::uniform_distribution<>(0, 1), "{0,1}"); uniform_plotter.add(boost::math::uniform_distribution<>(0, 3), "{0,3}"); @@ -523,7 +546,7 @@ int main() uniform_plotter.add(boost::math::uniform_distribution<>(-1, 1), "{-1,1}"); uniform_plotter.plot("Uniform Distribution PDF", "uniform_pdf.svg"); - distribution_plotter > + distribution_plotter > uniform_cdf_plotter(false); uniform_cdf_plotter.add(boost::math::uniform_distribution<>(0, 1), "{0,1}"); uniform_cdf_plotter.add(boost::math::uniform_distribution<>(0, 3), "{0,3}"); @@ -531,53 +554,71 @@ int main() uniform_cdf_plotter.add(boost::math::uniform_distribution<>(-1, 1), "{-1,1}"); uniform_cdf_plotter.plot("Uniform Distribution CDF", "uniform_cdf.svg"); - distribution_plotter > + distribution_plotter > bernoulli_plotter; bernoulli_plotter.add(boost::math::bernoulli_distribution<>(0.25), "p=0.25"); bernoulli_plotter.add(boost::math::bernoulli_distribution<>(0.5), "p=0.5"); bernoulli_plotter.add(boost::math::bernoulli_distribution<>(0.75), "p=0.75"); bernoulli_plotter.plot("Bernoulli Distribution PDF", "bernoulli_pdf.svg"); - distribution_plotter > + distribution_plotter > bernoulli_cdf_plotter(false); bernoulli_cdf_plotter.add(boost::math::bernoulli_distribution<>(0.25), "p=0.25"); bernoulli_cdf_plotter.add(boost::math::bernoulli_distribution<>(0.5), "p=0.5"); bernoulli_cdf_plotter.add(boost::math::bernoulli_distribution<>(0.75), "p=0.75"); bernoulli_cdf_plotter.plot("Bernoulli Distribution CDF", "bernoulli_cdf.svg"); - distribution_plotter > + distribution_plotter > binomial_plotter; binomial_plotter.add(boost::math::binomial_distribution<>(5, 0.5), "n=5 p=0.5"); binomial_plotter.add(boost::math::binomial_distribution<>(20, 0.5), "n=20 p=0.5"); binomial_plotter.add(boost::math::binomial_distribution<>(50, 0.5), "n=50 p=0.5"); binomial_plotter.plot("Binomial Distribution PDF", "binomial_pdf_1.svg"); - distribution_plotter > + distribution_plotter > binomial_plotter2; binomial_plotter2.add(boost::math::binomial_distribution<>(20, 0.1), "n=20 p=0.1"); binomial_plotter2.add(boost::math::binomial_distribution<>(20, 0.5), "n=20 p=0.5"); binomial_plotter2.add(boost::math::binomial_distribution<>(20, 0.9), "n=20 p=0.9"); binomial_plotter2.plot("Binomial Distribution PDF", "binomial_pdf_2.svg"); - - distribution_plotter > + + distribution_plotter > negative_binomial_plotter; negative_binomial_plotter.add(boost::math::negative_binomial_distribution<>(20, 0.25), "n=20 p=0.25"); negative_binomial_plotter.add(boost::math::negative_binomial_distribution<>(20, 0.5), "n=20 p=0.5"); negative_binomial_plotter.add(boost::math::negative_binomial_distribution<>(20, 0.75), "n=20 p=0.75"); negative_binomial_plotter.plot("Negative Binomial Distribution PDF", "negative_binomial_pdf_1.svg"); - distribution_plotter > + distribution_plotter > negative_binomial_plotter2; negative_binomial_plotter2.add(boost::math::negative_binomial_distribution<>(10, 0.5), "n=10 p=0.5"); negative_binomial_plotter2.add(boost::math::negative_binomial_distribution<>(20, 0.5), "n=40 p=0.5"); negative_binomial_plotter2.add(boost::math::negative_binomial_distribution<>(70, 0.5), "n=70 p=0.5"); negative_binomial_plotter2.plot("Negative Binomial Distribution PDF", "negative_binomial_pdf_2.svg"); - distribution_plotter > + distribution_plotter > poisson_plotter; poisson_plotter.add(boost::math::poisson_distribution<>(5), "λ=1"); poisson_plotter.add(boost::math::poisson_distribution<>(10), "λ=10"); poisson_plotter.add(boost::math::poisson_distribution<>(20), "λ=50"); poisson_plotter.plot("Poisson Distribution PDF", "poisson_pdf_1.svg"); + distribution_plotter > + hypergeometric_plotter; + hypergeometric_plotter.add(boost::math::hypergeometric_distribution<>(30, 50, 500), "N=500, r=50, n=30"); + hypergeometric_plotter.add(boost::math::hypergeometric_distribution<>(30, 100, 500), "N=500, r=100, n=30"); + hypergeometric_plotter.add(boost::math::hypergeometric_distribution<>(30, 250, 500), "N=500, r=250, n=30"); + hypergeometric_plotter.add(boost::math::hypergeometric_distribution<>(30, 400, 500), "N=500, r=400, n=30"); + hypergeometric_plotter.add(boost::math::hypergeometric_distribution<>(30, 450, 500), "N=500, r=450, n=30"); + hypergeometric_plotter.plot("Hypergeometric Distribution PDF", "hypergeometric_pdf_1.svg"); + + distribution_plotter > + hypergeometric_plotter2; + hypergeometric_plotter2.add(boost::math::hypergeometric_distribution<>(50, 50, 500), "N=500, r=50, n=50"); + hypergeometric_plotter2.add(boost::math::hypergeometric_distribution<>(100, 50, 500), "N=500, r=50, n=100"); + hypergeometric_plotter2.add(boost::math::hypergeometric_distribution<>(250, 50, 500), "N=500, r=50, n=250"); + hypergeometric_plotter2.add(boost::math::hypergeometric_distribution<>(400, 50, 500), "N=500, r=50, n=400"); + hypergeometric_plotter2.add(boost::math::hypergeometric_distribution<>(450, 50, 500), "N=500, r=50, n=450"); + hypergeometric_plotter2.plot("Hypergeometric Distribution PDF", "hypergeometric_pdf_2.svg"); + } diff --git a/doc/sf_and_dist/graphs/generate.sh b/doc/sf_and_dist/graphs/generate.sh index 7a2a9271a..2a6e270de 100755 --- a/doc/sf_and_dist/graphs/generate.sh +++ b/doc/sf_and_dist/graphs/generate.sh @@ -7,8 +7,8 @@ # # Paths to tools come first, change these to match your system: # -math2svg='C:\download\open\SVGMath-0.3.1\math2svg.py' -python=/cygdrive/c/Python25/python.exe +math2svg='d:\download\open\SVGMath-0.3.1\math2svg.py' +python=/cygdrive/c/Python26/python.exe inkscape=/cygdrive/c/progra~1/Inkscape/inkscape # Image DPI: dpi=96 @@ -24,3 +24,4 @@ done + diff --git a/doc/sf_and_dist/graphs/hypergeometric_pdf_1.png b/doc/sf_and_dist/graphs/hypergeometric_pdf_1.png new file mode 100644 index 000000000..ef49ab155 Binary files /dev/null and b/doc/sf_and_dist/graphs/hypergeometric_pdf_1.png differ diff --git a/doc/sf_and_dist/graphs/hypergeometric_pdf_1.svg b/doc/sf_and_dist/graphs/hypergeometric_pdf_1.svg new file mode 100644 index 000000000..0cd332d27 --- /dev/null +++ b/doc/sf_and_dist/graphs/hypergeometric_pdf_1.svg @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + +0 +5 +10 +15 +20 +25 +30 +0 +0 +0.05 +0.1 +0.15 +0.2 +0.25 +0 + +Probability + +Random Variable + + + + + + + + + + + + + + + +N=500, r=50, n=30 +N=500, r=100, n=30 +N=500, r=250, n=30 +N=500, r=400, n=30 +N=500, r=450, n=30 + +Hypergeometric Distribution PDF + + + diff --git a/doc/sf_and_dist/graphs/hypergeometric_pdf_2.png b/doc/sf_and_dist/graphs/hypergeometric_pdf_2.png new file mode 100644 index 000000000..d81629825 Binary files /dev/null and b/doc/sf_and_dist/graphs/hypergeometric_pdf_2.png differ diff --git a/doc/sf_and_dist/graphs/hypergeometric_pdf_2.svg b/doc/sf_and_dist/graphs/hypergeometric_pdf_2.svg new file mode 100644 index 000000000..b10d34ef3 --- /dev/null +++ b/doc/sf_and_dist/graphs/hypergeometric_pdf_2.svg @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + +0 +10 +20 +30 +40 +50 +0 +0 +0.05 +0.1 +0.15 +0.2 +0 + +Probability + +Random Variable + + + + + + + + + + + + + + + +N=500, r=50, n=50 +N=500, r=50, n=100 +N=500, r=50, n=250 +N=500, r=50, n=400 +N=500, r=50, n=450 + +Hypergeometric Distribution PDF + + + diff --git a/doc/sf_and_dist/graphs/laplace_pdf.png b/doc/sf_and_dist/graphs/laplace_pdf.png new file mode 100644 index 000000000..29f390487 Binary files /dev/null and b/doc/sf_and_dist/graphs/laplace_pdf.png differ diff --git a/doc/sf_and_dist/graphs/laplace_pdf.svg b/doc/sf_and_dist/graphs/laplace_pdf.svg new file mode 100644 index 000000000..bc876e247 --- /dev/null +++ b/doc/sf_and_dist/graphs/laplace_pdf.svg @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + +0 +5 +0 +-5 +0 +0.1 +0.2 +0.3 +0.4 +0.5 +0.6 +0.7 +0.8 +0.9 +1 +1.1 +0 + +Probability + +Random Variable + + + + + + + + + + + + + + + +μ = 0, σ = 1 +μ = 0, σ = 0.5 +μ = 0, σ = 2 +μ = -1, σ = 1 +μ = 1, σ = 1 + +Laplace Distribution PDF + + + diff --git a/doc/sf_and_dist/graphs/laplace_pdf_mu.png b/doc/sf_and_dist/graphs/laplace_pdf_mu.png new file mode 100644 index 000000000..cb4b1642e Binary files /dev/null and b/doc/sf_and_dist/graphs/laplace_pdf_mu.png differ diff --git a/doc/sf_and_dist/graphs/laplace_pdf_mu.svg b/doc/sf_and_dist/graphs/laplace_pdf_mu.svg new file mode 100644 index 000000000..a272e4be7 --- /dev/null +++ b/doc/sf_and_dist/graphs/laplace_pdf_mu.svg @@ -0,0 +1,537 @@ + + + +Produced by GNUPLOT 4.2 patchlevel 4 + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 0.1 + + + + + 0.2 + + + + + 0.3 + + + + + 0.4 + + + + + 0.5 + + + + + -10 + + + + + -8 + + + + + -6 + + + + + -4 + + + + + -2 + + + + + 0 + + + + + 2 + + + + + 4 + + + + + 6 + + + + + 8 + + + + + 10 + + + + + Probability + + + + Random Variable + + + + + + + + μ = -6, σ = 1 + + + + + + + + + + + μ = 0, σ = 2 + + + + + + + + + + + μ = 2, σ = 4 + + + + + + + + + + + diff --git a/doc/sf_and_dist/graphs/laplace_pdf_sigma.png b/doc/sf_and_dist/graphs/laplace_pdf_sigma.png new file mode 100644 index 000000000..1f0f17b14 Binary files /dev/null and b/doc/sf_and_dist/graphs/laplace_pdf_sigma.png differ diff --git a/doc/sf_and_dist/graphs/laplace_pdf_sigma.svg b/doc/sf_and_dist/graphs/laplace_pdf_sigma.svg new file mode 100644 index 000000000..67825f48f --- /dev/null +++ b/doc/sf_and_dist/graphs/laplace_pdf_sigma.svg @@ -0,0 +1,537 @@ + + + +Produced by GNUPLOT 4.2 patchlevel 4 + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 0.1 + + + + + 0.2 + + + + + 0.3 + + + + + 0.4 + + + + + 0.5 + + + + + -10 + + + + + -8 + + + + + -6 + + + + + -4 + + + + + -2 + + + + + 0 + + + + + 2 + + + + + 4 + + + + + 6 + + + + + 8 + + + + + 10 + + + + + Probability + + + + Random Variable + + + + + + + + μ = 0, σ = 1 + + + + + + + + + + + μ = 0, σ = 2 + + + + + + + + + + + μ = 0, σ = 5 + + + + + + + + + + + diff --git a/doc/sf_and_dist/graphs/logistic_pdf.png b/doc/sf_and_dist/graphs/logistic_pdf.png new file mode 100644 index 000000000..7a1346bd5 Binary files /dev/null and b/doc/sf_and_dist/graphs/logistic_pdf.png differ diff --git a/doc/sf_and_dist/graphs/logistic_pdf.svg b/doc/sf_and_dist/graphs/logistic_pdf.svg new file mode 100644 index 000000000..40a48fd64 --- /dev/null +++ b/doc/sf_and_dist/graphs/logistic_pdf.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + +0 +5 +10 +0 +-5 +-10 +0 +0.1 +0.2 +0.3 +0.4 +0.5 +0 + +Probability + +Random Variable + + + + + + + + + + + + + +location=0, scale=1 +location=0, scale=3 +location=0, scale=0.5 +location=5, scale=1 + +Logistic Distribution PDF + + + diff --git a/doc/sf_and_dist/graphs/pareto_pdf1.png b/doc/sf_and_dist/graphs/pareto_pdf1.png index dbb373aa9..9d7376904 100644 Binary files a/doc/sf_and_dist/graphs/pareto_pdf1.png and b/doc/sf_and_dist/graphs/pareto_pdf1.png differ diff --git a/doc/sf_and_dist/graphs/pareto_pdf1.svg b/doc/sf_and_dist/graphs/pareto_pdf1.svg index 35c7b881e..208bf38b7 100644 --- a/doc/sf_and_dist/graphs/pareto_pdf1.svg +++ b/doc/sf_and_dist/graphs/pareto_pdf1.svg @@ -1,63 +1,64 @@ - - + - + - + - - - - - - + + + + + + -5 -10 -0 -0.1 -0.2 -0.3 -0.4 -0.5 -0.6 -0.7 -0.8 -0.9 -0 +5 +10 +0 +0.1 +0.2 +0.3 +0.4 +0.5 +0.6 +0.7 +0.8 +0.9 +0 -Probability +Probability -Random Variable - - - +Random Variable + + + - - - - - - - - - + + + + + -location=1 -location=2 -location=3 +scale=1 +scale=2 +scale=3 -Pareto Distribution PDF (scale=1) +Pareto Distribution PDF (shape=1) + + diff --git a/doc/sf_and_dist/graphs/pareto_pdf2.png b/doc/sf_and_dist/graphs/pareto_pdf2.png index 54ba8486a..d76017b54 100644 Binary files a/doc/sf_and_dist/graphs/pareto_pdf2.png and b/doc/sf_and_dist/graphs/pareto_pdf2.png differ diff --git a/doc/sf_and_dist/graphs/pareto_pdf2.svg b/doc/sf_and_dist/graphs/pareto_pdf2.svg index 7f7b31c71..2a2470208 100644 --- a/doc/sf_and_dist/graphs/pareto_pdf2.svg +++ b/doc/sf_and_dist/graphs/pareto_pdf2.svg @@ -1,62 +1,63 @@ - - + - + - + - - - - - - + + + + + + -1 -2 -3 -4 -5 -6 -7 -0 -0.5 -1 -1.5 -0 +1 +2 +3 +4 +5 +6 +7 +0 +0.5 +1 +1.5 +0 -Probability +Probability -Random Variable - - - +Random Variable + + + - - - - - + -scale=0.5 -scale=1 -scale=2 +shape=0.5 +shape=1 +shape=2 -Pareto Distribution PDF (location=1) +Pareto Distribution PDF (scale=1) + + diff --git a/doc/sf_and_dist/html/index.html b/doc/sf_and_dist/html/index.html index 42b8a9b34..3a44b1946 100644 --- a/doc/sf_and_dist/html/index.html +++ b/doc/sf_and_dist/html/index.html @@ -3,7 +3,7 @@ Math Toolkit - + @@ -42,11 +42,18 @@

Johan Råde

+

+Gautam Sewani +

+

+Thijs van den Berg +

-
+
-

+

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

@@ -72,9 +79,12 @@ and Policies
Thread Safety
Performance
+
If and How to Build + the Library and its Examples and Tests
History and What's New
-
C99 and TR1 C Functions
+
C99 and C++ TR1 C-style + Functions
Contact Info and Support
@@ -83,7 +93,20 @@
Statistical Distributions Tutorial
-
Overview
+
Overview of Distributions
+
+
Headers + and Namespaces
+
Distributions + are Objects
+
Generic + operations common to all distributions are non-member functions
+
+ Complements are supported too - and when to use them
+
+ Parameters can be calculated
+
Summary
+
Worked Examples
@@ -108,6 +131,8 @@ and Scale Examples
Comparison with C, R, FORTRAN-style Free Functions
+
Using the + Distributions from Within C#
Random Variates and Distribution Parameters
@@ -137,6 +162,12 @@
F Distribution
Gamma (and Erlang) Distribution
+
+ Hypergeometric Distribution
+
Laplace + Distribution
+
+ Logistic Distribution
Log Normal Distribution
@@ -287,39 +318,43 @@
asinh
atanh
-
Rounding Truncation and + +
Floating Point Utilities
+
+
Rounding Truncation and Integer Conversion
-
Rounding Functions
-
Truncation Functions
-
Integer and Fractional +
Rounding Functions
+
Truncation Functions
+
Integer and Fractional Part Splitting (modf)
-
Floating-Point Classification: +
Floating-Point Classification: Infinities and NaN's
-
Floating-Point Representation +
Sign Manipulation + Functions
+
Floating-Point Representation Distance (ULP), and Finding Adjacent Floating-Point Values
-
Finding - the Next Representable Value in a Specific Direction (nextafter)
-
Finding +
Finding the + Next Representable Value in a Specific Direction (nextafter)
+
Finding the Next Greater Representable Value (float_next)
-
Finding +
Finding the Next Smaller Representable Value (float_prior)
-
Calculating +
Calculating the Representation Distance Between Two Floating Point Values (ULP) float_distance
-
Advancing +
Advancing a Floating Point Value by a Specific Representation Distance (ULP) float_advance
-
TR1 and C99 external - "C" Functions
-
-
C99 and TR1 C Functions - Overview
-
C99 C Functions
-
TR1 C Functions - Quick Reference
+
TR1 and C99 external "C" + Functions
+
+
C99 and TR1 C Functions Overview
+
C99 C Functions
+
TR1 C Functions Quick + Reference
Internal Details and Tools (Experimental)
@@ -357,6 +392,8 @@
Using With NTL - a High-Precision Floating-Point Library
+
Using With MPFR / GMP + - a High-Precision Floating-Point Library
Conceptual Requirements for Real Number Types
Conceptual Requirements @@ -451,7 +488,7 @@

- +

Last revised: December 29, 2008 at 16:50:38 GMT

Last revised: May 22, 2009 at 11:23:00 GMT


diff --git a/doc/sf_and_dist/html/math_toolkit/backgrounders.html b/doc/sf_and_dist/html/math_toolkit/backgrounders.html index 91ccd20b9..4c401eb83 100644 --- a/doc/sf_and_dist/html/math_toolkit/backgrounders.html +++ b/doc/sf_and_dist/html/math_toolkit/backgrounders.html @@ -3,7 +3,7 @@ Backgrounders - + @@ -38,8 +38,9 @@
-
- + Handling of Functions that are Not Mathematically defined
@@ -276,7 +276,7 @@

- + Median of distributions
@@ -309,7 +309,7 @@ Basic Statistics. give more detail, in particular for discrete distributions.

- + Handling of Floating-Point Infinity
@@ -353,7 +353,7 @@ handling policies.

- + Scale, Shape and Location
@@ -380,7 +380,7 @@ functions, they can be added if required.

- + Notes on Implementation of Specific Functions & Distributions
@@ -392,7 +392,7 @@ 0 and upper = 1 would be more suitable.
- + Rational Approximations Used
@@ -435,7 +435,7 @@ to the "true" minimax solution.

- + Representation of Mathematical Constants
@@ -469,7 +469,7 @@
BOOST_DEFINE_MATH_CONSTANT(pi,
   3.141592653589793238462643383279502884197169399375105820974944,
   5923078164062862089986280348253421170679821480865132823066470938446095505,
-  0)                                              
+  0)
 

And used thus: @@ -487,16 +487,16 @@

So you cannot write

-
double p = boost::math::constants::pi<>();  // could not deduce template argument for 'T'  
+
double p = boost::math::constants::pi<>();  // could not deduce template argument for 'T'
 

Neither can you write:

-
double p = boost::math::constants::pi; // Context does not allow for disambiguation of overloaded function     
-double p = boost::math::constants::pi(); // Context does not allow for disambiguation of overloaded function     
+
double p = boost::math::constants::pi; // Context does not allow for disambiguation of overloaded function
+double p = boost::math::constants::pi(); // Context does not allow for disambiguation of overloaded function
 
- + Thread safety
@@ -521,7 +521,7 @@ the right thing here at some point.

- + Sources of Test Data
@@ -565,7 +565,7 @@ the underlying special function is known to be difficult to implement.

- + Creating and Managing the Equations
@@ -582,7 +582,7 @@ Convertion to SVG was achieved using SVGMath and a command line such as:

-
$for file in *.mml; do 
+
$for file in *.mml; do
 >/cygdrive/c/Python25/python.exe 'C:\download\open\SVGMath-0.3.1\math2svg.py' \
 >>$file > $(basename $file .mml).svg
 >done
@@ -629,8 +629,8 @@
 

Or using Inkscape and a command such as:

-
for file in *.svg; do 
-  /cygdrive/c/progra~1/Inkscape/inkscape -d 120 -e $(cygpath -a -w $(basename $file .svg).png) $(cygpath -a -w $file); 
+
for file in *.svg; do
+  /cygdrive/c/progra~1/Inkscape/inkscape -d 120 -e $(cygpath -a -w $(basename $file .svg).png) $(cygpath -a -w $file);
 done

Currently Inkscape seems to generate the better looking png's. @@ -639,20 +639,29 @@ done

The PDF is generated into \pdf\math.pdf using a command from a shell or command window with current directory \math_toolkit\libs\math\doc\sf_and_dist, typically:

-
bjam -a pdf
+
bjam -a pdf >math_pdf.log

Note that XEP will have to be configured to use and - embed whatever fonts are used by the SVG equations (if necessary - editing the sample xep.xml provided by the XEP installation). + embed whatever fonts are used by the SVG equations (almost certainly + editing the sample xep.xml provided by the XEP installation). If you fail + to do this you will get XEP warnings in the log file like +

+
[warning]could not find any font family matching "Times New Roman"; replaced by Helvetica
+

+ (html is the default so it is generated at math_toolkit\libs\math\doc\sf_and_dist\html\index.html + using command line >bjam -a > math_docs.log). +

+
<!-- Sample configuration for Windows TrueType fonts.  -->
+
+

+ <!-- Sample configuration for Windows TrueType fonts. --> is provided + in the xep.xml downloaded, but the Windows TrueType fonts are commented out.

- (html is generated at math_toolkit\libs\math\doc\sf_and_dist\html\index.html - using just bjam -a). + JM's XEP config file \xep\xep.xml has the following font configuration section + added:

-

- JM's XEP config file has the following font configuration section added: -

-
<font-group xml:base="file:/C:/Windows/Fonts/" label="Windows TrueType" embed="true" subset="true"> 
+
<font-group xml:base="file:/C:/Windows/Fonts/" label="Windows TrueType" embed="true" subset="true">
       <font-family name="Arial">
         <font><font-data ttf="arial.ttf"/></font>
         <font style="oblique"><font-data ttf="ariali.ttf"/></font>
@@ -692,14 +701,16 @@ done
<font weight="bold"><font-data ttf="palab.ttf"/></font> <font weight="bold" style="italic"><font-data ttf="palabi.ttf"/></font> </font-family> - - <font-family name="Lucida Sans Unicode"> - <font><font-data ttf="lsansuni.ttf"/></font> + + <font-family name"Lucida Sans Unicode"> + <!-- <font><font-data ttf"lsansuni.ttf"><font> --> + <!-- actually called l_10646.ttf on Windows 2000 and Vista Sp1 --> + <font><font-data ttf="l_10646.ttf"></font> </font-family>

PAB had to alter his because the Lucida Sans Unicode font had a different - name. Changes are very likely to be required if you are not using Windows. + name. Other changes are very likely to be required if you are not using Windows.

XZ authored his equations using the venerable Latex, JM converted these to @@ -726,7 +737,7 @@ done

HTML: this needs further investigation.

- + Producing Graphs
@@ -743,8 +754,9 @@ done
-
- + Motivation

@@ -98,7 +98,7 @@ functions divided by large powers into single (simpler) expressions.

- + The Approximation
@@ -160,7 +160,7 @@

- + Computing the Coefficients
@@ -204,7 +204,7 @@ multiplied by F as the last step.

- + Choosing the Right Parameters
@@ -228,7 +228,7 @@ computing to float precision with double precision arithmetic.

-

Table 53. Optimal choices for N and g when computing with +

Table 53. Optimal choices for N and g when computing with guard digits (source: Pugh)

@@ -371,7 +371,7 @@ exactly matches the machine epsilon for the type in question.

-

Table 54. Optimum value for N and g when computing at fixed +

Table 54. Optimum value for N and g when computing at fixed precision

@@ -536,7 +536,7 @@ is exact, and so isn't used for the gamma function.

- + References
    @@ -561,8 +561,9 @@
-
- + General references
@@ -91,7 +91,7 @@ Library (version 2), Walter E. Brown

- + Calculators* that we found (and used to cross-check - as far as their widely-varying accuracy allowed). @@ -101,7 +101,7 @@ Binomial Probability Distribution Calculator.

- + Other Libraries

@@ -161,8 +161,9 @@ -
-
- + Remez Step 1
@@ -205,7 +205,7 @@ to 5.6x10-4.

- + Remez Step 2
@@ -234,7 +234,7 @@ In our example we perform multi-point exchange.

- + Iteration

@@ -250,7 +250,7 @@ remez-4

- + Rational Approximations
@@ -299,7 +299,7 @@ number of terms overall.

- + Practical Considerations
@@ -407,7 +407,7 @@ desired minimax solution (5x10-4).

- + Remez Method Checklist
@@ -461,7 +461,7 @@
- + References

@@ -527,8 +527,9 @@ -
-
-
- + Finding the Location and Scale for Normal and similar distributions
@@ -50,7 +50,7 @@ using boost::math::complement; // Will be needed by users who want to use complements.
- + find_location function
@@ -80,7 +80,7 @@ }} // namespaces
- + find_scale function
@@ -130,8 +130,9 @@ -
-
- + References
    @@ -339,8 +339,9 @@
-
- + References

@@ -615,8 +615,9 @@ from presumed-known mean and variance. -

- + Estimating the Number of Trials Required for a Certain Number of Successes
@@ -431,7 +431,7 @@ of seeing 10 events that occur with frequency one half.

- + Estimating the Maximum Number of Trials to Ensure no more than a Certain Number of Successes @@ -479,7 +479,7 @@ Worked Example.

- + Non-member Accessors
@@ -504,7 +504,7 @@ in the context of this distribution:

-

Table 11. Meaning of the non-member accessors

+

Table 11. Meaning of the non-member accessors

@@ -627,7 +627,7 @@

- + Examples

@@ -635,7 +635,7 @@ examples are available illustrating the use of the binomial distribution.

- + Accuracy

@@ -645,7 +645,7 @@ please refer to these functions for information on accuracy.

- + Implementation

@@ -886,7 +886,7 @@

- + References
    @@ -907,8 +907,9 @@
-
- + References
    @@ -291,8 +291,9 @@
-
- + References
    @@ -394,8 +394,9 @@ independent, normally distributed random
-
- + references
    @@ -310,8 +310,9 @@
-
-
-

-PrevUpHomeNext +PrevUpHomeNext
@@ -88,7 +88,7 @@

- + Member Functions
@@ -121,7 +121,7 @@ Returns the scale parameter of this distribution.

- + Non-member Accessors
@@ -141,7 +141,7 @@ The domain of the random variable is [0,+∞].

- + Accuracy

@@ -150,7 +150,7 @@ function, and as such should have very low error rates.

- + Implementation

@@ -318,8 +318,9 @@

-

-PrevUpHomeNext +PrevUpHomeNext
diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_beta_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_beta_dist.html index 2991d59f0..a7a250a32 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_beta_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_beta_dist.html @@ -3,7 +3,7 @@ Noncentral Beta Distribution - + @@ -96,7 +96,7 @@ is a central χ2 random variable with

- + Member Functions
@@ -128,7 +128,7 @@ is a central χ2 random variable with was constructed.

- + Non-member Accessors
@@ -152,7 +152,7 @@ is a central χ2 random variable with The domain of the random variable is [0, 1].

- + Accuracy

@@ -168,7 +168,7 @@ is a central χ2 random variable with zero error.

-

Table 13. Errors In CDF of the Noncentral Beta

+

Table 13. Errors In CDF of the Noncentral Beta

@@ -295,7 +295,7 @@ is a central χ2 random variable with functions are broadly similar.

- + Tests

@@ -307,7 +307,7 @@ is a central χ2 random variable with tests.

- + Implementation

@@ -398,8 +398,9 @@ is a central χ2 random variable with

-