DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
// (C) Copyright John Maddock 2006. // 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) // // This is not a complete header file, it is included by gamma.hpp // after it has defined it's definitions. This inverts the incomplete // gamma functions P and Q on the first parameter "a" using a generic // root finding algorithm (TOMS Algorithm 748). // #ifndef BOOST_MATH_SP_DETAIL_GAMMA_INVA #define BOOST_MATH_SP_DETAIL_GAMMA_INVA #include
#include
namespace boost{ namespace math{ namespace detail{ template
struct gamma_inva_t { gamma_inva_t(T z_, T p_, bool invert_) : z(z_), p(p_), invert(invert_) {} T operator()(T a) { return invert ? p - boost::math::gamma_q(a, z, Policy()) : boost::math::gamma_p(a, z, Policy()) - p; } private: T z, p; bool invert; }; template
T inverse_poisson_cornish_fisher(T lambda, T p, T q, const Policy& pol) { BOOST_MATH_STD_USING // mean: T m = lambda; // standard deviation: T sigma = sqrt(lambda); // skewness T sk = 1 / sigma; // kurtosis: // T k = 1/lambda; // Get the inverse of a std normal distribution: T x = boost::math::erfc_inv(p > q ? 2 * q : 2 * p, pol) * constants::root_two
(); // Set the sign: if(p < 0.5) x = -x; T x2 = x * x; // w is correction term due to skewness T w = x + sk * (x2 - 1) / 6; /* // Add on correction due to kurtosis. // Disabled for now, seems to make things worse? // if(lambda >= 10) w += k * x * (x2 - 3) / 24 + sk * sk * x * (2 * x2 - 5) / -36; */ w = m + sigma * w; return w > tools::min_value
() ? w : tools::min_value
(); } template
T gamma_inva_imp(const T& z, const T& p, const T& q, const Policy& pol) { BOOST_MATH_STD_USING // for ADL of std lib math functions // // Special cases first: // if(p == 0) { return tools::max_value
(); } if(q == 0) { return tools::min_value
(); } // // Function object, this is the functor whose root // we have to solve: // gamma_inva_t
f(z, (p < q) ? p : q, (p < q) ? false : true); // // Tolerance: full precision. // tools::eps_tolerance
tol(policies::digits
()); // // Now figure out a starting guess for what a may be, // we'll start out with a value that'll put p or q // right bang in the middle of their range, the functions // are quite sensitive so we should need too many steps // to bracket the root from there: // T guess; T factor = 8; if(z >= 1) { // // We can use the relationship between the incomplete // gamma function and the poisson distribution to // calculate an approximate inverse, for large z // this is actually pretty accurate, but it fails badly // when z is very small. Also set our step-factor according // to how accurate we think the result is likely to be: // guess = 1 + inverse_poisson_cornish_fisher(z, q, p, pol); if(z > 5) { if(z > 1000) factor = 1.01f; else if(z > 50) factor = 1.1f; else if(guess > 10) factor = 1.25f; else factor = 2; if(guess < 1.1) factor = 8; } } else if(z > 0.5) { guess = z * 1.2f; } else { guess = -0.4f / log(z); } // // Max iterations permitted: // boost::uintmax_t max_iter = policies::get_max_root_iterations
(); // // Use our generic derivative-free root finding procedure. // We could use Newton steps here, taking the PDF of the // Poisson distribution as our derivative, but that's // even worse performance-wise than the generic method :-( // std::pair
r = bracket_and_solve_root(f, guess, factor, false, tol, max_iter, pol); if(max_iter >= policies::get_max_root_iterations
()) policies::raise_evaluation_error
("boost::math::gamma_p_inva<%1%>(%1%, %1%)", "Unable to locate the root within a reasonable number of iterations, closest approximation so far was %1%", r.first, pol); return (r.first + r.second) / 2; } } // namespace detail template
inline typename tools::promote_args
::type gamma_p_inva(T1 x, T2 p, const Policy& pol) { typedef typename tools::promote_args
::type result_type; typedef typename policies::evaluation
::type value_type; typedef typename policies::normalise< Policy, policies::promote_float
, policies::promote_double
, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; if(p == 0) { return tools::max_value
(); } if(p == 1) { return tools::min_value
(); } return policies::checked_narrowing_cast
( detail::gamma_inva_imp( static_cast
(x), static_cast
(p), 1 - static_cast
(p), pol), "boost::math::gamma_p_inva<%1%>(%1%, %1%)"); } template
inline typename tools::promote_args
::type gamma_q_inva(T1 x, T2 q, const Policy& pol) { typedef typename tools::promote_args
::type result_type; typedef typename policies::evaluation
::type value_type; typedef typename policies::normalise< Policy, policies::promote_float
, policies::promote_double
, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; if(q == 1) { return tools::max_value
(); } if(q == 0) { return tools::min_value
(); } return policies::checked_narrowing_cast
( detail::gamma_inva_imp( static_cast
(x), 1 - static_cast
(q), static_cast
(q), pol), "boost::math::gamma_q_inva<%1%>(%1%, %1%)"); } template
inline typename tools::promote_args
::type gamma_p_inva(T1 x, T2 p) { return boost::math::gamma_p_inva(x, p, policies::policy<>()); } template
inline typename tools::promote_args
::type gamma_q_inva(T1 x, T2 q) { return boost::math::gamma_q_inva(x, q, policies::policy<>()); } } // namespace math } // namespace boost #endif // BOOST_MATH_SP_DETAIL_GAMMA_INVA
gamma_inva.hpp
Page URL
File URL
Prev
16/24
Next
Download
( 6 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.