Boost logo

Boost-Commit :

From: pbristow_at_[hidden]
Date: 2007-09-16 11:21:09


Author: pbristow
Date: 2007-09-16 11:21:08 EDT (Sun, 16 Sep 2007)
New Revision: 39321
URL: http://svn.boost.org/trac/boost/changeset/39321

Log:
Cosmetic - correction sin chisqr by JM to correct problem
Text files modified:
   sandbox/math_toolkit/libs/math/example/chi_square_std_dev_test.cpp | 34 +++++++++++++++++++++++-----------
   1 files changed, 23 insertions(+), 11 deletions(-)

Modified: sandbox/math_toolkit/libs/math/example/chi_square_std_dev_test.cpp
==============================================================================
--- sandbox/math_toolkit/libs/math/example/chi_square_std_dev_test.cpp (original)
+++ sandbox/math_toolkit/libs/math/example/chi_square_std_dev_test.cpp 2007-09-16 11:21:08 EDT (Sun, 16 Sep 2007)
@@ -1,16 +1,11 @@
-// Copyright John Maddock 2006
+// Copyright John Maddock 2006, 2007
 // Copyright Paul A. Bristow 2007
+
 // 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)
 
-#ifdef _MSC_VER
-# pragma warning(disable: 4512) // assignment operator could not be generated.
-# pragma warning(disable: 4510) // default constructor could not be generated.
-# pragma warning(disable: 4610) // can never be instantiated - user defined constructor required.
-#endif
-
 #include <iostream>
 #include <iomanip>
 #include <boost/math/distributions/chi_squared.hpp>
@@ -159,6 +154,9 @@
    using namespace std;
    using namespace boost::math;
 
+ try
+ {
+
    // Print out general info:
    cout <<
       "_____________________________________________________________\n"
@@ -170,7 +168,7 @@
    //
    // Define a table of significance levels:
    //
- double alpha[] = { 0.5, 0.25, 0.1, 0.05, 0.01, 0.001, 0.0001, 0.00001 };
+ double alpha[] = { 0.5, 0.33333333333333333333333, 0.25, 0.1, 0.05, 0.01, 0.001, 0.0001, 0.00001 };
    //
    // Print table header:
    //
@@ -178,7 +176,7 @@
            "_______________________________________________________________\n"
            "Confidence Estimated Estimated\n"
            " Value (%) Sample Size Sample Size\n"
- " (lower one (upper one\n"
+ " (lower one- (upper one-\n"
            " sided test) sided test)\n"
            "_______________________________________________________________\n";
    //
@@ -188,14 +186,14 @@
    {
       // Confidence value:
       cout << fixed << setprecision(3) << setw(10) << right << 100 * (1-alpha[i]);
- // calculate df for a lower single sided test:
+ // calculate df for a lower single-sided test:
       double df = chi_squared::estimate_degrees_of_freedom(
          -diff, alpha[i], alpha[i], variance);
       // convert to sample size:
       double size = ceil(df) + 1;
       // Print size:
       cout << fixed << setprecision(0) << setw(16) << right << size;
- // calculate df for an upper single sided test:
+ // calculate df for an upper single-sided test:
       df = chi_squared::estimate_degrees_of_freedom(
          diff, alpha[i], alpha[i], variance);
       // convert to sample size:
@@ -204,8 +202,22 @@
       cout << fixed << setprecision(0) << setw(16) << right << size << endl;
    }
    cout << endl;
+ }
+ catch(const std::exception& e)
+ { // Always useful to include try & catch blocks because default policies
+ // are to throw exceptions on arguments that cause errors like underflow, overflow.
+ // Lacking try & catch blocks, the program will abort without a message below,
+ // which may give some helpful clues as to the cause of the exception.
+ std::cout <<
+ "\n""Message from thrown exception was:\n " << e.what() << std::endl;
+ }
 }
 
+//Message from thrown exception was: for alpha 0.5
+// Error in function boost::math::tools::bracket_and_solve_root<double>:
+//Unable to bracket root, last nearest value was 1.2446030555722283e-058
+
+
 int main()
 {
    //


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk