 # Boost-Commit :

From: john_at_[hidden]
Date: 2007-09-17 06:09:34

Date: 2007-09-17 06:09:33 EDT (Mon, 17 Sep 2007)
New Revision: 39347
URL: http://svn.boost.org/trac/boost/changeset/39347

Log:
Fix problems with probabilities in Student's t examples.
Text files modified:
sandbox/math_toolkit/libs/math/doc/distributions/students_t_examples.qbk | 14 +++---
sandbox/math_toolkit/libs/math/example/students_t_single_sample.cpp | 84 ++++++++++++++++++++++++++++-----------
sandbox/math_toolkit/libs/math/example/students_t_two_samples.cpp | 59 +++++++++++----------------
3 files changed, 91 insertions(+), 66 deletions(-)

Modified: sandbox/math_toolkit/libs/math/doc/distributions/students_t_examples.qbk
==============================================================================
--- sandbox/math_toolkit/libs/math/doc/distributions/students_t_examples.qbk (original)
+++ sandbox/math_toolkit/libs/math/doc/distributions/students_t_examples.qbk 2007-09-17 06:09:33 EDT (Mon, 17 Sep 2007)
@@ -350,7 +350,7 @@
Sample Mean - Expected Test Mean = -1.10000
Degrees of Freedom = 2
T Statistic = -1.97566
- Probability that difference is due to chance = 9.343e-002
+ Probability that difference is due to chance = 1.869e-001

Results for Alternative Hypothesis and alpha = 0.0500'''

@@ -380,7 +380,7 @@
Sample Mean - Expected Test Mean = -1.10000
Degrees of Freedom = 2
T Statistic = -1.97566
-Probability that difference is due to chance = 9.343e-002
+Probability that difference is due to chance = 1.869e-001

Results for Alternative Hypothesis and alpha = 0.1000'''

@@ -592,7 +592,7 @@
students_t dist(v);
double q = cdf(complement(dist, fabs(t_stat)));
cout << setw(55) << left << "Probability that difference is due to chance" << "= "
- << setprecision(3) << scientific << q << "\n\n";
+ << setprecision(3) << scientific << 2 * q << "\n\n";

Here we've used the absolute value of the t-statistic, because we initially
want to know simply whether there is a difference or not (a two-sided test).
@@ -652,7 +652,7 @@
Degrees of Freedom = 326.00000
Pooled Standard Deviation = 326.00000
T Statistic = -12.62059
- Probability that difference is due to chance = 2.637e-030
+ Probability that difference is due to chance = 5.273e-030

Results for Alternative Hypothesis and alpha = 0.0500'''

@@ -663,7 +663,7 @@
]

So with a probability that the difference is due to chance of just
-2.637e-030, we can safely conclude that there is indeed a difference.
+5.273e-030, we can safely conclude that there is indeed a difference.

The tests on the alternative hypothesis show that the Sample 1 Mean is
greater than that for Sample 2: in this case Sample 1 represents the
@@ -728,7 +728,7 @@
Sample 2 Standard Deviation = 6.1077
Degrees of Freedom = 136.87
T Statistic = -12.946
- Probability that difference is due to chance = 7.855e-026
+ Probability that difference is due to chance = 1.571e-025

Results for Alternative Hypothesis and alpha = 0.0500'''

@@ -740,7 +740,7 @@

This time allowing the variances in the two samples to differ has yielded
a higher likelihood that the observed difference is down to chance alone
-(7.855e-026 compared to 2.637e-030 when equal variances were assumed).
+(1.571e-025 compared to 5.273e-030 when equal variances were assumed).
However, the conclusion remains the same: US cars are less fuel efficient
than Japanese models.

Modified: sandbox/math_toolkit/libs/math/example/students_t_single_sample.cpp
==============================================================================
--- sandbox/math_toolkit/libs/math/example/students_t_single_sample.cpp (original)
+++ sandbox/math_toolkit/libs/math/example/students_t_single_sample.cpp 2007-09-17 06:09:33 EDT (Mon, 17 Sep 2007)
@@ -135,7 +135,7 @@
students_t dist(v);
double q = cdf(complement(dist, fabs(t_stat)));
cout << setw(55) << left << "Probability that difference is due to chance" << "= "
- << setprecision(3) << scientific << q << "\n\n";
+ << setprecision(3) << scientific << 2 * q << "\n\n";
//
// Finally print out results of alternative hypothesis:
//
@@ -264,9 +264,12 @@
__________________________________
2-Sided Confidence Limits For Mean
__________________________________
+
Number of Observations = 195
Mean = 9.26146
Standard Deviation = 0.02278881
+
+
_______________________________________________________________
Confidence T Interval Lower Upper
Value (%) Value Width Limit Limit
@@ -279,46 +282,61 @@
99.900 3.341 5.453e-003 9.25601 9.26691
99.990 3.973 6.484e-003 9.25498 9.26794
99.999 4.537 7.404e-003 9.25406 9.26886
+
__________________________________
Student t test for a single sample
__________________________________
+
Number of Observations = 195
Sample Mean = 9.26146
Sample Standard Deviation = 0.02279
Expected True Mean = 5.00000
+
Sample Mean - Expected Test Mean = 4.26146
Degrees of Freedom = 194
T Statistic = 2611.28380
Probability that difference is due to chance = 0.000e+000
+
Results for Alternative Hypothesis and alpha = 0.0500
+
Alternative Hypothesis Conclusion
Mean != 5.000 NOT REJECTED
Mean < 5.000 REJECTED
Mean > 5.000 NOT REJECTED
+
+
_____________________________________________________________
Estimated sample sizes required for various confidence levels
_____________________________________________________________
+
True Mean = 5.00000
Sample Mean = 9.26146
Sample Standard Deviation = 0.02279
+
+
_______________________________________________________________
-Confidence Estimated
- Value (%) Sample Size
+Confidence Estimated Estimated
+ Value (%) Sample Size Sample Size
+ (one sided test) (two sided test)
_______________________________________________________________
- 50.000 2
- 75.000 2
- 90.000 2
- 95.000 2
- 99.000 2
- 99.900 3
- 99.990 3
- 99.999 3
+ 50.000 2 2
+ 75.000 2 2
+ 90.000 2 2
+ 95.000 2 2
+ 99.000 2 2
+ 99.900 3 3
+ 99.990 3 3
+ 99.999 4 4
+
__________________________________
2-Sided Confidence Limits For Mean
__________________________________
+
Number of Observations = 3
Mean = 37.8000000
Standard Deviation = 0.9643650
+
+
_______________________________________________________________
Confidence T Interval Lower Upper
Value (%) Value Width Limit Limit
@@ -331,56 +349,74 @@
99.900 31.599 17.594 20.20639 55.39361
99.990 99.992 55.673 -17.87346 93.47346
99.999 316.225 176.067 -138.26683 213.86683
+
__________________________________
Student t test for a single sample
__________________________________
+
Number of Observations = 3
Sample Mean = 37.80000
Sample Standard Deviation = 0.96437
Expected True Mean = 38.90000
+
Sample Mean - Expected Test Mean = -1.10000
Degrees of Freedom = 2
T Statistic = -1.97566
-Probability that difference is due to chance = 9.343e-002
+Probability that difference is due to chance = 1.869e-001
+
Results for Alternative Hypothesis and alpha = 0.0500
+
Alternative Hypothesis Conclusion
Mean != 38.900 REJECTED
Mean < 38.900 REJECTED
Mean > 38.900 REJECTED
+
+
__________________________________
Student t test for a single sample
__________________________________
+
Number of Observations = 3
Sample Mean = 37.80000
Sample Standard Deviation = 0.96437
Expected True Mean = 38.90000
+
Sample Mean - Expected Test Mean = -1.10000
Degrees of Freedom = 2
T Statistic = -1.97566
-Probability that difference is due to chance = 9.343e-002
+Probability that difference is due to chance = 1.869e-001
+
Results for Alternative Hypothesis and alpha = 0.1000
+
Alternative Hypothesis Conclusion
-Mean != 38.900 NOT REJECTED
+Mean != 38.900 REJECTED
Mean < 38.900 NOT REJECTED
Mean > 38.900 REJECTED
+
+
_____________________________________________________________
Estimated sample sizes required for various confidence levels
_____________________________________________________________
+
True Mean = 38.90000
Sample Mean = 37.80000
Sample Standard Deviation = 0.96437
+
+
_______________________________________________________________
-Confidence Estimated
- Value (%) Sample Size
+Confidence Estimated Estimated
+ Value (%) Sample Size Sample Size
+ (one sided test) (two sided test)
_______________________________________________________________
- 50.000 2
- 75.000 2
- 90.000 3
- 95.000 5
- 99.000 8
- 99.900 13
- 99.990 18
- 99.999 23
+ 50.000 2 2
+ 75.000 3 4
+ 90.000 7 9
+ 95.000 11 13
+ 99.000 20 22
+ 99.900 35 37
+ 99.990 50 53
+ 99.999 66 68
+
Build Time 0:03
Build log was saved at "file://i:\boost-06-05-03-1300\libs\math\test\Math_test\students_t_single_sample\Debug\BuildLog.htm"
students_t_single_sample - 0 error(s), 0 warning(s)

Modified: sandbox/math_toolkit/libs/math/example/students_t_two_samples.cpp
==============================================================================
--- sandbox/math_toolkit/libs/math/example/students_t_two_samples.cpp (original)
+++ sandbox/math_toolkit/libs/math/example/students_t_two_samples.cpp 2007-09-17 06:09:33 EDT (Mon, 17 Sep 2007)
@@ -72,7 +72,7 @@
students_t dist(v);
double q = cdf(complement(dist, fabs(t_stat)));
cout << setw(55) << left << "Probability that difference is due to chance" << "= "
- << setprecision(3) << scientific << q << "\n\n";
+ << setprecision(3) << scientific << 2 * q << "\n\n";
//
// Finally print out results of alternative hypothesis:
//
@@ -160,7 +160,7 @@
students_t dist(v);
double q = cdf(complement(dist, fabs(t_stat)));
cout << setw(55) << left << "Probability that difference is due to chance" << "= "
- << setprecision(3) << scientific << q << "\n\n";
+ << setprecision(3) << scientific << 2 * q << "\n\n";
//
// Finally print out results of alternative hypothesis:
//
@@ -208,61 +208,50 @@
students_t_two_samples.cpp
Autorun "i:\boost-06-05-03-1300\libs\math\test\Math_test\debug\students_t_two_samples.exe"
-_________________________________________________
-Student t test for two samples (unequal variances)
-_________________________________________________
+_______________________________________________
+Student t test for two samples (equal variances)
+_______________________________________________
+
Number of Observations (Sample 1) = 249
Sample 1 Mean = 20.145
Sample 1 Standard Deviation = 6.4147
Number of Observations (Sample 2) = 79
Sample 2 Mean = 30.481
Sample 2 Standard Deviation = 6.1077
-Degrees of Freedom = 136.87
-T Statistic = -12.946
-Probability that difference is due to chance = 7.855e-026
+Degrees of Freedom = 326
+Pooled Standard Deviation = 326
+T Statistic = -12.621
+Probability that difference is due to chance = 5.273e-030
+
Results for Alternative Hypothesis and alpha = 0.0500
+
Alternative Hypothesis Conclusion
Sample 1 Mean != Sample 2 Mean NOT REJECTED
Sample 1 Mean < Sample 2 Mean NOT REJECTED
Sample 1 Mean > Sample 2 Mean REJECTED
-_______________________________________________
-Student t test for two samples (equal variances)
-_______________________________________________
+
+
+_________________________________________________
+Student t test for two samples (unequal variances)
+_________________________________________________
+
Number of Observations (Sample 1) = 249
Sample 1 Mean = 20.14458
Sample 1 Standard Deviation = 6.41470
Number of Observations (Sample 2) = 79
Sample 2 Mean = 30.48101
Sample 2 Standard Deviation = 6.10771
-Degrees of Freedom = 326.00000
-Pooled Standard Deviation = 326.00000
-T Statistic = -12.62059
-Probability that difference is due to chance = 2.637e-030
+Degrees of Freedom = 136.87499
+T Statistic = -12.94627
+Probability that difference is due to chance = 1.571e-025
+
Results for Alternative Hypothesis and alpha = 0.0500
+
Alternative Hypothesis Conclusion
Sample 1 Mean != Sample 2 Mean NOT REJECTED
Sample 1 Mean < Sample 2 Mean NOT REJECTED
Sample 1 Mean > Sample 2 Mean REJECTED
-_____________________________________________________________
-Estimated sample sizes required for various confidence levels
-_____________________________________________________________
-Sample 1 Mean = 20.14458
-Sample 1 Standard Deviation = 6.41470
-Sample 1 Size = 249
-Sample 2 Mean = 30.48101
-Sample 2 Standard Deviation = 6.10771
-_______________________________________________________________________
-Confidence Estimated Sample Size Estimated Sample 2 Size
- Value (%) (With Two Equal Sizes) (With Fixed Sample 1 Size)
-_______________________________________________________________________
- 50.000 1 0
- 75.000 2 1
- 90.000 3 1
- 95.000 4 2
- 99.000 6 3
- 99.900 10 4
- 99.990 14 6
- 99.999 18 8
+
Build Time 0:03
Build log was saved at "file://i:\boost-06-05-03-1300\libs\math\test\Math_test\students_t_two_samples\Debug\BuildLog.htm"
students_t_two_samples - 0 error(s), 0 warning(s)