#! /usr/bin/env python # def r8vec_normal_01_sorted ( n, seed ): #*****************************************************************************80 # ## R8VEC_NORMAL_01_SORTED returns a sorted normal 01 random vector. # # Discussion: # # The Normal 01 distribution has mean 0 and standard deviation 1. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 28 March 2016 # # Author: # # John Burkardt # # Reference: # # Jon Bentley, James Saxe, # Generating sorted lists of random numbers, # ACM Transactions on Mathematical Software, # Volume 6, Number 3, September 1980, pages 359-364. # # Parameters: # # Input, integer N, the number of values to generate. # # Input, integer SEED, the integer "seed" used to generate # the output random number. SEED should not be 0. # # Output, real R8VEC(N), a real vector of normal 01 random values # in ascending order. # # Output, integer SEED, the updated seed. # import numpy as np from normal_01 import normal_01_cdf_inv from r8vec_uniform_01_sorted1 import r8vec_uniform_01_sorted1 cdfvec, seed = r8vec_uniform_01_sorted1 ( n, seed ) r8vec = np.zeros ( n ) for i in range ( 0, n ): r8vec[i] = normal_01_cdf_inv ( cdfvec[i] ) return r8vec, seed def r8vec_normal_01_sorted_test ( ): #*****************************************************************************80 # ## R8VEC_NORMAL_01_SORTED_TEST tests R8VEC_NORMAL_01_SORTED_TEST, # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 28 March 2016 # # Author: # # John Burkardt # import platform from r8vec_transpose_print import r8vec_transpose_print print ( '' ) print ( 'R8VEC_NORMAL_01_SORTED_TEST:' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' R8VEC_NORMAL_01_SORTED generates a vector of N normal 01' ) print ( ' random values in ascending sorted order.' ) print ( '' ) print ( ' Generate several examples:' ) print ( '' ) n = 5 seed = 123456789 for i in range ( 0, 10 ): r8vec, seed = r8vec_normal_01_sorted ( n, seed ) r8vec_transpose_print ( n, r8vec, ' R8VEC:' ) # # Terminate. # print ( '' ) print ( 'R8VEC_NORMAL_01_SORTED_TEST' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) r8vec_normal_01_sorted_test ( ) timestamp ( )