# include # include # include # include # include # include using namespace std; # include "normal.hpp" //****************************************************************************80 complex c8_normal_01 ( ) //****************************************************************************80 // // Purpose: // // c8_normal_01() returns a unit pseudonormal C8. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Output: // // complex C8_NORMAL_01, a unit pseudonormal value. // { const double r8_pi = 3.141592653589793; double v1; double v2; complex value; double x_c; double x_r; v1 = drand48 ( ); v2 = drand48 ( ); x_r = sqrt ( - 2.0 * log ( v1 ) ) * cos ( 2.0 * r8_pi * v2 ); x_c = sqrt ( - 2.0 * log ( v1 ) ) * sin ( 2.0 * r8_pi * v2 ); value = complex ( x_r, x_c ); return value; } /******************************************************************************/ complex *c8vec_normal_01_new ( int n ) /******************************************************************************/ /* Purpose: c8vec_normal_01_new() returns a unit pseudonormal C8VEC. Discussion: The standard normal probability distribution function (PDF) has mean 0 and standard deviation 1. Licensing: This code is distributed under the MIT license. Modified: 07 December 2023 Author: John Burkardt Input: int N, the number of values desired. Output: complex C8VEC_NORMAL_01_NEW[N], a sample of the standard normal PDF. */ { int i; const double r8_pi = 3.141592653589793; double v1; double v2; complex *x; x = new complex [n]; for ( i = 0; i < n; i++ ) { v1 = drand48 ( ); v2 = drand48 ( ); x[i] = sqrt ( - 2.0 * log ( v1 ) ) * complex ( cos ( 2.0 * r8_pi * v2 ), sin ( 2.0 * r8_pi * v2 ) ); } return x; } //****************************************************************************80 void c8vec_print ( int n, complex a[], string title ) //****************************************************************************80 // // Purpose: // // c8vec_print() prints a C8VEC. // // Discussion: // // A C8VEC is a vector of complex values. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 10 September 2009 // // Author: // // John Burkardt // // Input: // // int N, the number of components of the vector. // // complex A[N], the vector to be printed. // // string TITLE, a title. // { int i; cout << "\n"; cout << title << "\n"; cout << "\n"; for ( i = 0; i < n; i++ ) { cout << " " << setw(8) << i << ": " << real ( a[i] ) << " " << imag ( a[i] ) << "\n"; } return; } //****************************************************************************80 int i4_normal_ab ( double a, double b ) //****************************************************************************80 // // Purpose: // // i4_normal_ab() returns a scaled pseudonormal I4. // // Discussion: // // The normal probability distribution function (PDF) is sampled, // with mean A and standard deviation B. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Input: // // double A, the mean of the PDF. // // double B, the standard deviation of the PDF. // // Output: // // int I4_NORMAL_AB, a sample of the normal PDF. // { double r1; double r2; const double r8_pi = 3.141592653589793; int value; double x; r1 = drand48 ( ); r2 = drand48 ( ); x = sqrt ( - 2.0 * log ( r1 ) ) * cos ( 2.0 * r8_pi * r2 ); value = ( int ) round ( a + b * x ); return value; } //****************************************************************************80 double r8_normal_01 ( ) //****************************************************************************80 // // Purpose: // // r8_normal_01() returns a unit pseudonormal R8. // // Discussion: // // The standard normal probability distribution function (PDF) has // mean 0 and standard deviation 1. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Output: // // double R8_NORMAL_01, a normally distributed random value. // { double r1; double r2; const double r8_pi = 3.141592653589793; double x; r1 = drand48 ( ); r2 = drand48 ( ); x = sqrt ( - 2.0 * log ( r1 ) ) * cos ( 2.0 * r8_pi * r2 ); return x; } //****************************************************************************80 double r8_normal_ab ( double a, double b ) //****************************************************************************80 // // Purpose: // // r8_normal_ab() returns a scaled pseudonormal R8. // // Discussion: // // The normal probability distribution function (PDF) is sampled, // with mean A and standard deviation B. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Input: // // double A, the mean of the PDF. // // double B, the standard deviation of the PDF. // // Output: // // double R8_NORMAL_AB, a sample of the normal PDF. // { double value; value = a + b * r8_normal_01 ( ); return value; } //****************************************************************************80 double r8_uniform_01 ( ) //****************************************************************************80 // // Purpose: // // r8_uniform_01() returns a unit pseudorandom R8. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Reference: // // Paul Bratley, Bennett Fox, Linus Schrage, // A Guide to Simulation, // Springer Verlag, pages 201-202, 1983. // // Pierre L'Ecuyer, // Random Number Generation, // in Handbook of Simulation // edited by Jerry Banks, // Wiley Interscience, page 95, 1998. // // Bennett Fox, // Algorithm 647: // Implementation and Relative Efficiency of Quasirandom // Sequence Generators, // ACM Transactions on Mathematical Software, // Volume 12, Number 4, pages 362-376, 1986. // // Peter Lewis, Allen Goodman, James Miller, // A Pseudo-Random Number Generator for the System/360, // IBM Systems Journal, // Volume 8, pages 136-143, 1969. // // Output: // // double R8_UNIFORM_01, a new pseudorandom variate, strictly between // 0 and 1. // { double r; r = drand48 ( ); return r; } //****************************************************************************80 void r8mat_normal_01 ( int m, int n, double x[] ) //****************************************************************************80 // // Purpose: // // r8mat_normal_01() returns a unit pseudonormal R8MAT. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Reference: // // Paul Bratley, Bennett Fox, Linus Schrage, // A Guide to Simulation, // Springer Verlag, pages 201-202, 1983. // // Bennett Fox, // Algorithm 647: // Implementation and Relative Efficiency of Quasirandom // Sequence Generators, // ACM Transactions on Mathematical Software, // Volume 12, Number 4, pages 362-376, 1986. // // Peter Lewis, Allen Goodman, James Miller, // A Pseudo-Random Number Generator for the System/360, // IBM Systems Journal, // Volume 8, pages 136-143, 1969. // // Input: // // int M, N, the number of rows and columns in the array. // // Output: // // double X[M*N], the array of pseudonormal values. // { r8vec_normal_01 ( m * n, x ); return; } //****************************************************************************80 double *r8mat_normal_01_new ( int m, int n ) //****************************************************************************80 // // Purpose: // // r8mat_normal_01_new() returns a unit pseudonormal R8MAT. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Reference: // // Paul Bratley, Bennett Fox, Linus Schrage, // A Guide to Simulation, // Springer Verlag, pages 201-202, 1983. // // Bennett Fox, // Algorithm 647: // Implementation and Relative Efficiency of Quasirandom // Sequence Generators, // ACM Transactions on Mathematical Software, // Volume 12, Number 4, pages 362-376, 1986. // // Peter Lewis, Allen Goodman, James Miller, // A Pseudo-Random Number Generator for the System/360, // IBM Systems Journal, // Volume 8, pages 136-143, 1969. // // Input: // // int M, N, the number of rows and columns in the array. // // Output: // // double R8MAT_NORMAL_01_NEW[M*N], the array of pseudonormal values. // { double *r; r = r8vec_normal_01_new ( m * n ); return r; } //****************************************************************************80 void r8mat_normal_ab ( int m, int n, double a, double b, double x[] ) //****************************************************************************80 // // Purpose: // // r8mat_normal_ab() returns a scaled pseudonormal R8MAT. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Reference: // // Paul Bratley, Bennett Fox, Linus Schrage, // A Guide to Simulation, // Springer Verlag, pages 201-202, 1983. // // Bennett Fox, // Algorithm 647: // Implementation and Relative Efficiency of Quasirandom // Sequence Generators, // ACM Transactions on Mathematical Software, // Volume 12, Number 4, pages 362-376, 1986. // // Peter Lewis, Allen Goodman, James Miller, // A Pseudo-Random Number Generator for the System/360, // IBM Systems Journal, // Volume 8, pages 136-143, 1969. // // Input: // // int M, N, the number of rows and columns in the array. // // double A, B, the mean and standard deviation. // // Output: // // double X[M*N], the array of pseudonormal values. // { r8vec_normal_ab ( m * n, a, b, x ); return; } //****************************************************************************80 double *r8mat_normal_ab_new ( int m, int n, double a, double b ) //****************************************************************************80 // // Purpose: // // r8mat_normal_ab_new() returns a scaled pseudonormal R8MAT. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Reference: // // Paul Bratley, Bennett Fox, Linus Schrage, // A Guide to Simulation, // Springer Verlag, pages 201-202, 1983. // // Bennett Fox, // Algorithm 647: // Implementation and Relative Efficiency of Quasirandom // Sequence Generators, // ACM Transactions on Mathematical Software, // Volume 12, Number 4, pages 362-376, 1986. // // Peter Lewis, Allen Goodman, James Miller, // A Pseudo-Random Number Generator for the System/360, // IBM Systems Journal, // Volume 8, pages 136-143, 1969. // // Input: // // int M, N, the number of rows and columns in the array. // // double A, B, the mean and standard deviation. // // Output: // // double R8MAT_NORMAL_AB_NEW[M*N], the array of pseudonormal values. // { double *r; r = r8vec_normal_ab_new ( m * n, a, b ); return r; } //****************************************************************************80 void r8mat_print ( int m, int n, double a[], string title ) //****************************************************************************80 // // Purpose: // // r8mat_print() prints an R8MAT. // // Discussion: // // An R8MAT is a doubly dimensioned array of R8 values, stored as a vector // in column-major order. // // Entry A(I,J) is stored as A[I+J*M] // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Input: // // int M, the number of rows in A. // // int N, the number of columns in A. // // double A[M*N], the M by N matrix. // // string TITLE, a title. // { r8mat_print_some ( m, n, a, 1, 1, m, n, title ); return; } //****************************************************************************80 void r8mat_print_some ( int m, int n, double a[], int ilo, int jlo, int ihi, int jhi, string title ) //****************************************************************************80 // // Purpose: // // r8mat_print_some() prints some of an R8MAT. // // Discussion: // // An R8MAT is a doubly dimensioned array of R8 values, stored as a vector // in column-major order. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Input: // // int M, the number of rows of the matrix. // M must be positive. // // int N, the number of columns of the matrix. // N must be positive. // // double A[M*N], the matrix. // // int ILO, JLO, IHI, JHI, designate the first row and // column, and the last row and column to be printed. // // string TITLE, a title. // { # define INCX 5 int i; int i2hi; int i2lo; int j; int j2hi; int j2lo; cout << "\n"; cout << title << "\n"; if ( m <= 0 || n <= 0 ) { cout << "\n"; cout << " (None)\n"; return; } // // Print the columns of the matrix, in strips of 5. // for ( j2lo = jlo; j2lo <= jhi; j2lo = j2lo + INCX ) { j2hi = j2lo + INCX - 1; if ( n < j2hi ) { j2hi = n; } if ( jhi < j2hi ) { j2hi = jhi; } cout << "\n"; // // For each column J in the current range... // // Write the header. // cout << " Col: "; for ( j = j2lo; j <= j2hi; j++ ) { cout << setw(7) << j - 1 << " "; } cout << "\n"; cout << " Row\n"; cout << "\n"; // // Determine the range of the rows in this strip. // if ( 1 < ilo ) { i2lo = ilo; } else { i2lo = 1; } if ( ihi < m ) { i2hi = ihi; } else { i2hi = m; } for ( i = i2lo; i <= i2hi; i++ ) { // // Print out (up to) 5 entries in row I, that lie in the current strip. // cout << setw(5) << i - 1 << ": "; for ( j = j2lo; j <= j2hi; j++ ) { cout << setw(12) << a[i-1+(j-1)*m] << " "; } cout << "\n"; } } return; # undef INCX } //****************************************************************************80 void r8vec_normal_01 ( int n, double x[] ) //****************************************************************************80 // // Purpose: // // r8vec_normal_01() returns a unit pseudonormal R8VEC. // // Discussion: // // The standard normal probability distribution function (PDF) has // mean 0 and standard deviation 1. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Input: // // int N, the number of values desired. // // Output: // // double X[N], a sample of the standard normal PDF. // // Local: // // double R(N+1), is used to store some uniform random values. // Its dimension is N+1, but really it is only needed to be the // smallest even number greater than or equal to N. // // int X_LO, X_HI, records the range of entries of // X that we need to compute // { int i; int m; double *r; const double r8_pi = 3.141592653589793; int x_hi; int x_lo; // // Record the range of X we need to fill in. // x_lo = 1; x_hi = n; // // If we need just one new value, do that here to avoid null arrays. // if ( x_hi - x_lo + 1 == 1 ) { r = r8vec_uniform_01_new ( 2 ); x[x_hi-1] = sqrt ( - 2.0 * log ( r[0] ) ) * cos ( 2.0 * r8_pi * r[1] ); delete [] r; } // // If we require an even number of values, that's easy. // else if ( ( x_hi - x_lo + 1 ) % 2 == 0 ) { m = ( x_hi - x_lo + 1 ) / 2; r = r8vec_uniform_01_new ( 2 * m ); for ( i = 0; i <= 2 * m - 2; i = i + 2 ) { x[x_lo+i-1] = sqrt ( - 2.0 * log ( r[i] ) ) * cos ( 2.0 * r8_pi * r[i+1] ); x[x_lo+i ] = sqrt ( - 2.0 * log ( r[i] ) ) * sin ( 2.0 * r8_pi * r[i+1] ); } delete [] r; } // // If we require an odd number of values, we generate an even number, // and handle the last pair specially, storing one in X(N). // else { x_hi = x_hi - 1; m = ( x_hi - x_lo + 1 ) / 2 + 1; r = r8vec_uniform_01_new ( 2 * m ); for ( i = 0; i <= 2 * m - 4; i = i + 2 ) { x[x_lo+i-1] = sqrt ( - 2.0 * log ( r[i] ) ) * cos ( 2.0 * r8_pi * r[i+1] ); x[x_lo+i ] = sqrt ( - 2.0 * log ( r[i] ) ) * sin ( 2.0 * r8_pi * r[i+1] ); } i = 2*m - 2; x[x_lo+i-1] = sqrt ( - 2.0 * log ( r[i] ) ) * cos ( 2.0 * r8_pi * r[i+1] ); delete [] r; } return; } //****************************************************************************80 double *r8vec_normal_01_new ( int n ) //****************************************************************************80 // // Purpose: // // r8vec_normal_01_new() returns a unit pseudonormal R8VEC. // // Discussion: // // The standard normal probability distribution function (PDF) has // mean 0 and standard deviation 1. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Input: // // int N, the number of values desired. // // Output: // // double R8VEC_NORMAL_01_NEW[N], a sample of the standard normal PDF. // // Local: // // double R(N+1), is used to store some uniform random values. // Its dimension is N+1, but really it is only needed to be the // smallest even number greater than or equal to N. // // int X_LO, X_HI, records the range of entries of // X that we need to compute. // { int i; int m; double *r; const double r8_pi = 3.141592653589793; double *x; int x_hi; int x_lo; x = new double[n]; // // Record the range of X we need to fill in. // x_lo = 1; x_hi = n; // // If we need just one new value, do that here to avoid null arrays. // if ( x_hi - x_lo + 1 == 1 ) { r = r8vec_uniform_01_new ( 2 ); x[x_hi-1] = sqrt ( - 2.0 * log ( r[0] ) ) * cos ( 2.0 * r8_pi * r[1] ); delete [] r; } // // If we require an even number of values, that's easy. // else if ( ( x_hi - x_lo + 1 ) % 2 == 0 ) { m = ( x_hi - x_lo + 1 ) / 2; r = r8vec_uniform_01_new ( 2 * m ); for ( i = 0; i <= 2 * m - 2; i = i + 2 ) { x[x_lo+i-1] = sqrt ( - 2.0 * log ( r[i] ) ) * cos ( 2.0 * r8_pi * r[i+1] ); x[x_lo+i ] = sqrt ( - 2.0 * log ( r[i] ) ) * sin ( 2.0 * r8_pi * r[i+1] ); } delete [] r; } // // If we require an odd number of values, we generate an even number, // and handle the last pair specially, storing one in X(N), and // saving the other for later. // else { x_hi = x_hi - 1; m = ( x_hi - x_lo + 1 ) / 2 + 1; r = r8vec_uniform_01_new ( 2 * m ); for ( i = 0; i <= 2 * m - 4; i = i + 2 ) { x[x_lo+i-1] = sqrt ( - 2.0 * log ( r[i] ) ) * cos ( 2.0 * r8_pi * r[i+1] ); x[x_lo+i ] = sqrt ( - 2.0 * log ( r[i] ) ) * sin ( 2.0 * r8_pi * r[i+1] ); } i = 2*m - 2; x[x_lo+i-1] = sqrt ( - 2.0 * log ( r[i] ) ) * cos ( 2.0 * r8_pi * r[i+1] ); delete [] r; } return x; } //****************************************************************************80 void r8vec_normal_ab ( int n, double b, double c, double x[] ) //****************************************************************************80 // // Purpose: // // r8vec_normal_ab() returns a scaled pseudonormal R8VEC. // // Discussion: // // The scaled normal probability distribution function (PDF) has // mean A and standard deviation B. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Input: // // int N, the number of values desired. // // double B, C, the mean and standard deviation. // // Output: // // double X[N], a sample of the standard normal PDF. // // Local: // // double R(N+1), is used to store some uniform random values. // Its dimension is N+1, but really it is only needed to be the // smallest even number greater than or equal to N. // // int X_LO, X_HI, records the range of entries of // X that we need to compute. // { int i; int m; double *r; const double r8_pi = 3.141592653589793; int x_hi; int x_lo; x = new double[n]; // // Record the range of X we need to fill in. // x_lo = 1; x_hi = n; // // If we need just one new value, do that here to avoid null arrays. // if ( x_hi - x_lo + 1 == 1 ) { r = r8vec_uniform_01_new ( 2 ); x[x_hi-1] = sqrt ( - 2.0 * log ( r[0] ) ) * cos ( 2.0 * r8_pi * r[1] ); delete [] r; } // // If we require an even number of values, that's easy. // else if ( ( x_hi - x_lo + 1 ) % 2 == 0 ) { m = ( x_hi - x_lo + 1 ) / 2; r = r8vec_uniform_01_new ( 2 * m ); for ( i = 0; i <= 2 * m - 2; i = i + 2 ) { x[x_lo+i-1] = sqrt ( - 2.0 * log ( r[i] ) ) * cos ( 2.0 * r8_pi * r[i+1] ); x[x_lo+i ] = sqrt ( - 2.0 * log ( r[i] ) ) * sin ( 2.0 * r8_pi * r[i+1] ); } delete [] r; } // // If we require an odd number of values, we generate an even number, // and handle the last pair specially, storing one in X(N). // else { x_hi = x_hi - 1; m = ( x_hi - x_lo + 1 ) / 2 + 1; r = r8vec_uniform_01_new ( 2 * m ); for ( i = 0; i <= 2 * m - 4; i = i + 2 ) { x[x_lo+i-1] = sqrt ( - 2.0 * log ( r[i] ) ) * cos ( 2.0 * r8_pi * r[i+1] ); x[x_lo+i ] = sqrt ( - 2.0 * log ( r[i] ) ) * sin ( 2.0 * r8_pi * r[i+1] ); } i = 2*m - 2; x[x_lo+i-1] = sqrt ( - 2.0 * log ( r[i] ) ) * cos ( 2.0 * r8_pi * r[i+1] ); delete [] r; } for ( i = 0; i < n; i++ ) { x[i] = b + c * x[i]; } return; } //****************************************************************************80 double *r8vec_normal_ab_new ( int n, double b, double c ) //****************************************************************************80 // // Purpose: // // r8vec_normal_ab_new() returns a scaled pseudonormal R8VEC. // // Discussion: // // The scaled normal probability distribution function (PDF) has // mean A and standard deviation B. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Input: // // int N, the number of values desired. // // double B, C, the mean and standard deviation. // // Output: // // double R8VEC_NORMAL_AB_NEW[N], a sample of the standard normal PDF. // // Local: // // double R(N+1), is used to store some uniform random values. // Its dimension is N+1, but really it is only needed to be the // smallest even number greater than or equal to N. // // int X_LO, X_HI, records the range of entries of // X that we need to compute. // { int i; int m; double *r; const double r8_pi = 3.141592653589793; double *x; int x_hi; int x_lo; x = new double[n]; // // Record the range of X we need to fill in. // x_lo = 1; x_hi = n; // // If we need just one new value, do that here to avoid null arrays. // if ( x_hi - x_lo + 1 == 1 ) { r = r8vec_uniform_01_new ( 2 ); x[x_hi-1] = sqrt ( - 2.0 * log ( r[0] ) ) * cos ( 2.0 * r8_pi * r[1] ); delete [] r; } // // If we require an even number of values, that's easy. // else if ( ( x_hi - x_lo + 1 ) % 2 == 0 ) { m = ( x_hi - x_lo + 1 ) / 2; r = r8vec_uniform_01_new ( 2 * m ); for ( i = 0; i <= 2 * m - 2; i = i + 2 ) { x[x_lo+i-1] = sqrt ( - 2.0 * log ( r[i] ) ) * cos ( 2.0 * r8_pi * r[i+1] ); x[x_lo+i ] = sqrt ( - 2.0 * log ( r[i] ) ) * sin ( 2.0 * r8_pi * r[i+1] ); } delete [] r; } // // If we require an odd number of values, we generate an even number, // and handle the last pair specially. // else { x_hi = x_hi - 1; m = ( x_hi - x_lo + 1 ) / 2 + 1; r = r8vec_uniform_01_new ( 2 * m ); for ( i = 0; i <= 2 * m - 4; i = i + 2 ) { x[x_lo+i-1] = sqrt ( - 2.0 * log ( r[i] ) ) * cos ( 2.0 * r8_pi * r[i+1] ); x[x_lo+i ] = sqrt ( - 2.0 * log ( r[i] ) ) * sin ( 2.0 * r8_pi * r[i+1] ); } i = 2*m - 2; x[x_lo+i-1] = sqrt ( - 2.0 * log ( r[i] ) ) * cos ( 2.0 * r8_pi * r[i+1] ); delete [] r; } for ( i = 0; i < n; i++ ) { x[i] = b + c * x[i]; } return x; } //****************************************************************************80 void r8vec_print ( int n, double a[], string title ) //****************************************************************************80 // // Purpose: // // r8vec_print() prints an R8VEC. // // Discussion: // // An R8VEC is a vector of R8's. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Input: // // int N, the number of components of the vector. // // double A[N], the vector to be printed. // // string TITLE, a title. // { int i; cout << "\n"; cout << title << "\n"; cout << "\n"; for ( i = 0; i < n; i++ ) { cout << " " << setw(8) << i << ": " << setw(14) << a[i] << "\n"; } return; } //****************************************************************************80 double *r8vec_uniform_01_new ( int n ) //****************************************************************************80 // // Purpose: // // r8vec_uniform_01_new() returns a new unit pseudorandom R8VEC. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 13 September 2022 // // Author: // // John Burkardt // // Reference: // // Paul Bratley, Bennett Fox, Linus Schrage, // A Guide to Simulation, // Second Edition, // Springer, 1987, // ISBN: 0387964673, // LC: QA76.9.C65.B73. // // Bennett Fox, // Algorithm 647: // Implementation and Relative Efficiency of Quasirandom // Sequence Generators, // ACM Transactions on Mathematical Software, // Volume 12, Number 4, December 1986, pages 362-376. // // Pierre L'Ecuyer, // Random Number Generation, // in Handbook of Simulation, // edited by Jerry Banks, // Wiley, 1998, // ISBN: 0471134031, // LC: T57.62.H37. // // Peter Lewis, Allen Goodman, James Miller, // A Pseudo-Random Number Generator for the System/360, // IBM Systems Journal, // Volume 8, Number 2, 1969, pages 136-143. // // Input: // // int N, the number of entries in the vector. // // Output: // // double R8VEC_UNIFORM_01_NEW[N], the vector of pseudorandom values. // { int i; double *r; r = new double[n]; for ( i = 0; i < n; i++ ) { r[i] = drand48 ( ); } return r; }