⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 igamma_inv.qbk

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 QBK
字号:
[section:igamma_inv Incomplete Gamma Function Inverses][h4 Synopsis]``#include <boost/math/special_functions/gamma.hpp>``   namespace boost{ namespace math{      template <class T1, class T2>   ``__sf_result`` gamma_q_inv(T1 a, T2 q);      template <class T1, class T2, class ``__Policy``>   ``__sf_result`` gamma_q_inv(T1 a, T2 q, const ``__Policy``&);      template <class T1, class T2>   ``__sf_result`` gamma_p_inv(T1 a, T2 p);      template <class T1, class T2, class ``__Policy``>   ``__sf_result`` gamma_p_inv(T1 a, T2 p, const ``__Policy``&);      template <class T1, class T2>   ``__sf_result`` gamma_q_inva(T1 x, T2 q);      template <class T1, class T2, class ``__Policy``>   ``__sf_result`` gamma_q_inva(T1 x, T2 q, const ``__Policy``&);      template <class T1, class T2>   ``__sf_result`` gamma_p_inva(T1 x, T2 p);      template <class T1, class T2, class ``__Policy``>   ``__sf_result`` gamma_p_inva(T1 x, T2 p, const ``__Policy``&);      }} // namespaces   [h4 Description]There are four [@http://mathworld.wolfram.com/IncompleteGammaFunction.html incomplete gamma function]inverses which either compute/x/ given /a/ and /p/ or /q/,or else compute /a/ given /x/ and either /p/ or /q/.The return type of these functions is computed using the __arg_pomotion_ruleswhen T1 and T2 are different types, otherwise the return type is simply T1.[optional_policy][tip When people normally talk about the inverse of the incompletegamma function, they are talking about inverting on parameter /x/.These are implemented here as gamma_p_inv and gamma_q_inv, and are byfar the most efficient of the inverses presented here.The inverse on the /a/ parameter finds use in some statisticalapplications but has to be computed by rather brute force numericaltechniques and is consequently several times slower.These are implemented here as gamma_p_inva and gamma_q_inva.]   template <class T1, class T2>   ``__sf_result`` gamma_q_inv(T1 a, T2 q);   template <class T1, class T2, class ``__Policy``>   ``__sf_result`` gamma_q_inv(T1 a, T2 q, const ``__Policy``&);Returns a value x such that: `q = gamma_q(a, x);`Requires: /a > 0/ and /1 >= p,q >= 0/.   template <class T1, class T2>   ``__sf_result`` gamma_p_inv(T1 a, T2 p);      template <class T1, class T2, class ``__Policy``>   ``__sf_result`` gamma_p_inv(T1 a, T2 p, const ``__Policy``&);   Returns a value x such that: `p = gamma_p(a, x);`Requires: /a > 0/ and /1 >= p,q >= 0/.   template <class T1, class T2>   ``__sf_result`` gamma_q_inva(T1 x, T2 q);   template <class T1, class T2, class ``__Policy``>   ``__sf_result`` gamma_q_inva(T1 x, T2 q, const ``__Policy``&);Returns a value a such that: `q = gamma_q(a, x);`Requires: /x > 0/ and /1 >= p,q >= 0/.   template <class T1, class T2>   ``__sf_result`` gamma_p_inva(T1 x, T2 p);      template <class T1, class T2, class ``__Policy``>   ``__sf_result`` gamma_p_inva(T1 x, T2 p, const ``__Policy``&);   Returns a value a such that: `p = gamma_p(a, x);`Requires: /x > 0/ and /1 >= p,q >= 0/.[h4 Accuracy]The accuracy of these functions doesn't vary much by platform or bythe type T.  Given that these functions are computed by iterative methods,they are deliberately "detuned" so as not to be too accurate: it is inany case impossible for these function to be more accurate than theregular forward incomplete gamma functions.  In practice, the accuracyof these functions is very similar to that of __gamma_p and __gamma_qfunctions.[h4 Testing]There are two sets of tests: * Basic sanity checks attempt to "round-trip" from/a/ and /x/ to /p/ or /q/ and back again.  These tests have quitegenerous tolerances: in general both the incomplete gamma, and itsinverses, change so rapidly that round tripping to more than a coupleof significant digits isn't possible.  This is especially true when/p/ or /q/ is very near one: in this case there isn't enough "information content" in the input to the inverse function to getback where you started.* Accuracy checks using high precision test values.  These measurethe accuracy of the result, given exact input values.[h4 Implementation]The functions gamma_p_inv and [@http://functions.wolfram.com/GammaBetaErf/InverseGammaRegularized/ gamma_q_inv]share a common implementation.First an initial approximation is computed using the methodology describedin:[@http://portal.acm.org/citation.cfm?id=23109&coll=portal&dl=ACM A. R. Didonato and A. H. Morris, Computation of the Incomplete Gamma Function Ratios and their Inverse, ACM Trans. Math. Software 12 (1986), 377-393.]Finally, the last few bits are cleaned up using Halley iteration, the iterationlimit is set to 2/3 of the number of bits in T, which by experiment issufficient to ensure that the inverses are at least as accurate as the normalincomplete gamma functions.  In testing, no more than 3 iterations are requiredto produce a result as accurate as the forward incomplete gamma function, andin many cases only one iteration is required.The functions gamma_p_inva and gamma_q_inva also share a common implementationbut are handled separately from gamma_p_inv and gamma_q_inv.An initial approximation for /a/ is computed very crudely so that/gamma_p(a, x) ~ 0.5/, this value is then used as a starting pointfor a generic derivative-free root finding algorithm.  As a consequence,these two functions are rather more expensive to compute than the gamma_p_inv or gamma_q_inv functions.  Even so, the root is usually foundin fewer than 10 iterations.[endsect][/section The Incomplete Gamma Function Inverses][/   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).]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -