policy_ref_snip2.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright John Maddock 2007.
  2. // Copyright Paul A. Bristow 2010
  3. // Use, modification and distribution are subject to the
  4. // Boost Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. // Note that this file contains quickbook mark-up as well as code
  7. // and comments, don't change any of the special comment mark-ups!
  8. #include <iostream>
  9. using std::cout; using std::endl;
  10. //[policy_ref_snip2
  11. #include <boost/math/distributions/normal.hpp>
  12. using boost::math::normal_distribution;
  13. using namespace boost::math::policies;
  14. // Define a specific policy:
  15. typedef policy<
  16. overflow_error<ignore_error>
  17. > my_policy;
  18. // Define the distribution, using my_policy:
  19. typedef normal_distribution<double, my_policy> my_norm;
  20. // Construct a my_norm distribution, using default mean and standard deviation,
  21. // and get a 0.05 or 5% quantile:
  22. double q = quantile(my_norm(), 0.05); // = -1.64485
  23. //] //[/policy_ref_snip2]
  24. int main()
  25. {
  26. my_norm n; // Construct a my_norm distribution,
  27. // using default mean zero and standard deviation unity.
  28. double q = quantile(n, 0.05); // and get a quantile.
  29. cout << "quantile(my_norm(), 0.05) = " << q << endl;
  30. }
  31. /*
  32. Output:
  33. quantile(my_norm(), 0.05) = -1.64485
  34. */