2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Updated to use distributions & cosmetic, & removals of warnings at level 4.

[SVN r3134]
This commit is contained in:
Paul A. Bristow
2006-08-12 16:09:46 +00:00
parent 9ec09012c3
commit ed7804629d
3 changed files with 61 additions and 83 deletions

View File

@@ -1,4 +1,5 @@
// students_t_example1.cpp
// Copyright Paul A. Bristow 2006.
// Use, modification and distribution are subject to the
@@ -39,8 +40,8 @@ double value[values] = {38.9, 37.4, 37.1};
// Is there any evidence for systematic error?
// The Students't distribution function is described at
// http://en.wikipedia.org/wiki/Student%27s_t_distribution
#include <boost/math/distributions/students_t.hpp>
using boost::math::students_t; // Probability of students_t(df, t).
@@ -92,61 +93,21 @@ int main()
Output is:
Example 1 using Student's t function. ..\..\..\..\..\..\boost-sandbox\libs\mat
h_functions\example\students_t_example1.cpp Tue Jul 11 12:44:17 2006 140050727
------ Build started: Project: students_t_example1, Configuration: Debug Win32 ------
Compiling...
students_t_example1.cpp
Linking...
Autorun "i:\boost-06-05-03-1300\libs\math\test\Math_test\debug\students_t_example1.exe"
Example 1 using Student's t function. ..\..\..\..\..\..\boost-sandbox\libs\math_functions\example\students_t_example1.cpp Sat Aug 12 16:54:41 2006 140050727
Measurement 1 = 38.9, measurement 2 = 37.4, measurement 3 = 37.1
Standard = 38.9, mean = 37.8, (mean - standard) = -1.1
Standard deviation = 0.964365
Probability of Student's t -1.976 with 2 degrees of freedom is 0.9066 (1-tailed).
Press any key to continue . . .
*/
/*
Obselete junk?
double p = students_t(degrees_of_freedom, t);
p = students_t(degrees_of_freedom, t);
cout << "Probability of t = " << t << " is " << p << endl;
//t = 4.30; 4.30265272974946
//p = students_t(degrees_of_freedom, t); // 0.975 = tquantiles value
//cout << "Probability of t = " << t << " is " << p << endl;
// But MathCAD pt(2, 4.30265272974946) = 0.944426429950027 ??? expect 0.95
//t = 2.92;
//p = students_t(degrees_of_freedom, t); // 0.95
//cout << "Probability of t = " << t << " is " << p << endl;
//t = -2.92;
//p = students_t(degrees_of_freedom, t); // 0.05
//cout << "Probability of t = " << t << " is " << p << endl;
// Means probability(t < 1.533) = 0.9 == 90%, a one-sided or one-tailed-test.
// http://faculty.vassar.edu/lowry/VassarStats.html
// calculator gives mean = 37.8, difference from 'hypothetical population mean' == SRM 38.9 is -1.1,
// t = -1.975, 2 df, P 1-tailed = 0.093474, 2-tailed = 0.186948.
Example 1 using Student's t function. ..\..\..\..\..\..\boost-sandbox\libs\mat
h_functions\example\students_t_example1.cpp Sat Jun 17 11:25:02 2006 140050727
mean = 37.8
standard deviation = 0.964365
Student's t = -1.97566
Probability of t = -1.97566 is 0.0934283
Probability of t = 4.3 is 0.974971
Probability of t = 2.92 is 0.95
Probability of t = -2.92 is 0.0499996
Probability of Student's t = 0.05
Press any key to continue . . .
Probability of Student's t is 0.90657
Build Time 0:03
Build log was saved at "file://i:\boost-06-05-03-1300\libs\math\test\Math_test\students_t_example1\Debug\BuildLog.htm"
students_t_example1 - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
*/

View File

@@ -1,6 +1,6 @@
// students_t_example2.cpp
// Copyright Paul A. Bristow 2006.
// Copyright Paul A. Bristow 2006.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -97,8 +97,12 @@ int main()
Output is:
Example2 using Student's t function. ..\..\..\..\..\..\boost-sandbox\libs\math
_functions\example\students_t_example2.cpp Sat Jun 17 16:39:11 2006 140050727
------ Build started: Project: students_t_example2, Configuration: Debug Win32 ------
Compiling...
students_t_example2.cpp
Linking...
Autorun "i:\boost-06-05-03-1300\libs\math\test\Math_test\debug\students_t_example2.exe"
Example2 using Student's t function. ..\..\..\..\..\..\boost-sandbox\libs\math_functions\example\students_t_example2.cpp Sat Aug 12 16:55:59 2006 140050727
0 25.06
1 25.18
2 24.87
@@ -109,29 +113,9 @@ Mean = 25.2283
Standard deviation = 0.238279
Student's t = 2.34725, with 5 degrees of freedom.
Probability of positive bias is 0.967108.
Press any key to continue . . .
1>------ Build started: Project: students_t_example2, Configuration: Debug Win32 ------
1>Compiling...
1>students_t_example2.cpp
1>Linking...
1>Embedding manifest...
1>Autorun "i:\boost-06-05-03-1300\libs\math\test\Math_test\debug\students_t_example2.exe"
1>Example2 using Student's t function. ..\..\..\..\..\..\boost-sandbox\libs\math_functions\example\students_t_example2.cpp Sat Jun 17 16:39:11 2006 140050727
1> 0 25.06
1> 1 25.18
1> 2 24.87
1> 3 25.51
1> 4 25.34
1> 5 25.41
1>Mean = 25.2283
1>Standard deviation = 0.238279
1>Student's t = 2.34725, with 5 degrees of freedom.
1>Probability of positive bias is 0.967108.
1>Build Time 0:03
1>Build log was saved at "file://i:\boost-06-05-03-1300\libs\math\test\Math_test\students_t_example2\Debug\BuildLog.htm"
1>students_t_example2 - 0 error(s), 0 warning(s)
Build Time 0:03
Build log was saved at "file://i:\boost-06-05-03-1300\libs\math\test\Math_test\students_t_example2\Debug\BuildLog.htm"
students_t_example2 - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
*/

View File

@@ -6,7 +6,7 @@
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
// Example 3 of using Student's t
// Example 3 of using Student's t.
// A general guide to Student's t is at
// http://en.wikipedia.org/wiki/Student's_t-test
@@ -26,6 +26,11 @@
// but to his employer - the company insisted on the pseudonym
// so that it could turn a blind eye to the breach of its rules.
#ifdef _MSC_VER
# pragma warning(disable: 4702) // unreachable code
#endif
// 4996 4512
// The Students't distribution function is described at
// http://en.wikipedia.org/wiki/Student%27s_t_distribution
@@ -119,9 +124,12 @@ correlated samples: p 1-tailed 0.261635, 2-tailed 0.534327
Output is:
Example3 using Student's t function. ..\..\..\..\..\..\boost-sandbox\libs\math
_functions\example\students_t_example3.cpp Sat Jun 17 14:52:44 2006 140050727
------ Build started: Project: students_t_example3, Configuration: Debug Win32 ------
Compiling...
students_t_example3.cpp
Linking...
Atuorun "i:\boost-06-05-03-1300\libs\math\test\Math_test\debug\students_t_example3.exe"
Example3 using Student's t function. ..\..\..\..\..\..\boost-sandbox\libs\math_functions\example\students_t_example3.cpp Sat Aug 12 16:57:50 2006 140050727
Portion wet_oxidation Direct_extraction difference
0 71 76 -5
1 61 68 -7
@@ -131,7 +139,32 @@ Mean difference = -1.75
Standard deviation of differences = 4.99166
Student's t = -0.70117, if 3 degrees of freedom.
Probability of the means being different is 0.533692.
Press any key to continue . . .
Build Time 0:03
Build log was saved at "file://i:\boost-06-05-03-1300\libs\math\test\Math_test\students_t_example3\Debug\BuildLog.htm"
students_t_example3 - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
------ Build started: Project: students_t_example3, Configuration: Release Win32 ------
Compiling...
students_t_example3.cpp
Linking...
Generating code
Finished generating code
Autorun "i:\boost-06-05-03-1300\libs\math\test\math_test\release\students_t_example3.exe"
Example3 using Student's t function. ..\..\..\..\..\..\boost-sandbox\libs\math_functions\example\students_t_example3.cpp Sat Aug 12 17:01:52 2006 140050727
Portion wet_oxidation Direct_extraction difference
0 71 76 -5
1 61 68 -7
2 50 48 2
3 60 57 3
Mean difference = -1.75
Standard deviation of differences = 4.99166
Student's t = -0.70117, if 3 degrees of freedom.
Probability of the means being different is 0.533692.
Build Time 0:04
Build log was saved at "file://i:\boost-06-05-03-1300\libs\math\test\Math_test\students_t_example3\Release\BuildLog.htm"
students_t_example3 - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
*/