$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r66719 - trunk/libs/math/example
From: pbristow_at_[hidden]
Date: 2010-11-24 11:31:13
Author: pbristow
Date: 2010-11-24 11:31:10 EST (Wed, 24 Nov 2010)
New Revision: 66719
URL: http://svn.boost.org/trac/boost/changeset/66719
Log:
Comments etc
Text files modified: 
   trunk/libs/math/example/neg_binom_confidence_limits.cpp |     2                                         
   trunk/libs/math/example/neg_binomial_sample_sizes.cpp   |   216 ++++++++++++++++++++------------------- 
   trunk/libs/math/example/normal_misc_examples.cpp        |     4                                         
   trunk/libs/math/example/policy_eg_1.cpp                 |    15 ++                                      
   trunk/libs/math/example/policy_ref_snip8.cpp            |     6                                         
   5 files changed, 132 insertions(+), 111 deletions(-)
Modified: trunk/libs/math/example/neg_binom_confidence_limits.cpp
==============================================================================
--- trunk/libs/math/example/neg_binom_confidence_limits.cpp	(original)
+++ trunk/libs/math/example/neg_binom_confidence_limits.cpp	2010-11-24 11:31:10 EST (Wed, 24 Nov 2010)
@@ -37,7 +37,6 @@
   double alpha[] = { 0.5, 0.25, 0.1, 0.05, 0.01, 0.001, 0.0001, 0.00001 };
 
 /*`
-
 Confidence value as % is (1 - alpha) * 100, so alpha 0.05 == 95% confidence
 that the true occurence frequency lies *inside* the calculated interval.
 
@@ -81,7 +80,6 @@
 single-sided interval, for example: ['"Calculate a lower bound so that we are P%
 sure that the true occurrence frequency is greater than some value"]
 then we would *not* have divided by two.
-
 */
 
    // Now print out the upper and lower limits for the alpha table values.
Modified: trunk/libs/math/example/neg_binomial_sample_sizes.cpp
==============================================================================
--- trunk/libs/math/example/neg_binomial_sample_sizes.cpp	(original)
+++ trunk/libs/math/example/neg_binomial_sample_sizes.cpp	2010-11-24 11:31:10 EST (Wed, 24 Nov 2010)
@@ -29,8 +29,8 @@
 //[neg_binomial_sample_sizes
 
 /*`
-It centres around a routine that prints out
-a table of minimum sample sizes for various probability thresholds:
+It centres around a routine that prints out a table of 
+minimum sample sizes (number of trials) for various probability thresholds:
 */
   void find_number_of_trials(double failures, double p);
 /*`
@@ -41,6 +41,8 @@
 /*`
 Confidence value as % is (1 - alpha) * 100, so alpha 0.05 == 95% confidence
 that the desired number of failures will be observed.
+The values range from a very low 0.5 or 50% confidence up to an extremely high
+confidence of 99.999.
 
 Much of the rest of the program is pretty-printing, the important part
 is in the calculation of minimum number of trials required for each
@@ -48,13 +50,8 @@
 
   (int)ceil(negative_binomial::find_minimum_number_of_trials(failures, p, alpha[i]);
 
-*/
-
-/*`
-
 find_minimum_number_of_trials returns a double,
-so ceil rounds this up to ensure we have an integral minimum number of trials.
-
+so `ceil` rounds this up to ensure we have an integral minimum number of trials.
 */
   
 void find_number_of_trials(double failures, double p)
@@ -66,11 +63,10 @@
    // Calculate how many trials we need to ensure the
    // required number of failures DOES exceed "failures".
 
-  cout << "\n""Target number of failures = " << failures;
-  cout << ",   Success fraction = " << 100 * p << "%" << endl;
+  cout << "\n""Target number of failures = " << (int)failures;
+  cout << ",   Success fraction = " << fixed << setprecision(1) << 100 * p << "%" << endl;
    // Print table header:
-   cout << "\n\n"
-           "____________________________\n"
+   cout << "____________________________\n"
            "Confidence        Min Number\n"
            " Value (%)        Of Trials \n"
            "____________________________\n";
@@ -106,98 +102,108 @@
 /*
 
 Output is:
-
-Autorun "i:\boost-06-05-03-1300\libs\math\test\Math_test\debug\neg_binomial_sample_sizes.exe"
-Target number of failures = 5,   Success fraction = 50%
-____________________________
-Confidence        Min Number
- Value (%)        Of Trials 
-____________________________
-    50.000          11
-    75.000          14
-    90.000          17
-    95.000          18
-    99.000          22
-    99.900          27
-    99.990          31
-    99.999          36
-Target number of failures = 50.000,   Success fraction = 50.000%
-____________________________
-Confidence        Min Number
- Value (%)        Of Trials 
-____________________________
-    50.000         101
-    75.000         109
-    90.000         115
-    95.000         119
-    99.000         128
-    99.900         137
-    99.990         146
-    99.999         154
-Target number of failures = 500.000,   Success fraction = 50.000%
-____________________________
-Confidence        Min Number
- Value (%)        Of Trials 
-____________________________
-    50.000        1001
-    75.000        1023
-    90.000        1043
-    95.000        1055
-    99.000        1078
-    99.900        1104
-    99.990        1126
-    99.999        1146
-Target number of failures = 50.000,   Success fraction = 10.000%
-____________________________
-Confidence        Min Number
- Value (%)        Of Trials 
-____________________________
-    50.000          56
-    75.000          58
-    90.000          60
-    95.000          61
-    99.000          63
-    99.900          66
-    99.990          68
-    99.999          71
-Target number of failures = 500.000,   Success fraction = 10.000%
-____________________________
-Confidence        Min Number
- Value (%)        Of Trials 
-____________________________
-    50.000         556
-    75.000         562
-    90.000         567
-    95.000         570
-    99.000         576
-    99.900         583
-    99.990         588
-    99.999         594
-Target number of failures = 5.000,   Success fraction = 90.000%
-____________________________
-Confidence        Min Number
- Value (%)        Of Trials 
-____________________________
-    50.000          57
-    75.000          73
-    90.000          91
-    95.000         103
-    99.000         127
-    99.900         159
-    99.990         189
-    99.999         217
-Target number of failures = 5.000,   Success fraction = 40.000%
-____________________________
-Confidence        Min Number
- Value (%)        Of Trials 
-____________________________
-    50.000          10
-    75.000          11
-    90.000          13
-    95.000          15
-    99.000          18
-    99.900          21
-    99.990          25
-    99.999          28
+Target number of failures = 5,   Success fraction = 50.0%
+  ____________________________
+  Confidence        Min Number
+   Value (%)        Of Trials 
+  ____________________________
+      50.000          11
+      75.000          14
+      90.000          17
+      95.000          18
+      99.000          22
+      99.900          27
+      99.990          31
+      99.999          36
+  
+  
+  Target number of failures = 50,   Success fraction = 50.0%
+  ____________________________
+  Confidence        Min Number
+   Value (%)        Of Trials 
+  ____________________________
+      50.000         101
+      75.000         109
+      90.000         115
+      95.000         119
+      99.000         128
+      99.900         137
+      99.990         146
+      99.999         154
+  
+  
+  Target number of failures = 500,   Success fraction = 50.0%
+  ____________________________
+  Confidence        Min Number
+   Value (%)        Of Trials 
+  ____________________________
+      50.000        1001
+      75.000        1023
+      90.000        1043
+      95.000        1055
+      99.000        1078
+      99.900        1104
+      99.990        1126
+      99.999        1146
+  
+  
+  Target number of failures = 50,   Success fraction = 10.0%
+  ____________________________
+  Confidence        Min Number
+   Value (%)        Of Trials 
+  ____________________________
+      50.000          56
+      75.000          58
+      90.000          60
+      95.000          61
+      99.000          63
+      99.900          66
+      99.990          68
+      99.999          71
+  
+  
+  Target number of failures = 500,   Success fraction = 10.0%
+  ____________________________
+  Confidence        Min Number
+   Value (%)        Of Trials 
+  ____________________________
+      50.000         556
+      75.000         562
+      90.000         567
+      95.000         570
+      99.000         576
+      99.900         583
+      99.990         588
+      99.999         594
+  
+  
+  Target number of failures = 5,   Success fraction = 90.0%
+  ____________________________
+  Confidence        Min Number
+   Value (%)        Of Trials 
+  ____________________________
+      50.000          57
+      75.000          73
+      90.000          91
+      95.000         103
+      99.000         127
+      99.900         159
+      99.990         189
+      99.999         217
+  
+  
+  Target number of failures = 5,   Success fraction = 95.0%
+  ____________________________
+  Confidence        Min Number
+   Value (%)        Of Trials 
+  ____________________________
+      50.000         114
+      75.000         148
+      90.000         184
+      95.000         208
+      99.000         259
+      99.900         324
+      99.990         384
+      99.999         442
 
 */
Modified: trunk/libs/math/example/normal_misc_examples.cpp
==============================================================================
--- trunk/libs/math/example/normal_misc_examples.cpp	(original)
+++ trunk/libs/math/example/normal_misc_examples.cpp	2010-11-24 11:31:10 EST (Wed, 24 Nov 2010)
@@ -40,6 +40,10 @@
       double step = 1.; // in z 
       double range = 4; // min and max z = -range to +range.
       int precision = 17; // traditional tables are only computed to much lower precision.
+      // but std::numeric_limits<double>::max_digits10; on new Standard Libraries gives
+      // 17, the maximum number of digits that can possibly be significant.
+      // std::numeric_limits<double>::digits10; == 15 is number of guaranteed digits,
+      // the other two digits being 'noisy'.
 
       // Construct a standard normal distribution s
         normal s; // (default mean = zero, and standard deviation = unity)
Modified: trunk/libs/math/example/policy_eg_1.cpp
==============================================================================
--- trunk/libs/math/example/policy_eg_1.cpp	(original)
+++ trunk/libs/math/example/policy_eg_1.cpp	2010-11-24 11:31:10 EST (Wed, 24 Nov 2010)
@@ -14,7 +14,20 @@
 using boost::math::tgamma;
 
 // Define the policy to use:
-using namespace boost::math::policies;
+using namespace boost::math::policies; // may be convenient, or
+
+using boost::math::policies::policy;
+// Types of error whose action can be altered by policies:.
+using boost::math::policies::evaluation_error;
+using boost::math::policies::domain_error;
+using boost::math::policies::overflow_error;
+using boost::math::policies::domain_error;
+using boost::math::policies::pole_error;
+// Actions on error (in enum error_policy_type):
+using boost::math::policies::errno_on_error;
+using boost::math::policies::ignore_error;
+using boost::math::policies::throw_on_error;
+using boost::math::policies::user_error;
 
 typedef policy<
    domain_error<errno_on_error>,
Modified: trunk/libs/math/example/policy_ref_snip8.cpp
==============================================================================
--- trunk/libs/math/example/policy_ref_snip8.cpp	(original)
+++ trunk/libs/math/example/policy_ref_snip8.cpp	2010-11-24 11:31:10 EST (Wed, 24 Nov 2010)
@@ -19,9 +19,9 @@
       policy<discrete_quantile<integer_round_nearest> > 
    > dist_type;
    
-// Lower quantile rounded up:
+// Lower quantile rounded (down) to nearest:
 double x = quantile(dist_type(20, 0.3), 0.05); // 27
-// Upper quantile rounded down:
+// Upper quantile rounded (down) to nearest:
 double y = quantile(complement(dist_type(20, 0.3), 0.05)); // 68
 
 //] //[/policy_ref_snip8]
@@ -40,8 +40,8 @@
 
 Output:
 
+   using policy<discrete_quantile<integer_round_nearest> 
   quantile(dist_type(20, 0.3), 0.05) = 27
   quantile(complement(dist_type(20, 0.3), 0.05)) 68
 
-
 */