# include # include # include # include # include using namespace std; # include "asa241.hpp" int main ( ); void test01 ( ); void test02 ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // asa241_test() tests asa241(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 17 January 2008 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "asa241_test():\n"; cout << " C++ version\n"; cout << " Test asa241().\n"; test01 ( ); test02 ( ); cout << "\n"; cout << "asa241_test():\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void test01 ( ) //****************************************************************************80 // // Purpose: // // test01() tests r4_normal_01_cdf_inverse(), normal_01_cdf_values(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 14 February 2009 // // Author: // // John Burkardt // { double fx; float fx2; int n_data; double x; float x2; cout << "\n"; cout << "test01():\n"; cout << " Let FX = NormalCDF ( X ).\n"; cout << "\n"; cout << " normal_01_cdf_values() returns some values of ( X, FX ).\n"; cout << "\n"; cout << " r4_normal_01_cdf_inverse() takes the value of FX, and computes an\n"; cout << " estimate X2, of the corresponding input argument,\n"; cout << " accurate to about 7 decimal places.\n"; cout << "\n"; cout << " FX X X2 DIFF\n"; cout << "\n"; n_data = 0; for ( ; ; ) { normal_01_cdf_values ( &n_data, &x, &fx ); if ( n_data == 0 ) { break; } fx2 = ( float ) ( fx ); x2 = r4_normal_01_cdf_inverse ( fx2 ); cout << " " << setprecision(16) << setw(24) << fx << " " << setprecision(16) << setw(24) << x << " " << setprecision(16) << setw(24) << x2 << " " << setprecision(16) << fabs ( x - x2 ) << "\n"; } return; } //****************************************************************************80 void test02 ( ) //****************************************************************************80 // // Purpose: // // test02() tests r8_normal_01_cdf_inverse(), normal_01_cdf_values(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 14 February 2009 // // Author: // // John Burkardt // { double fx; int n_data; double x; double x2; cout << "\n"; cout << "test02():\n"; cout << " Let FX = NormalCDF ( X ).\n"; cout << "\n"; cout << " normal_01_cdf_values() returns some values of ( X, FX ).\n"; cout << "\n"; cout << " r8_normal_01_cdf_inverse() takes the value of FX, and computes an\n"; cout << " estimate X2, of the corresponding input argument,\n"; cout << " accurate to about 16 decimal places.\n"; cout << "\n"; cout << " FX X X2 DIFF\n"; cout << "\n"; n_data = 0; for ( ; ; ) { normal_01_cdf_values ( &n_data, &x, &fx ); if ( n_data == 0 ) { break; } x2 = r8_normal_01_cdf_inverse ( fx ); cout << " " << setprecision(16) << setw(24) << fx << " " << setprecision(16) << setw(24) << x << " " << setprecision(16) << setw(24) << x2 << " " << setprecision(16) << fabs ( x - x2 ) << "\n"; } return; } //****************************************************************************80 void timestamp ( ) //****************************************************************************80 // // Purpose: // // timestamp() prints the current YMDHMS date as a time stamp. // // Example: // // May 31 2001 09:45:54 AM // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 24 September 2003 // // Author: // // John Burkardt // { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct tm *tm; time_t now; now = time ( NULL ); tm = localtime ( &now ); strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); cout << time_buffer << "\n"; return; # undef TIME_SIZE }