test_real_concept_neg_bin.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // test_real_concept.cpp
  2. // Copyright Paul A. Bristow 2010.
  3. // Copyright John Maddock 2010.
  4. // Use, modification and distribution are subject to the
  5. // Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt
  7. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. // Tests real_concept for Negative Binomial and Geometric Distribution.
  9. // find_upper_bound ...
  10. #include <boost/math/concepts/real_concept.hpp> // for real_concept
  11. using ::boost::math::concepts::real_concept;
  12. #include <boost/math/distributions/geometric.hpp> // for geometric_distribution
  13. using boost::math::geometric_distribution;
  14. using boost::math::geometric; // using typedef for geometric_distribution<double>
  15. #include <boost/math/distributions/negative_binomial.hpp> // for some comparisons.
  16. #include <iostream>
  17. using std::cout;
  18. using std::endl;
  19. using std::setprecision;
  20. using std::showpoint;
  21. #include <limits>
  22. using std::numeric_limits;
  23. template <class RealType>
  24. void test_spot(RealType)
  25. {
  26. using boost::math::negative_binomial_distribution;
  27. // NOT boost::math::negative_binomial or boost::math::geometric
  28. // - because then you get the default negative_binomial_distribution<double>!!!
  29. RealType k = static_cast<RealType>(2.L);
  30. RealType alpha = static_cast<RealType>(0.05L);
  31. RealType p = static_cast<RealType>(0.5L);
  32. RealType result;
  33. result = negative_binomial_distribution<RealType>::find_lower_bound_on_p(static_cast<RealType>(k), static_cast<RealType>(1), static_cast<RealType>(alpha));
  34. result = negative_binomial_distribution<RealType>::find_lower_bound_on_p(k, 1, alpha);
  35. result = geometric_distribution<RealType>::find_lower_bound_on_p(k, alpha);
  36. }
  37. int main()
  38. {
  39. test_spot(boost::math::concepts::real_concept(0.)); // Test real concept.
  40. return 0;
  41. }