policy_ref_snip4.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #ifdef _MSC_VER
  9. # pragma warning (disable : 4305) // 'initializing' : truncation from 'long double' to 'const eval_type'
  10. # pragma warning (disable : 4244) // 'conversion' : truncation from 'long double' to 'const eval_type'
  11. #endif
  12. //[policy_ref_snip4
  13. #include <boost/math/distributions/normal.hpp>
  14. using boost::math::normal_distribution;
  15. using namespace boost::math::policies;
  16. // Define a policy:
  17. typedef policy<
  18. promote_float<false>
  19. > my_policy;
  20. // Define the new normal distribution using my_policy:
  21. typedef normal_distribution<float, my_policy> my_norm;
  22. // Get a quantile:
  23. float q = quantile(my_norm(), 0.05f);
  24. //] [policy_ref_snip4]
  25. #include <iostream>
  26. using std::cout; using std::endl;
  27. int main()
  28. {
  29. cout << " quantile(my_norm(), 0.05f) = " << q << endl; // -1.64485
  30. }