diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 4b96d51ba..fe21fc30f 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -13,9 +13,10 @@ project #intel-linux:off intel-darwin:off msvc-7.1:off - gcc:-fvisibility=hidden + #gcc:-fvisibility=hidden intel-linux:-fvisibility=hidden sun:-xldscope=hidden + [ check-target-builds ../config//has_gcc_visibility : -fvisibility=hidden : ] ; cpp-pch pch : ../src/tr1/pch.hpp : ../src/tr1 shared:BOOST_MATH_TR1_DYN_LINK=1 ; diff --git a/config/Jamfile.v2 b/config/Jamfile.v2 index 0ac348e8e..440796de2 100644 --- a/config/Jamfile.v2 +++ b/config/Jamfile.v2 @@ -15,11 +15,14 @@ obj has_mpfr_class : has_mpfr_class.cpp : obj has_ntl_rr : has_ntl_rr.cpp : $(ntl-path)/include ; obj has_gmpxx : has_gmpxx.cpp : $(gmp_path) $(gmp_path)/mpfr $(gmp_path)/gmpfrxx ; +obj has_gcc_visibility : has_gcc_visibility.cpp : + gcc:-fvisibility=hidden gcc:-Werror ; explicit has_long_double_support ; explicit has_mpfr_class ; explicit has_ntl_rr ; explicit has_gmpxx ; +explicit has_gcc_visibility ; diff --git a/config/has_gcc_visibility.cpp b/config/has_gcc_visibility.cpp new file mode 100644 index 000000000..6c7d6f915 --- /dev/null +++ b/config/has_gcc_visibility.cpp @@ -0,0 +1,13 @@ +// Copyright John Maddock 20010. +// 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) + +#ifndef __GNUC__ +# error "This is a GCC specific test case". +#endif + +int main() +{ + return 0; +} diff --git a/doc/html/index.html b/doc/html/index.html index 6fc94d160..e51c8fab0 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -3,7 +3,7 @@ Boost.Math - + @@ -17,7 +17,7 @@
-
+

@@ -51,11 +51,11 @@ 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)

@@ -461,7 +461,7 @@
- +

Last revised: , at

Last revised: September 01, 2010 at 19:10:43 +0100


diff --git a/doc/math.qbk b/doc/math.qbk index ca58aaa9e..8c1ce0142 100644 --- a/doc/math.qbk +++ b/doc/math.qbk @@ -1,12 +1,11 @@ [article Boost.Math - [quickbook 1.4] - [copyright 2006, 2007, 2008, 2009 John Maddock, Paul A. Bristow, Hubert Holin, Daryle Walker, Xiaogang Zhang, Bruno Lalande, Johan Råde, Gautam Sewani and Thijs van den Berg] + [quickbook 1.5] + [copyright 2006, 2007, 2008, 2009, 2010 John Maddock, Paul A. Bristow, Hubert Holin, Daryle Walker, Xiaogang Zhang, Bruno Lalande, Johan Råde, Gautam Sewani and Thijs van den Berg] [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 http://www.boost.org/LICENSE_1_0.txt]) ] - [category math] [authors [Maddock, John], [Bristow, Paul A.], [Holin, Hubert], [Walker, Daryle], [Zhang, Xiaogang], [Lalande, Bruno], [Råde, Johan], [Sewani, Gautam], [van den Berg, Thijs]] [last-revision $Date$] ] diff --git a/doc/sf_and_dist/FAQ.qbk b/doc/sf_and_dist/FAQ.qbk new file mode 100644 index 000000000..2aeb3fa08 --- /dev/null +++ b/doc/sf_and_dist/FAQ.qbk @@ -0,0 +1,87 @@ +[section:faq Frequently Asked Questions FAQ] + +# ['I'm a FORTRAN/NAG/SPSS/SAS/Cephes/MathCad/R user and I don't see where the functions like dnorm(mean, sd) are in Boost.Math?] [br] +Nearly all are provided, and many more like mean, skewness, quantiles, complements ... +but Boost.Math makes full use of C++, and it looks a bit different. +But do not panic! See section on construction and the many examples. +Briefly, the distribution is constructed with the parameters (like location and scale) +(things after the | in representation like P(X=k|n, p) or ; in a common represention of pdf f(x; [mu][sigma][super 2]). +Functions like pdf, cdf are called with the name of that distribution and the random variate often called x or k. +For example, `normal my_norm(0, 1); pdf(my_norm, 2.0);` [br] +# ['I'm allegic to reading manuals and prefer to learn from examples.][br] +Fear not - you are not alone! Many examples are available for functions and distributions. +Some are referenced directly from the text. Others can be found at \boost_latest_release\libs\math\example. +If you are a Visual Studio user, you should be able to create projects from each of these, +making sure that the Boost library is in the include directories list. +# ['How do I make sure that the Boost library is in the Visual Studio include directories list?][br] +You can add an include path, for example, your Boost place /boost-latest_release, +for example `X:/boost_1_45_0/` if you have a separate partition X for Boost releases. +Or you can use an environment variable BOOST_ROOT set to your Boost place, and include that. +Visual Studio before 2010 provided Tools, Options, VC++ Directories to control directories: +Visual Studio 2010 instead provides property sheets to assist. +You may find it convenient to create a new one adding \boost-latest_release; +to the existing include items in $(IncludePath). +# ['I'm a FORTRAN/NAG/SPSS/SAS/Cephes/MathCad/R user and +I don't see where the properties like mean, median, mode, variance, skewness of distributions are in Boost.Math?][br] +They are all available (if defined for the parameters with which you constructed the distribution) via __usual_accessors. +# ['I am a C programmer. Can I user Boost.Math with C?][br] +Yes you can, including all the special functions, and TR1 functions like isnan. +They appear as C functions, by being declared as "extern C". +# ['I am a C# (Basic? F# FORTRAN? Other CLI?) programmer. Can I use Boost.Math with C#?] [br] +Yes you can, including all the special functions, and TR1 functions like isnan. +But you [*must build the Boost.Math as a dynamic library (.dll) and compile with the /CLI option]. +See the boost/math/dot_net_example folder which contains an example that +builds a simple statistical distribution app with a GUI. +See [@http://sourceforge.net/projects/distexplorer/ Statistical Distribution Explorer] [br] +# ['What these "policies" things for?] [br] +Policies are a powerful (if necessarily complex) fine-grain mechanism that +allow you to customise the behaviour of the Boost.Math library according to your precise needs. +See __policy_section. But if, very probably, the default behaviour suits you, you don't need to know more. +# ['I am a C user and expect to see global C-style`::errno` set for overflow/errors etc?] [br] +You can achieve what you want - see __error_policy and __user_error_handling and many examples. +# ['I am a C user and expect to silently return a max value for overflow?] [br] +You (and C++ users too) can return whatever you want on overflow +- see __overflow_error and __error_policy and several examples. +# ['I don't want any error message for overflow etc?] [br] +You can control exactly what happens for all the abnormal conditions, including the values returned. +See __domain_error, __overflow_error __error_policy __user_error_handling etc and examples. +# ['My environment doesn't allow and/or I don't want exceptions. Can I still user Boost.Math?] [br] +Yes but you must customise the error handling: see __user_error_handling and __changing_policy_defaults . +# ['The docs are several hundreds of pages long! Can I read the docs off-line or on paper?] [br] +Yes - you can download the Boost current release of most documentation +as a zip of pdfs (including Boost.Math) from Sourceforge, +for example [@https://sourceforge.net/projects/boost/files/boost-docs/1.45.0/boost_pdf_1_45_0.tar.gz/download]. +And you can print any pages you need (or even print all pages - but be warned that there are several hundred!). +Both html and pdf versions are highly hyperlinked. +The entire Boost.Math pdf can be searched with Adobe Reader, Edit, Find ... +This can often find what you seek, a partial substitute for a full index. +# ['I want a compact version for an embedded application. Can I use float precision?] [br] +Yes - by selecting RealType template parameter as float: +for example normal_distribution your_normal(mean, sd); +(But double may still be used internally, so space saving may be less that you hope for). +You can also change the promotion policy, but accuracy might be much reduced. +# ['I seem to get somewhat different results compared to other programs. Why?] +We hope Boost.Math to be more accurate: our priority is accuracy (over speed). +See the section on accuracy. But for evaluations that require iterations +there are parameters which can change the required accuracy. You might be able to +squeeze a little more accuracy at the cost of runtime. +# ['Will my program run more slowly compared to other math functions and statistical libraries?] +Probably, thought not always, and not by too much: our priority is accuracy. +For most functions, making sure you have the latest compiler version with all optimisations switched on is the key to speed. +For evaluations that require iteration, you may be able to gain a little more speed at the expense of accuracy. +See detailed suggestions and results on __performance. +# ['Where are the pre-built libraries?] [br] +Good news - you probably don't need any! - just #include . +But in the unlikely event that you do, see __building. +# ['I don't see the function or distribution that I want.] [br] +You could try an email to ask the authors - but no promises! + +[endsect] [/section:faq Frequently Asked Questions] + +[/ + Copyright 2010 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/background.qbk b/doc/sf_and_dist/background.qbk index 34a0bfeb0..dca8d3276 100644 --- a/doc/sf_and_dist/background.qbk +++ b/doc/sf_and_dist/background.qbk @@ -3,12 +3,12 @@ [@http://en.wikipedia.org/wiki/Random_variate Random variates] and [@http://en.wikipedia.org/wiki/Parameter distribution parameters] are conventionally distinguished (for example in Wikipedia and Wolfram MathWorld -by placing a semi-colon after the random variate (whose value you 'choose'), +by placing a semi-colon after the __random_variate (whose value you 'choose'), to separate the variate from the parameter(s) that defines the shape of the distribution. For example, the binomial distribution has two parameters: n (the number of trials) and p (the probability of success on one trial). -It also has the random variate /k/: the number of successes observed. +It also has the __random_variate /k/: the number of successes observed. This means the probability density\/mass function (pdf) is written as ['f(k; n, p)]. Translating this into code the `binomial_distribution` constructor @@ -18,7 +18,7 @@ therefore has two parameters: While the function `pdf` has one argument specifying the distribution type (which includes it's parameters, if any), -and a second argument for the random variate. So taking our binomial distribution +and a second argument for the __random_variate. So taking our binomial distribution example, we would write: pdf(binomial_distribution(n, p), k); @@ -30,16 +30,15 @@ example, we would write: 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: -only integral values of the random variate are envisaged +only integral values of the __random_variate are envisaged and the functions are only defined at these integral values. 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. To enforce a strict mathematical model, -users may use floor or ceil functions on the random variate, -prior to calling the distribution function, -to enforce integral values. +users may use floor or ceil functions on the __random_variate, +prior to calling the distribution function, to enforce integral values. For similar reasons, in continuous distributions, parameters like degrees of freedom that might appear to be integral, are treated as real values diff --git a/doc/sf_and_dist/building.qbk b/doc/sf_and_dist/building.qbk index bc133550e..f2c30f161 100644 --- a/doc/sf_and_dist/building.qbk +++ b/doc/sf_and_dist/building.qbk @@ -1,10 +1,15 @@ -[section:building If and How to Build the Library and its Examples and Tests] +[section:building If and How to Build a Boost.Math Library, and its Examples and Tests] -[h4 Building the Library] +[h4 Building a Library (shared, dynamic .dll or static .lib)] 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 +#including the necessary header(s). + +For most simple uses, +including a header (or few) is best for compile time and program size. + +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. @@ -15,7 +20,7 @@ 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: +that will do the job on Linux, while: bjam toolset=msvc --with-math --build-type=complete stage @@ -94,7 +99,7 @@ will do this automatically when appropriate. [endsect] [/ building.qbk - Copyright 2006, 2007, 2008 John Maddock and Paul A. Bristow. + Copyright 2006, 2007, 2008, 2010 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/common_overviews.qbk b/doc/sf_and_dist/common_overviews.qbk index 236331ca9..b25bd9c8b 100644 --- a/doc/sf_and_dist/common_overviews.qbk +++ b/doc/sf_and_dist/common_overviews.qbk @@ -7,7 +7,7 @@ behaviour of this library according to your needs. There is more information available in the [link math_toolkit.policy.pol_tutorial policy tutorial] and the [link math_toolkit.policy.pol_ref policy reference]. -Generally speaking unless you find that the +Generally speaking, unless you find that the [link math_toolkit.policy.pol_tutorial.policy_tut_defaults default policy behaviour] when encountering 'bad' argument values does not meet your needs, @@ -53,7 +53,7 @@ statistical distribution]. [template performance_overview[] By and large the performance of this library should be acceptable -for most needs. However, you should note that the library's primary +for most needs. However, you should note that this library's primary emphasis is on accuracy and numerical stability, and /not/ speed. In terms of the algorithms used, this library aims to use the same "best @@ -73,7 +73,7 @@ from this library are: and "debug" builds can easily be a [link math_toolkit.perf.getting_best factor of 20]. # Pick your compiler carefully: [link math_toolkit.perf.comp_compilers performance differences of up to -8 fold] have been found between some windows compilers for example. +8 fold] have been found between some Windows compilers for example. The [link math_toolkit.perf performance section] contains more information on the performance diff --git a/doc/sf_and_dist/credits.qbk b/doc/sf_and_dist/credits.qbk index bc708e7ae..6398b5942 100644 --- a/doc/sf_and_dist/credits.qbk +++ b/doc/sf_and_dist/credits.qbk @@ -30,6 +30,9 @@ Gautam Sewani coded the logistic distribution as part of a Google Summer of Code M. A. (Thijs) van den Berg coded the Laplace distribution. (Thijs has also threatened to implement some multivariate distributions). +Thomas Mang requested the inverse gamma in chi squared distributions +for Bayesian applications and helped in their implementation. + Professor Nico Temme for advice on the inverse incomplete beta function. [@http://www.shoup.net Victor Shoup for NTL], @@ -42,6 +45,10 @@ We are grateful to Joel Guzman for helping us stress-test his program used to generate the html and pdf versions of this document, adding several new features en route. +Thanks to Mark Coleman and Georgi Boshnakov for spot test values +from __Mathematica, and of course, +to Eric Weissten for nurturing __Mathworld, an invaluable resource. + Plots of the functions and distributions were prepared in [@http://www.w3.org/ W3C] standard [@http://www.svg.org/ Scalable Vector Graphic (SVG)] format @@ -62,7 +69,7 @@ Arnaldur Gylfason, John Phillips, Stephan Tolksdorf and Jeff Garland [endsect] [/section:credits Credits and Acknowledgements] [/ - Copyright 2006, 2007, 2008, 2009 John Maddock and Paul A. Bristow. + Copyright 2006, 2007, 2008, 2009, 2010 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 9ca5a249e..f5b036fa5 100644 --- a/doc/sf_and_dist/dist_reference.qbk +++ b/doc/sf_and_dist/dist_reference.qbk @@ -13,6 +13,8 @@ [include distributions/extreme_value.qbk] [include distributions/fisher.qbk] [include distributions/gamma.qbk] +[include distributions/inverse_chi_squared.qbk] +[include distributions/inverse_gamma.qbk] [include distributions/hypergeometric.qbk] [include distributions/laplace.qbk] [include distributions/logistic.qbk] @@ -121,7 +123,7 @@ opportunity to integrate the statistical tests with this framework at some later [endsect][/section:future Extras Future Directions] [/ dist_reference.qbk - Copyright 2006 John Maddock and Paul A. Bristow. + Copyright 2006, 2010 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_tutorial.qbk b/doc/sf_and_dist/dist_tutorial.qbk index 2fd24633c..a059ad3de 100644 --- a/doc/sf_and_dist/dist_tutorial.qbk +++ b/doc/sf_and_dist/dist_tutorial.qbk @@ -1,4 +1,4 @@ -[/ def names end in distrib to avoid clashes] +[/ def names all end in distrib to avoid clashes with names of functions] [def __binomial_distrib [link math_toolkit.dist.dist_ref.dists.binomial_dist Binomial Distribution]] [def __chi_squared_distrib [link math_toolkit.dist.dist_ref.dists.chi_squared_dist Chi Squared Distribution]] [def __normal_distrib [link math_toolkit.dist.dist_ref.dists.normal_dist Normal Distribution]] @@ -19,14 +19,22 @@ provides a few worked examples of applying the library to statistical tests. All the code in this library is inside namespace boost::math. + In order to use a distribution /my_distribution/ you will need to include either the header or -the "include everything" header: . +the "include all the distributions" header: . For example, to use the Students-t distribution include either or +You also need to bring distribution names into scope, +perhaps with a `using namespace boost::math;` declaration, + +or specific `using` declarations like `using boost::math::normal;` (*recommended*). + +[caution Some math function names are also used in namespace std so including could cause ambiguity!] + [endsect] [/ section:headers Headers and Namespaces] [section:objects Distributions are Objects] @@ -63,7 +71,12 @@ 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; + // using namespace boost::math; // Avoid potential ambiguity with names in std + // Safer to declare specific functions with using statement(s): + + using boost::math::beta_distribution; + using boost::math::binomial_distribution; + using boost::math::students_t; // Construct a students_t distribution with 4 degrees of freedom: students_t d1(4); @@ -136,37 +149,47 @@ efficient algorithms available that are specific to random number generation. ] [/tip Random numbers that approximate Quantiles of Distributions] For example, the binomial distribution has two parameters: -n (the number of trials) and p (the probability of success on one trial). +n (the number of trials) and p (the probability of success on any 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. +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)]. [note [*Random Variates and Distribution Parameters] -[@http://en.wikipedia.org/wiki/Random_variate Random variates] +The concept of a __random_variable is closely linked to the term __random_variate: +a random variate is a particular value (outcome) of a random variable. and [@http://en.wikipedia.org/wiki/Parameter distribution parameters] -are conventionally distinguished (for example in Wikipedia and Wolfram MathWorld -by placing a semi-colon (or sometimes vertical bar) -after the random variate (whose value you 'choose'), -to separate the variate from the parameter(s) that defines the shape of the distribution. +are conventionally distinguished (for example in Wikipedia and Wolfram MathWorld) +by placing a semi-colon or vertical bar) +/after/ the __random_variable (whose value you 'choose'), +to separate the variate from the parameter(s) that defines the shape of the distribution.[br] +For example, the binomial distribution probability distribution function (PDF) is written as +['f(k| n, p)] = Pr(K = k|n, p) = probability of observing k successes out of n trials. +K is the __random_variable, k is the __random_variate, +the parameters are n (trials) and p (probability). ] [/tip Random Variates and Distribution Parameters] +[note By convention, __random_variate are lower case, usually k is integral, x if real, and +__random_variable are upper case, K if integral, X if real. But this implementation treats +all as floating point values `RealType`, so if you really want an integral result, +you must round: see note on Discrete Probability Distributions below for details.] + 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 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"]. @@ -177,7 +200,7 @@ Outside are uninteresting zones where the pdf is zero, and the cdf zero or unity For most distributions, with probability distribution functions one might describe as 'well-behaved', we have decided that it is most useful for the supported range -to exclude random variate values like exact zero *if the end point is discontinuous*. +to *exclude* random variate values like exact zero *if the end point is discontinuous*. For example, the Weibull (scale 1, shape 1) distribution smoothly heads for unity as the random variate x declines towards zero. But at x = zero, the value of the pdf is suddenly exactly zero, by definition. @@ -412,6 +435,7 @@ Now that you have the basics, the next section looks at some worked examples. [include distributions/binomial_example.qbk] [include distributions/negative_binomial_example.qbk] [include distributions/normal_example.qbk] +[/include distributions/inverse_gamma_example.qbk] [include distributions/nc_chi_squared_example.qbk] [include distributions/error_handling_example.qbk] [include distributions/find_location_and_scale.qbk] @@ -424,7 +448,7 @@ Now that you have the basics, the next section looks at some worked examples. [endsect] [/ section:stat_tut Statistical Distributions Tutorial] [/ dist_tutorial.qbk - Copyright 2006 John Maddock and Paul A. Bristow. + Copyright 2006, 2010 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/binomial.qbk b/doc/sf_and_dist/distributions/binomial.qbk index d790e1708..ec94106e3 100644 --- a/doc/sf_and_dist/distributions/binomial.qbk +++ b/doc/sf_and_dist/distributions/binomial.qbk @@ -323,7 +323,7 @@ the context of this distribution: is a real-number, and not an integer. Depending on the use case you may want to take either the floor or ceiling of the result. For example: -`quantile(complement(binomial(n, p), P))``]] +`quantile(complement(binomial(n, p), P))`]] ] [h4 Examples] diff --git a/doc/sf_and_dist/distributions/gamma.qbk b/doc/sf_and_dist/distributions/gamma.qbk index 24b5d8adf..8568df2b6 100644 --- a/doc/sf_and_dist/distributions/gamma.qbk +++ b/doc/sf_and_dist/distributions/gamma.qbk @@ -127,10 +127,11 @@ and /q = 1-p/. [[kurtosis excess][6 / k ]] ] -[endsect][/section:normal_dist Normal] +[endsect][/section:gamma_dist Gamma (and Erlang) Distribution] + [/ - Copyright 2006 John Maddock and Paul A. Bristow. + Copyright 2006, 2010 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/inverse_chi_squared.qbk b/doc/sf_and_dist/distributions/inverse_chi_squared.qbk new file mode 100644 index 000000000..943db4295 --- /dev/null +++ b/doc/sf_and_dist/distributions/inverse_chi_squared.qbk @@ -0,0 +1,176 @@ +[section:inverse_chi_squared_dist Inverse Chi Squared Distribution] + +``#include `` + + namespace boost{ namespace math{ + + template + class inverse_chi_squared_distribution + { + public: + typedef RealType value_type; + typedef Policy policy_type; + + inverse_chi_squared_distribution(RealType df = 1); // Not explicitly scaled, default 1/df. + inverse_chi_squared_distribution(RealType df, RealType scale = 1/df); // Scaled. + + RealType degrees_of_freedom()const; // Default 1. + RealType scale()const; // Optional scale [xi] (variance), default 1/degrees_of_freedom. + }; + + }} // namespace boost // namespace math + +The inverse chi squared distribution is a continuous probability distribution +of the *reciprocal* of a variable distributed according to the chi squared distribution. + +The sources below give confusingly different formulae +using different symbols for the distribution pdf, +but they are all the same, or related by a change of variable, or choice of scale. + +Two constructors are available to implement both the scaled and (implicitly) unscaled versions. + +The main version has an explicit scale parameter which implements the +[@http://en.wikipedia.org/wiki/Scaled-inverse-chi-square_distribution scaled inverse chi_squared distribution]. + +A second version has an implicit scale = 1/degrees of freedom and gives the 1st definition in the +[@http://en.wikipedia.org/wiki/Inverse-chi-square_distribution Wikipedia inverse chi_squared distribution]. +The 2nd Wikipedia inverse chi_squared distribution definition can be implemented +by explicitly specifying a scale = 1. + +Both definitions are also available in Wolfram Mathematica and in __R (geoR) with default scale = 1/degrees of freedom. + +See + +* Inverse chi_squared distribution [@http://en.wikipedia.org/wiki/Inverse-chi-square_distribution] +* Scaled inverse chi_squared distribution[@http://en.wikipedia.org/wiki/Scaled-inverse-chi-square_distribution] +* R inverse chi_squared distribution functions [@http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/geoR/html/InvChisquare.html R ] +* Inverse chi_squared distribution functions [@http://mathworld.wolfram.com/InverseChi-SquaredDistribution.html Weisstein, Eric W. "Inverse Chi-Squared Distribution." From MathWorld--A Wolfram Web Resource.] +* Inverse chi_squared distribution reference [@http://reference.wolfram.com/mathematica/ref/InverseChiSquareDistribution.html Weisstein, Eric W. "Inverse Chi-Squared Distribution reference." From Wolfram Mathematica.] + +The inverse_chi_squared distribution is used in +[@http://en.wikipedia.org/wiki/Bayesian_statistics Bayesian statistics]: +the scaled inverse chi-square is conjugate prior for the normal distribution +with known mean, model parameter [sigma][pow2] (variance). + +See [@http://en.wikipedia.org/wiki/Conjugate_prior conjugate priors including a table of distributions and their priors.] + +See also __inverse_gamma_distrib and __chi_squared_distrib. + +The inverse_chi_squared distribution is a special case of a inverse_gamma distribution +with [nu] (degrees_of_freedom) shape ([alpha]) and scale ([beta]) where + +__spaces [alpha]= [nu] /2 and [beta] = [frac12]. + +[note This distribution *does* provide the typedef: + +``typedef inverse_chi_squared_distribution inverse_chi_squared;`` + +If you want a `double` precision inverse_chi_squared distribution you can use + +``boost::math::inverse_chi_squared_distribution<>`` + +or you can write `inverse_chi_squared my_invchisqr(2, 3);`] + +For degrees of freedom parameter [nu], +the (*unscaled*) inverse chi_squared distribution is defined by the probability density function (PDF): + +__spaces f(x;[nu]) = 2[super -[nu]/2] x[super -[nu]/2-1] e[super -1/2x] / [Gamma]([nu]/2) + +and Cumulative Density Function (CDF) + +__spaces F(x;[nu]) = [Gamma]([nu]/2, 1/2x) / [Gamma]([nu]/2) + +For degrees of freedom parameter [nu] and scale parameter [xi], +the *scaled* inverse chi_squared distribution is defined by the probability density function (PDF): + +__spaces f(x;[nu], [xi]) = ([xi][nu]/2)[super [nu]/2] e[super -[nu][xi]/2x] x[super -1-[nu]/2] / [Gamma]([nu]/2) + +and Cumulative Density Function (CDF) + +__spaces F(x;[nu], [xi]) = [Gamma]([nu]/2, [nu][xi]/2x) / [Gamma]([nu]/2) + +The following graphs illustrate how the PDF and CDF of the inverse chi_squared distribution +varies for a few values of parameters [nu] and [xi]: + +[graph inverse_chi_squared_pdf] [/.png or .svg] + +[graph inverse_chi_squared_cdf] + +[h4 Member Functions] + + inverse_chi_squared_distribution(RealType df = 1); // Implicitly scaled 1/df. + inverse_chi_squared_distribution(RealType df = 1, RealType scale); // Explicitly scaled. + +Constructs an inverse chi_squared distribution with [nu] degrees of freedom ['df], +and scale ['scale] with default value 1\/df. + +Requires that the degrees of freedom [nu] parameter is greater than zero, otherwise calls +__domain_error. + + RealType degrees_of_freedom()const; + +Returns the degrees_of_freedom [nu] parameter of this distribution. + + RealType scale()const; + +Returns the scale [xi] 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 variate is \[0,+[infin]\]. +[note Unlike some definitions, this implementation supports a random variate +equal to zero as a special case, returning zero for both pdf and cdf.] + +[h4 Accuracy] + +The inverse gamma distribution is implemented in terms of the +incomplete gamma functions like the __inverse_gamma_distrib that use +__gamma_p and __gamma_q and their inverses __gamma_p_inv and __gamma_q_inv: +refer to the accuracy data for those functions for more information. +But in general, gamma (and thus inverse gamma) results are often accurate to a few epsilon, +>14 decimal digits accuracy for 64-bit double. +unless iteration is involved, as for the estimation of degrees of freedom. + +[h4 Implementation] + +In the following table [nu] is the degrees of freedom parameter and +[xi] is the scale parameter of the distribution, +/x/ is the random variate, /p/ is the probability and /q = 1-p/ its complement. +Parameters [alpha] for shape and [beta] for scale +are used for the inverse gamma function: [alpha] = [nu]/2 and [beta] = [nu] * [xi]/2. + +[table +[[Function][Implementation Notes]] +[[pdf][Using the relation: pdf = __gamma_p_derivative([alpha], [beta]/ x, [beta]) / x * x ]] +[[cdf][Using the relation: p = __gamma_q([alpha], [beta] / x) ]] +[[cdf complement][Using the relation: q = __gamma_p([alpha], [beta] / x) ]] +[[quantile][Using the relation: x = [beta][space]/ __gamma_q_inv([alpha], p) ]] +[[quantile from the complement][Using the relation: x = [alpha][space]/ __gamma_p_inv([alpha], q) ]] +[[mode][[nu] * [xi] / ([nu] + 2) ]] +[[median][no closed form analytic equation is known, but is evaluated as quantile(0.5)]] +[[mean][[nu][xi] / ([nu] - 2) for [nu] > 2, else a __domain_error]] +[[variance][2 [nu][pow2] [xi][pow2] / (([nu] -2)[pow2] ([nu] -4)) for [nu] >4, else a __domain_error]] +[[skewness][4 [sqrt]2 [sqrt]([nu]-4) /([nu]-6) for [nu] >6, else a __domain_error ]] +[[kurtosis_excess][12 * (5[nu] - 22) / (([nu] - 6) * ([nu] - 8)) for [nu] >8, else a __domain_error]] +[[kurtosis][3 + 12 * (5[nu] - 22) / (([nu] - 6) * ([nu]-8)) for [nu] >8, else a __domain_error]] +] [/table] + +[h4 References] + +# Bayesian Data Analysis, Andrew Gelman, John B. Carlin, Hal S. Stern, Donald B. Rubin, +ISBN-13: 978-1584883883, Chapman & Hall; 2 edition (29 July 2003). + +# Bayesian Computation with R, Jim Albert, ISBN-13: 978-0387922973, Springer; 2nd ed. edition (10 Jun 2009) + +[endsect] [/section:inverse_chi_squared_dist Inverse chi_squared Distribution] + +[/ + Copyright 2010 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). +] \ No newline at end of file diff --git a/doc/sf_and_dist/distributions/inverse_gamma.qbk b/doc/sf_and_dist/distributions/inverse_gamma.qbk new file mode 100644 index 000000000..177f2fd87 --- /dev/null +++ b/doc/sf_and_dist/distributions/inverse_gamma.qbk @@ -0,0 +1,129 @@ +[section:inverse_gamma_dist Inverse Gamma Distribution] + +``#include `` + + namespace boost{ namespace math{ + + template + class inverse_gamma_distribution + { + public: + typedef RealType value_type; + typedef Policy policy_type; + + inverse_gamma_distribution(RealType shape, RealType scale = 1) + + RealType shape()const; + RealType scale()const; + }; + + }} // namespaces + +The inverse_gamma distribution is a continuous probability distribution +of the reciprocal of a variable distributed according to the gamma distribution. + +The inverse_gamma distribution is used in Bayesian statistics. + +See [@http://en.wikipedia.org/wiki/Inverse-gamma_distribution inverse gamma distribution]. + +[@http://rss.acs.unt.edu/Rdoc/library/pscl/html/igamma.html R inverse gamma distribution functions]. + +[@http://reference.wolfram.com/mathematica/ref/InverseGammaDistribution.html Wolfram inverse gamma distribution]. + +See also __gamma_distrib. + + +[note +In spite of potential confusion with the inverse gamma function, this +distribution *does* provide the typedef: + +``typedef inverse_gamma_distribution gamma;`` + +If you want a `double` precision gamma distribution you can use + +``boost::math::inverse_gamma_distribution<>`` + +or you can write `inverse_gamma my_ig(2, 3);`] + +For shape parameter [alpha] and scale parameter [beta], it is defined +by the probability density function (PDF): + +__spaces f(x;[alpha], [beta]) = [beta][super [alpha]] * (1/x) [super [alpha]+1] exp(-[beta]/x) / [Gamma]([alpha]) + +and cumulative density function (CDF) + +__spaces F(x;[alpha], [beta]) = [Gamma]([alpha], [beta]/x) / [Gamma]([alpha]) + +The following graphs illustrate how the PDF and CDF of the inverse gamma distribution +varies as the parameters vary: + +[graph inverse_gamma_pdf] [/png or svg] + +[graph inverse_gamma_cdf] + +[h4 Member Functions] + + inverse_gamma_distribution(RealType shape = 1, RealType scale = 1); + +Constructs an inverse gamma distribution with shape [alpha] and scale [beta]. + +Requires that the shape and scale parameters are greater than zero, otherwise calls +__domain_error. + + RealType shape()const; + +Returns the [alpha] shape parameter of this inverse gamma distribution. + + RealType scale()const; + +Returns the [beta] scale parameter of this inverse gamma 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 variate is \[0,+[infin]\]. +[note Unlike some definitions, this implementation supports a random variate +equal to zero as a special case, returning zero for pdf and cdf.] + +[h4 Accuracy] + +The inverse gamma distribution is implemented in terms of the +incomplete gamma functions __gamma_p and __gamma_q and their +inverses __gamma_p_inv and __gamma_q_inv: refer to the accuracy +data for those functions for more information. +But in general, inverse_gamma results are accurate to a few epsilon, +>14 decimal digits accuracy for 64-bit double. + +[h4 Implementation] + +In the following table [alpha] is the shape parameter of the distribution, +[alpha][space] is its scale parameter, /x/ is the random variate, /p/ is the probability +and /q = 1-p/. + +[table +[[Function][Implementation Notes]] +[[pdf][Using the relation: pdf = __gamma_p_derivative([alpha], [beta]/ x, [beta]) / x * x ]] +[[cdf][Using the relation: p = __gamma_q([alpha], [beta] / x) ]] +[[cdf complement][Using the relation: q = __gamma_p([alpha], [beta] / x) ]] +[[quantile][Using the relation: x = [beta][space]/ __gamma_q_inv([alpha], p) ]] +[[quantile from the complement][Using the relation: x = [alpha][space]/ __gamma_p_inv([alpha], q) ]] +[[mode][[beta] / ([alpha] + 1) ]] +[[median][no analytic equation is known, but is evaluated as quantile(0.5)]] +[[mean][[beta] / ([alpha] - 1) for [alpha] > 1, else a __domain_error]] +[[variance][([beta] * [beta]) / (([alpha] - 1) * ([alpha] - 1) * ([alpha] - 2)) for [alpha] >2, else a __domain_error]] +[[skewness][4 * sqrt ([alpha] -2) / ([alpha] -3) for [alpha] >3, else a __domain_error]] +[[kurtosis_excess][(30 * [alpha] - 66) / (([alpha]-3)*([alpha] - 4)) for [alpha] >4, else a __domain_error]] +] [/table] + +[endsect][/section:inverse_gamma_dist Inverse Gamma Distribution] + +[/ + Copyright 2010 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/inverse_gamma_example.qbk b/doc/sf_and_dist/distributions/inverse_gamma_example.qbk new file mode 100644 index 000000000..3feaa26e8 --- /dev/null +++ b/doc/sf_and_dist/distributions/inverse_gamma_example.qbk @@ -0,0 +1,15 @@ + +[section:inverse_gamma_eg Inverse Gamma Distribution Bayes Example] + +TODO + +[endsect] [/section:inverse_gamma_eg Inverse Gamma Distribution Bayes Example] + + +[/ + Copyright 2006, 2010 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/non_members.qbk b/doc/sf_and_dist/distributions/non_members.qbk index d94874226..07bb7378e 100644 --- a/doc/sf_and_dist/distributions/non_members.qbk +++ b/doc/sf_and_dist/distributions/non_members.qbk @@ -1,7 +1,7 @@ [section:nmp Non-Member Properties] Properties that are common to all distributions are accessed via non-member -getter functions. This allows more of these functions to be added over time +getter functions: non-membership allows more of these functions to be added over time, as the need arises. Unfortunately the literature uses many different and confusing names to refer to a rather small number of actual concepts; refer to the [link concept_index concept index] to find the property you @@ -70,7 +70,7 @@ to the integral from -infinity to x of the __pdf. This function may return a __domain_error if the random variable is outside the defined range for the distribution. -For example the following graph shows the cdf for the +For example, the following graph shows the cdf for the normal distribution: [$../graphs/cdf.png] @@ -98,7 +98,7 @@ function in a call to `complement`, for example: // print survival function for x=2.0: std::cout << cdf(complement(norm, 2.0)) << std::endl; -For example the following graph shows the __complement of the cdf for the +For example, the following graph shows the __complement of the cdf for the normal distribution: [$../graphs/survival.png] @@ -180,11 +180,11 @@ variate takes the value x. This function may return a __domain_error if the random variable is outside the defined range for the distribution. -For example for a standard normal distribution the pdf looks like this: +For example, for a standard normal distribution the pdf looks like this: [$../graphs/pdf.png] -[h4 [#math.dist.range]range] +[h4 [#math.dist.range]Range] template std::pair range(const ``['Distribution-Type]``& dist); diff --git a/doc/sf_and_dist/error_handling.qbk b/doc/sf_and_dist/error_handling.qbk index 4ef6f6ba4..34cf033fb 100644 --- a/doc/sf_and_dist/error_handling.qbk +++ b/doc/sf_and_dist/error_handling.qbk @@ -54,7 +54,7 @@ appropriate result]] ] The following tables show all the permutations of errors and actions, -with the default action for each error shown in bold: +with the *default action for each error shown in bold*: [table Possible Actions for Domain Errors [[Action] [Behaviour]] @@ -136,14 +136,19 @@ with the default action for each error shown in bold: this function must be defined by the user].]] ] +All these error conditions are in namespace boost::math::policies, +made available, for example, a by namespace declaration +using `namespace boost::math::policies;` or individual using declarations +`using boost::math::policies::overflow_error;`. + [heading Rationale] -The flexibility of the current implementation should be reasonably obvious, the +The flexibility of the current implementation should be reasonably obvious: the default behaviours were chosen based on feedback during the formal review of this library. It was felt that: * Genuine errors should be flagged with exceptions -rather than following C-compatible behaviour and setting ::errno. +rather than following C-compatible behaviour and setting `::errno`. * Numeric underflow and denormalised results were not considered to be fatal errors in most cases, so it was felt that these should be ignored. @@ -180,7 +185,7 @@ in use for the function that was called. The default policy behaviour of this function is to throw a std::domain_error C++ exception. But if the __Policy is to ignore -the error, or set global ::errno, then a NaN will be returned. +the error, or set global `::errno`, then a NaN will be returned. This behaviour is chosen to assist compatibility with the behaviour of ['ISO/IEC 9899:1999 Programming languages - C] @@ -328,8 +333,8 @@ Where `T` is the floating-point type passed to the function, `FunctionName` is the name of the function, `Message` is an error message describing the problem, Val is the value for which the result is indeterminate, Default is an -alternative default result that must be returned for ignore_error and -errno_on_error policies, and __Policy is the current policy in use for the +alternative default result that must be returned for `ignore_error` and +`errno_on_erro` policies, and __Policy is the current policy in use for the function that was called. The default policy for this function is `ignore_error`: note that this error @@ -351,8 +356,7 @@ Where `T` is the floating point type passed to the function, `FunctionName` is the name of the function, `Message` is an error message describing the problem, `Val` is the erroneous argument, -and __Policy is the current policy -in use for the called function. +and __Policy is the current policy in use for the called function. The default behaviour of this function is to throw a `boost::math::rounding_error`. @@ -384,7 +388,7 @@ listed above on [link overflow_error overflow], [endsect][/section:error_handling Error Handling] [/ - Copyright 2006 John Maddock and Paul A. Bristow. + Copyright 2006 - 2010 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/fpclassify.qbk b/doc/sf_and_dist/fpclassify.qbk index a15e627a6..a21a5a50c 100644 --- a/doc/sf_and_dist/fpclassify.qbk +++ b/doc/sf_and_dist/fpclassify.qbk @@ -50,7 +50,7 @@ these as macros. That mean that the following have differing meanings: // it works for any type that has numeric_limits support for type z: (isnan)(z); // - // As above but with namespace qualification. + // As above but with explicit namespace qualification. (boost::math::isnan)(z); // // This will cause a compiler error if isnan is a native macro: @@ -58,7 +58,7 @@ these as macros. That mean that the following have differing meanings: // So always use instead: (boost::math::isnan)(z); // - // You can also add a using statment, + // You can also add a using statement, // globally to a .cpp file, or to a local function in a .hpp file. using boost::math::isnan; // so you can write the shorter and less cluttered diff --git a/doc/sf_and_dist/graphs/inverse_chi_squared_cdf.png b/doc/sf_and_dist/graphs/inverse_chi_squared_cdf.png new file mode 100644 index 000000000..4592e5b19 Binary files /dev/null and b/doc/sf_and_dist/graphs/inverse_chi_squared_cdf.png differ diff --git a/doc/sf_and_dist/graphs/inverse_chi_squared_cdf.svg b/doc/sf_and_dist/graphs/inverse_chi_squared_cdf.svg new file mode 100644 index 000000000..33f61de6f --- /dev/null +++ b/doc/sf_and_dist/graphs/inverse_chi_squared_cdf.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 +6 +0 + +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 + + + + + + + + + + + + + + + +ν = 1 +ν = 3, (ξ = 1/3) +ν = 1, ξ = 1 +ν = 4, (ξ = 1/4) +ν = 3, (ξ = 1/5 + +Inverse Chi Squared Distribution CDF + + + diff --git a/doc/sf_and_dist/graphs/inverse_chi_squared_pdf.png b/doc/sf_and_dist/graphs/inverse_chi_squared_pdf.png new file mode 100644 index 000000000..776eacc0a Binary files /dev/null and b/doc/sf_and_dist/graphs/inverse_chi_squared_pdf.png differ diff --git a/doc/sf_and_dist/graphs/inverse_chi_squared_pdf.svg b/doc/sf_and_dist/graphs/inverse_chi_squared_pdf.svg new file mode 100644 index 000000000..ce7b56ba4 --- /dev/null +++ b/doc/sf_and_dist/graphs/inverse_chi_squared_pdf.svg @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 +6 +0 + +0 +1 +2 +3 +4 +0 + +Probability + +Random Variable + + + + + + + + + + + + + + + +ν = 1 +ν = 3, (ξ = 1/3) +ν = 3, ξ = 1 +ν = 4, (ξ = 1/4) +ν = 5, (ξ = 1/5) + +Inverse Chi Squared Distribution PDF + + + diff --git a/doc/sf_and_dist/graphs/inverse_gamma_cdf.png b/doc/sf_and_dist/graphs/inverse_gamma_cdf.png new file mode 100644 index 000000000..d3fdf7ec7 Binary files /dev/null and b/doc/sf_and_dist/graphs/inverse_gamma_cdf.png differ diff --git a/doc/sf_and_dist/graphs/inverse_gamma_cdf.svg b/doc/sf_and_dist/graphs/inverse_gamma_cdf.svg new file mode 100644 index 000000000..89af2890c --- /dev/null +++ b/doc/sf_and_dist/graphs/inverse_gamma_cdf.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 +0 + +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 + + + + + + + + + + + + + +α = 1, β = 1 +α = 2, β = 1 +α = 3, β = 2 +α = 3, β = 0.5 + +Inverse Gamma Distribution CDF + + + diff --git a/doc/sf_and_dist/graphs/inverse_gamma_pdf.png b/doc/sf_and_dist/graphs/inverse_gamma_pdf.png new file mode 100644 index 000000000..ff2451ad4 Binary files /dev/null and b/doc/sf_and_dist/graphs/inverse_gamma_pdf.png differ diff --git a/doc/sf_and_dist/graphs/inverse_gamma_pdf.svg b/doc/sf_and_dist/graphs/inverse_gamma_pdf.svg new file mode 100644 index 000000000..30deecfa6 --- /dev/null +++ b/doc/sf_and_dist/graphs/inverse_gamma_pdf.svg @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 +0 + +0 +1 +2 +3 +4 +5 +0 + +Probability + +Random Variable + + + + + + + + + + + + + +α = 1, β = 1 +α = 2, β = 1 +α = 3, β = 2 +α = 3, β = 0.5 + +Inverse Gamma Distribution PDF + + + diff --git a/doc/sf_and_dist/html/index.html b/doc/sf_and_dist/html/index.html index 11dcb4526..017fce59c 100644 --- a/doc/sf_and_dist/html/index.html +++ b/doc/sf_and_dist/html/index.html @@ -49,11 +49,11 @@ Thijs van den Berg
-
+

- ISBN 0-9504833-2-X 978-0-9504833-2-0, Classification 519.2-dc22

This manual is also available in printer - friendly PDF format. + friendly PDF format, and as a CD ISBN 0-9504833-2-X 978-0-9504833-2-0, + Classification 519.2-dc22.

- +

Last revised: August 23, 2010 at 10:23:09 GMT

Last revised: September 29, 2010 at 17:50:24 GMT


diff --git a/doc/sf_and_dist/html/math_toolkit/backgrounders.html b/doc/sf_and_dist/html/math_toolkit/backgrounders.html index bbd4dc469..5ca9a6507 100644 --- a/doc/sf_and_dist/html/math_toolkit/backgrounders.html +++ b/doc/sf_and_dist/html/math_toolkit/backgrounders.html @@ -38,9 +38,9 @@ -
- + Handling of Functions that are Not Mathematically defined

Functions that are not mathematically defined, like the Cauchy mean, fail - to compile by default. A - policy allows control of this. + to compile by default. A policy + allows control of this.

If the policy is to permit undefined functions, then calling them throws @@ -258,7 +258,7 @@

- + Median of distributions
@@ -268,11 +268,13 @@ functions, the mid-point in a list of values.

- However a useful median approximation for distribution dist - may be available from + However a useful numerical approximation for distribution dist + is available as usual as an accessor non-member function median using median(dist), + that may be evaluated (in the absence of an analytic formula) by calling

- quantile(dist, 0.5). + quantile(dist, 0.5) (this + is the mathematical definition of course).

Mean, @@ -291,7 +293,7 @@ Basic Statistics. give more detail, in particular for discrete distributions.

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

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

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

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

- + Sources of Test Data
@@ -514,7 +516,10 @@ in the case of serious disagreement. The accuracy, actual and claimed, vary very widely. Only Wolfram Mathematica functions provided a higher accuracy than C++ double (64-bit floating-point) - and was regarded as the most-trusted source by far. + and was regarded as the most-trusted source by far. The The + R Project for Statistical Computing provided the widest range of + distributions, but the usual Intel X86 distribution uses 64-but doubles, + so our use was limited to the 15 to 17 decimal digit accuracy.

A useful index of sources is: Web-oriented @@ -541,10 +546,18 @@ the underlying special function is known to be difficult to implement.

- + Creating and Managing the Equations
+

+ Equations that fit on a single line can most easily be produced by inline + Quickbook code using templates for Unicode Greek and Unicode Math symbols. + All Greek letter and small set of Math symbols is available at /boost-path/libs/math/doc/sf_and_dist/html4_symbols.qbk +

+

+ Where equations need to use more than one line, real Math editors were used. +

The primary source for the equations is now MathML: see the *.mml files in libs/math/doc/sf_and_dist/equations/. @@ -555,7 +568,7 @@ mangles these files and should not currently be used.

- Convertion to SVG was achieved using SVGMath + Conversion to SVG was achieved using SVGMath and a command line such as:

$for file in *.mml; do
@@ -563,6 +576,11 @@
 >>$file > $(basename $file .mml).svg
 >done
 
+

+ See also the section on "Using Python to run Inkscape" and "Using + inkscape to convert scalable vector SVG files to Portable Network graphic + PNG". +

Note that SVGMath requires that the mml files are not wrapped in an XHTML XML wrapper - this is added by Mathcast by default - @@ -713,7 +731,7 @@ done HTML: this needs further investigation.

- + Producing Graphs
@@ -722,17 +740,19 @@ done same process as the equations.

- The programs /libs/math/doc/sf_and_dist/graphs/dist_graphs.cpp and /libs/math/doc/sf_and_dist/graphs/sf_graphs.cpp - generate the SVG's directly using the Google - Summer of Code 2007 project of Jacob Voytko (whose work so far is - at .\boost-sandbox\SOC\2007\visualization). + The programs /libs/math/doc/sf_and_dist/graphs/dist_graphs.cpp and + /libs/math/doc/sf_and_dist/graphs/sf_graphs.cpp generate + the SVG's directly using the Google + Summer of Code 2007 project of Jacob Voytko (whose work so far, considerably + enhanced and now reasonably mature and usable, by Paul A. Bristow, is at + .\boost-sandbox\SOC\2007\visualization).

-
- + Motivation

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

- + The Approximation
@@ -161,7 +161,7 @@

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

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

-

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

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

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

-

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

+

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

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

- + References
    @@ -560,9 +560,9 @@
-
- + General references
@@ -75,8 +75,8 @@ Wiley 2000.

- EXTREME VALUE - DISTRIBUTIONS, Theory and Applications Samuel Kotz & Saralees + Extreme Value + Distributions, Theory and Applications Samuel Kotz & Saralees Nadarajah, ISBN 978-1-86094-224-2 & 1-86094-224-5 Oct 2000, Chapter 1.2 discusses the various extreme value distributions.

@@ -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

@@ -133,7 +133,8 @@ http://www.softintegration.com/docs/packagechnagstat

- NAG libraries. + NAG + libraries.

MathCAD @@ -158,12 +159,36 @@ Statistics Glossary, Valerie Easton and John H. McColl.

+

+ _R R Development Core Team (2010). + R: A language and environment for statistical computing. R Foundation for + Statistical Computing, Vienna, Austria. ISBN 3-900051-07-0, URL http://www.R-project.org. +

+

+ For use of R, see: +

+

+ Jim Albert, Bayesian Computation with R, ISBN 978-0-387-71384-7. +

+

+ C++ + Statistical Distributions in Boost - QuantNetwork forum discusses + using Boost.Math in finance. +

+

+ Quantnet + Boost and computational finance. Robert Demming & Daniel J. Duffy, + Introduction to the C++ Boost Libraries - Volume I - Foundations and Volume + II ISBN 978-94-91028-01-4, Advanced Libraries and Applications, ISBN 978-94-91028-02-1 + (to be published in 2011). discusses application of Boost.Math, especially + in finance.] +

-
-
- + 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
@@ -388,7 +388,7 @@ a positive power less than one will skew them towards either end. More usefully, if we initially rescale the points over [0,1] and then raise to a positive power, we can skew them to the left or right. Returning to our example of - ex over [-1,1], the initial interpolated form was some way from the minimax + ex ​ over [-1,1], the initial interpolated form was some way from the minimax solution:

@@ -397,7 +397,7 @@

However, if we first skew the interpolation points to the left (rescale them to [0, 1], raise to the power 1.3, and then rescale back to [-1,1]) we reduce - the error from 1.3x10-3to 6x10-4: + the error from 1.3x10-3 ​to 6x10-4:

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

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

@@ -527,9 +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,9 +130,9 @@ -
-
- + References
    @@ -343,9 +343,9 @@
-
-
- + 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

@@ -620,7 +620,7 @@

quantile(complement(binomial(n, p), - P))` + P))

@@ -628,7 +628,7 @@

- + Examples

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

- + Accuracy

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

- + Implementation

@@ -890,7 +890,7 @@

- + References
    @@ -911,9 +911,9 @@
-
- + References
    @@ -400,9 +400,9 @@ independent, normally distributed random
-
- + references
    @@ -318,9 +318,9 @@
-
- @@ -281,7 +281,7 @@ @@ -318,7 +318,7 @@ @@ -363,9 +363,9 @@
-

- For shape parameter k and scale parameter θ it is + For shape parameter k and scale parameter θ ​ it is defined by the probability density function:

- Sometimes an alternative formulation is used: given parameters α= k and - β= 1 / θ, then the distribution can be defined by the PDF: + Sometimes an alternative formulation is used: given parameters α ​= k and + β ​= 1 / θ, then the distribution can be defined by the PDF:

@@ -137,7 +137,7 @@ than a dedicated Erlang Distribution.

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

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

- + Accuracy

@@ -194,12 +194,12 @@ refer to the accuracy data for those functions for more information.

- + Implementation

In the following table k is the shape parameter - of the distribution, θ is it's scale parameter, x + of the distribution, θ ​ is it's scale parameter, x is the random variate, p is the probability and q = 1-p.

@@ -268,7 +268,7 @@

- Using the relation: x = θ* gamma_p_inv(k, + Using the relation: x = θ ​* gamma_p_inv(k, p)

- Using the relation: x = θ* gamma_q_inv(k, + Using the relation: x = θ ​* gamma_q_inv(k, p)

- (k-1)θ for k>1 otherwise a domain_error + (k-1)θ ​ for k>1 otherwise a domain_error

-

-PrevUpHomeNext +PrevUpHomeNext
diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/hypergeometric_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/hypergeometric_dist.html index 46003dcc5..cb4c77a88 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/hypergeometric_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/hypergeometric_dist.html @@ -6,7 +6,7 @@ - + @@ -20,7 +20,7 @@

-PrevUpHomeNext +PrevUpHomeNext
@@ -102,7 +102,7 @@

- + Member Functions
@@ -131,7 +131,7 @@ from the population N.

- + Non-member Accessors
@@ -185,7 +185,7 @@
- + Accuracy

@@ -211,7 +211,7 @@ meaningless for N >= 1015.

- + Testing

@@ -223,7 +223,7 @@ this implementation and NTL::RR.

- + Implementation

@@ -328,9 +328,9 @@ -


-PrevUpHomeNext +PrevUpHomeNext
diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_chi_squared_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_chi_squared_dist.html new file mode 100644 index 000000000..fae00b109 --- /dev/null +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_chi_squared_dist.html @@ -0,0 +1,471 @@ + + + +Inverse Chi Squared Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ +

+
#include <boost/math/distributions/inverse_chi_squared.hpp>
+

+

+
namespace boost{ namespace math{ 
+   
+template <class RealType = double, 
+          class Policy   = policies::policy<> >
+class inverse_chi_squared_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+
+   inverse_chi_squared_distribution(RealType df = 1); // Not explicitly scaled, default 1/df.
+   inverse_chi_squared_distribution(RealType df, RealType scale = 1/df);  // Scaled.
+
+   RealType degrees_of_freedom()const; // Default 1.
+   RealType scale()const; // Optional scale [xi] (variance), default 1/degrees_of_freedom.
+};
+
+}} // namespace boost // namespace math
+
+

+ The inverse chi squared distribution is a continuous probability distribution + of the reciprocal of a variable distributed + according to the chi squared distribution. +

+

+ The sources below give confusingly different formulae using different + symbols for the distribution pdf, but they are all the same, or related + by a change of variable, or choice of scale. +

+

+ Two constructors are available to implement both the scaled and (implicitly) + unscaled versions. +

+

+ The main version has an explicit scale parameter which implements the + scaled + inverse chi_squared distribution. +

+

+ A second version has an implicit scale = 1/degrees of freedom and gives + the 1st definition in the Wikipedia + inverse chi_squared distribution. The 2nd Wikipedia inverse chi_squared + distribution definition can be implemented by explicitly specifying a + scale = 1. +

+

+ Both definitions are also available in Wolfram Mathematica and in The R Project for Statistical Computing + (geoR) with default scale = 1/degrees of freedom. +

+

+ See +

+
+

+ The inverse_chi_squared distribution is used in Bayesian + statistics: the scaled inverse chi-square is conjugate prior + for the normal distribution with known mean, model parameter σ² (variance). +

+

+ See conjugate + priors including a table of distributions and their priors. +

+

+ See also Inverse + Gamma Distribution and Chi + Squared Distribution. +

+

+ The inverse_chi_squared distribution is a psecial case of a inverse_gamma + distribution with ν (degrees_of_freedom) shape (α) and scale (β) where +

+

+   α= ν /2 and β = ½. +

+
+ + + + + +
[Note]Note
+

+ This distribution does provide the + typedef: +

+

+ +

+
typedef inverse_chi_squared_distribution<double> inverse_chi_squared;
+

+

+

+ If you want a double precision + inverse_chi_squared distribution you can use +

+

+ +

+
boost::math::inverse_chi_squared_distribution<>
+

+

+

+ or you can write inverse_chi_squared + my_invchisqr(2, 3); +

+
+

+ For degrees of freedom parameter ν and scale parameter ξ, it is defined + by the probability density function (PDF): +

+

+   f(x;ν, ξ) = 2 -ν/2 e(-1/2x x (-1-ν/2) / Γ(ν/2) +

+

+ and Cumulative Density Function (CDF) +

+

+   F(x;ν, ξ) = Γ( ν /2, νξ/2x) / Γ(ν /2) +

+

+ The following graphs illustrate how the PDF and CDF of the inverse chi_squared + distribution varies for a few values of parameters ν and ξ: +

+

+ +

+

+ +

+
+ + Member + Functions +
+
inverse_chi_squared_distribution(RealType df = 1); // Implicitly scaled 1/df.
+inverse_chi_squared_distribution(RealType df = 1, RealType scale); // Explicitly scaled.
+
+

+ Constructs an inverse chi_squared distribution with ν degrees of freedom + df, and scale scale with default + value 1/df. +

+

+ Requires that the degrees of freedom ν parameter is greater than zero, + otherwise calls domain_error. +

+
RealType degrees_of_freedom()const; 
+
+

+ Returns the degrees_of_freedom ν parameter of this distribution. +

+
RealType scale()const; 
+
+

+ Returns the scale ξ parameter of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member + accessor functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, Quantile, Hazard + Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, skewness, + kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variate is [0,+∞]. +

+
+ + + + + +
[Note]Note

+ Unlike some definitions, this implementation supports a random variate + equal to zero as a special case, returning zero for both pdf and cdf. +

+
+ + Accuracy +
+

+ The inverse gamma distribution is implemented in terms of the incomplete + gamma functions like the Inverse + Gamma Distribution that use gamma_p + and gamma_q + and their inverses gamma_p_inv + and gamma_q_inv: + refer to the accuracy data for those functions for more information. + But in general, gamma (and thus inverse gamma) results are often accurate + to a few epsilon, >14 decimal digits accuracy for 64-bit double. unless + iteration is involved, as for the estimation of degrees of freedom. +

+
+ + Implementation +
+

+ In the following table ν is the degrees of freedom parameter and ξ is the + scale parameter of the distribution, x is the random + variate, p is the probability and q = + 1-p its complement. Parameters α for shape and β for scale are + used for the inverse gamma function: α = ν/2 and β = ν * ξ/2. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = gamma_p_derivative(α, + β/ x, β) / x * x +

+
+

+ cdf +

+
+

+ Using the relation: p = gamma_q(α, + β / x) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = gamma_p(α, + β / x) +

+
+

+ quantile +

+
+

+ Using the relation: x = β ​/ gamma_q_inv(α, + p) +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = α ​/ gamma_p_inv(α, + q) +

+
+

+ mode +

+
+

+ ν * ξ / (ν + 2) +

+
+

+ median +

+
+

+ no closed form analytic equation is known, but is evaluated + as quantile(0.5) +

+
+

+ mean +

+
+

+ νξ / (ν - 2) for ν > 2, else a domain_error +

+
+

+ variance +

+
+

+ 2 ν² ξ² / ((ν -2)² (ν -4)) for ν >4, else a domain_error +

+
+

+ skewness +

+
+

+ 4 √2 √(ν-4) /(ν-6) for ν >6, else a domain_error +

+
+

+ kurtosis_excess +

+
+

+ 12 * (5ν - 22) / ((ν - 6) * (ν - 8)) for ν >8, else a domain_error +

+
+

+ kurtosis +

+
+

+ 3 + 12 * (5ν - 22) / ((ν - 6) * (ν-8)) for ν >8, else a domain_error +

+
+
+ + References +
+
    +
  1. + Bayesian Data Analysis, Andrew Gelman, John B. Carlin, Hal S. Stern, + Donald B. Rubin, ISBN-13: 978-1584883883, Chapman & Hall; 2 edition + (29 July 2003). +
  2. +
  3. + Bayesian Computation with R, Jim Albert, ISBN-13: 978-0387922973, + Springer; 2nd ed. edition (10 Jun 2009) +
  4. +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_gamma_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_gamma_dist.html new file mode 100644 index 000000000..376b916f3 --- /dev/null +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_gamma_dist.html @@ -0,0 +1,382 @@ + + + +Inverse Gamma Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ +

+
#include <boost/math/distributions/inverse_gamma.hpp>
+

+

+
namespace boost{ namespace math{ 
+   
+template <class RealType = double, 
+          class Policy   = policies::policy<> >
+class inverse_gamma_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+
+   inverse_gamma_distribution(RealType shape, RealType scale = 1)
+
+   RealType shape()const;
+   RealType scale()const;
+};
+
+}} // namespaces
+
+

+ The inverse_gamma distribution is a continuous probability distribution + of the reciprocal of a variable distributed according to the gamma distribution. +

+

+ The inverse_gamma distribution is used in Bayesian statistics. +

+

+ See inverse + gamma distribution. +

+

+ R + inverse gamma distribution functions. +

+

+ Wolfram + inverse gamma distribution. +

+

+ See also Gamma + Distribution. +

+
+ + + + + +
[Note]Note
+

+ In spite of potential confusion with the inverse gamma function, this + distribution does provide the typedef: +

+

+ +

+
typedef inverse_gamma_distribution<double> gamma;
+

+

+

+ If you want a double precision + gamma distribution you can use +

+

+ +

+
boost::math::inverse_gamma_distribution<>
+

+

+

+ or you can write inverse_gamma + my_ig(2, 3); +

+
+

+ For shape parameter α and scale parameter β, it is defined by the probability + density function (PDF): +

+

+   f(x;α, β) = βα * (1/x) α+1 exp(-β/x) / Γ(α) +

+

+ and cumulative density function (CDF) +

+

+   F(x;α, β) = Γ(α, β/x) / Γ(α) +

+

+ The following graphs illustrate how the PDF and CDF of the inverse gamma + distribution varies as the parameters vary: +

+

+ +

+

+ +

+
+ + Member + Functions +
+
inverse_gamma_distribution(RealType shape = 1, RealType scale = 1);
+
+

+ Constructs an inverse gamma distribution with shape α and scale β. +

+

+ Requires that the shape and scale parameters are greater than zero, otherwise + calls domain_error. +

+
RealType shape()const;
+
+

+ Returns the α shape parameter of this inverse gamma distribution. +

+
RealType scale()const;
+
+

+ Returns the β scale parameter of this inverse gamma distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member + accessor functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, Quantile, Hazard + Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, skewness, + kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variate is [0,+∞]. +

+
+ + + + + +
[Note]Note

+ Unlike some definitions, this implementation supports a random variate + equal to zero as a special case, returning zero for pdf and cdf. +

+
+ + Accuracy +
+

+ The inverse gamma distribution is implemented in terms of the incomplete + gamma functions gamma_p + and gamma_q + and their inverses gamma_p_inv + and gamma_q_inv: + refer to the accuracy data for those functions for more information. + But in general, inverse_gamma results are accurate to a few epsilon, + >14 decimal digits accuracy for 64-bit double. +

+
+ + Implementation +
+

+ In the following table α is the shape parameter of the distribution, α ​ is + its scale parameter, x is the random variate, p + is the probability and q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = gamma_p_derivative(α, + β/ x, β) / x * x +

+
+

+ cdf +

+
+

+ Using the relation: p = gamma_q(α, + β / x) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = gamma_p(α, + β / x) +

+
+

+ quantile +

+
+

+ Using the relation: x = β ​/ gamma_q_inv(α, + p) +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = α ​/ gamma_p_inv(α, + q) +

+
+

+ mode +

+
+

+ β / (α + 1) +

+
+

+ median +

+
+

+ no analytic equation is known, but is evaluated as quantile(0.5) +

+
+

+ mean +

+
+

+ β / (α - 1) for α > 1, else a domain_error +

+
+

+ variance +

+
+

+ (β * β) / ((α - 1) * (α - 1) * (α - 2)) for α >2, else a domain_error +

+
+

+ skewness +

+
+

+ 4 * sqrt (α -2) / (α -3) for α >3, else a domain_error +

+
+

+ kurtosis_excess +

+
+

+ (30 * α - 66) / ((α-3)*(α - 4)) for α >4, else a domain_error +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/laplace_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/laplace_dist.html index 585674774..d4bf55608 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/laplace_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/laplace_dist.html @@ -62,7 +62,7 @@ 1972, p. 930). It is also called the double exponential distribution.

- For location parameter μ and scale parameter σ it is defined by the probability + For location parameter μ ​ and scale parameter σ ​ it is defined by the probability density function:

@@ -73,7 +73,7 @@ deviation of the normal or Gaussian distribution.

- The following graph illustrates the effect of the parameters μ and σ on the + The following graph illustrates the effect of the parameters μ ​ and σ ​ on the PDF. Note that the range of the random variable remains [-∞,+∞] irrespective of the value of the location parameter:

@@ -81,7 +81,7 @@

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

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

- + Accuracy

@@ -141,7 +141,7 @@ log and exp functions and as such should have very small errors.

- + Implementation

@@ -329,7 +329,7 @@

- + References
    @@ -350,9 +350,9 @@
-