def truncated_normal_ab_variance_test ( ): #*****************************************************************************80 # ## TRUNCATED_NORMAL_AB_VARIANCE_TEST tests TRUNCATED_NORMAL_AB_VARIANCE. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 08 March 2015 # # Author: # # John Burkardt # import numpy as np from truncated_normal_ab_sample import truncated_normal_ab_sample from r8vec_variance import r8vec_variance sample_num = 1000 seed = 123456789 a = 50.0 b = 150.0 mu = 100.0 sigma = 25.0 print '' print 'TRUNCATED_NORMAL_AB_VARIANCE_TEST' print ' TRUNCATED_NORMAL_AB_VARIANCE computes the variance' print ' of the Truncated Normal distribution.' print '' print ' The "parent" normal distribution has' print ' mean = %g' % ( mu ) print ' standard deviation = %g' % ( sigma ) print ' The parent distribution is truncated to' print ' the interval [%g,%g]' % ( a, b ) value = truncated_normal_ab_variance ( mu, sigma, a, b ) print '' print ' PDF variance = %g' % ( value ) x = np.zeros ( sample_num ) for i in range ( 0, sample_num ): x[i], seed = truncated_normal_ab_sample ( mu, sigma, a, b, seed ) value = r8vec_variance ( sample_num, x ) print '' print ' Sample size = %d' % ( sample_num ) print ' Sample variance = %g' % ( value ) print '' print 'TRUNCATED_NORMAL_AB_VARIANCE_TEST:' print ' Normal end of execution.' return
def truncated_normal_ab_variance_test(): #*****************************************************************************80 # ## TRUNCATED_NORMAL_AB_VARIANCE_TEST tests TRUNCATED_NORMAL_AB_VARIANCE. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 08 March 2015 # # Author: # # John Burkardt # import numpy as np from truncated_normal_ab_sample import truncated_normal_ab_sample from r8vec_variance import r8vec_variance sample_num = 1000 seed = 123456789 a = 50.0 b = 150.0 mu = 100.0 sigma = 25.0 print '' print 'TRUNCATED_NORMAL_AB_VARIANCE_TEST' print ' TRUNCATED_NORMAL_AB_VARIANCE computes the variance' print ' of the Truncated Normal distribution.' print '' print ' The "parent" normal distribution has' print ' mean = %g' % (mu) print ' standard deviation = %g' % (sigma) print ' The parent distribution is truncated to' print ' the interval [%g,%g]' % (a, b) value = truncated_normal_ab_variance(mu, sigma, a, b) print '' print ' PDF variance = %g' % (value) x = np.zeros(sample_num) for i in range(0, sample_num): x[i], seed = truncated_normal_ab_sample(mu, sigma, a, b, seed) value = r8vec_variance(sample_num, x) print '' print ' Sample size = %d' % (sample_num) print ' Sample variance = %g' % (value) print '' print 'TRUNCATED_NORMAL_AB_VARIANCE_TEST:' print ' Normal end of execution.' return
def normal_ms_variance_test(): #*****************************************************************************80 # ## NORMAL_MS_VARIANCE_TEST tests NORMAL_MS_VARIANCE. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 March 2015 # # Author: # # John Burkardt # import numpy as np import platform from normal_ms_sample import normal_ms_sample from r8vec_variance import r8vec_variance print('') print('NORMAL_MS_VARIANCE_TEST') print(' Python version: %s' % (platform.python_version())) print(' NORMAL_MS_VARIANCE computes the variance') print(' of the Normal MS distribution.') mu = 100.0 sigma = 15.0 value = normal_ms_variance(mu, sigma) print('') print(' PDF parameter MU = %g' % (mu)) print(' PDF parameter SIGMA = %g' % (sigma)) print(' PDF variance = %g' % (value)) nsample = 1000 seed = 123456789 x = np.zeros(nsample) for i in range(0, nsample): x[i], seed = normal_ms_sample(mu, sigma, seed) value = r8vec_variance(nsample, x) print('') print(' Sample size = %6d' % (nsample)) print(' Sample variance = %14g' % (value)) # # Terminate. # print('') print('NORMAL_MS_VARIANCE_TEST:') print(' Normal end of execution.') return
def normal_ms_variance_test ( ): #*****************************************************************************80 # ## NORMAL_MS_VARIANCE_TEST tests NORMAL_MS_VARIANCE. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 March 2015 # # Author: # # John Burkardt # import numpy as np from normal_ms_sample import normal_ms_sample from r8vec_variance import r8vec_variance print '' print 'NORMAL_MS_VARIANCE_TEST' print ' NORMAL_MS_VARIANCE computes the variance' print ' of the Normal MS distribution.' mu = 100.0 sigma = 15.0 value = normal_ms_variance ( mu, sigma ) print '' print ' PDF parameter MU = %g' % ( mu ) print ' PDF parameter SIGMA = %g' % ( sigma ) print ' PDF variance = %g' % ( value ) nsample = 1000 seed = 123456789 x = np.zeros ( nsample ) for i in range ( 0, nsample ): x[i], seed = normal_ms_sample ( mu, sigma, seed ) value = r8vec_variance ( nsample, x ) print '' print ' Sample size = %6d' % ( nsample ) print ' Sample variance = %14g' % ( value ) print '' print 'NORMAL_MS_VARIANCE_TEST:' print ' Normal end of execution.' return
def normal_01_variance_test(): #*****************************************************************************80 # ## NORMAL_01_VARIANCE_TEST tests NORMAL_01_VARIANCE. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 03 March 2015 # # Author: # # John Burkardt # import numpy as np from normal_01_sample import normal_01_sample from r8vec_variance import r8vec_variance print '' print 'NORMAL_01_VARIANCE_TEST' print ' NORMAL_01_VARIANCE computes the Normal 01 variance;' value = normal_01_variance() print '' print ' PDF variance = %14g' % (value) nsample = 1000 seed = 123456789 x = np.zeros(nsample) for i in range(0, nsample): x[i], seed = normal_01_sample(seed) value = r8vec_variance(nsample, x) print '' print ' Sample size = %6d' % (nsample) print ' Sample variance = %14g' % (value) print '' print 'NORMAL_01_VARIANCE_TEST:' print ' Normal end of execution.' return
def normal_01_variance_test ( ): #*****************************************************************************80 # ## NORMAL_01_VARIANCE_TEST tests NORMAL_01_VARIANCE. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 03 March 2015 # # Author: # # John Burkardt # import numpy as np from normal_01_sample import normal_01_sample from r8vec_variance import r8vec_variance print '' print 'NORMAL_01_VARIANCE_TEST' print ' NORMAL_01_VARIANCE computes the Normal 01 variance;' value = normal_01_variance ( ) print '' print ' PDF variance = %14g' % ( value ) nsample = 1000 seed = 123456789 x = np.zeros ( nsample ) for i in range ( 0, nsample ): x[i], seed = normal_01_sample ( seed ) value = r8vec_variance ( nsample, x ) print '' print ' Sample size = %6d' % ( nsample ) print ' Sample variance = %14g' % ( value ) print '' print 'NORMAL_01_VARIANCE_TEST:' print ' Normal end of execution.' return
def beta_sample_test(): #*****************************************************************************80 # ## BETA_SAMPLE_TEST tests BETA_MEAN, BETA_SAMPLE, BETA_VARIANCE. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 15 April 2009 # # Author: # # John Burkardt # import numpy as np import platform from r8vec_max import r8vec_max from r8vec_mean import r8vec_mean from r8vec_min import r8vec_min from r8vec_variance import r8vec_variance nsample = 1000 seed = 123456789 print('') print('BETA_SAMPLE_TEST') print(' Python version: %s' % (platform.python_version())) print(' BETA_MEAN computes the Beta mean') print(' BETA_SAMPLE samples the Beta distribution') print(' BETA_VARIANCE computes the Beta variance.') a = 2.0 b = 3.0 check = beta_check(a, b) if (not check): print('') print('BETA_SAMPLE_TEST - Fatal error!') print(' The parameters are not legal.') return mean = beta_mean(a, b) variance = beta_variance(a, b) print('') print(' PDF parameter A = %14g' % (a)) print(' PDF parameter B = %14g' % (b)) print(' PDF mean = %14g' % (mean)) print(' PDF variance = %14g' % (variance)) x = np.zeros(nsample) for i in range(0, nsample): x[i], seed = beta_sample(a, b, seed) mean = r8vec_mean(nsample, x) variance = r8vec_variance(nsample, x) xmax = r8vec_max(nsample, x) xmin = r8vec_min(nsample, x) print('') print(' Sample size = %6d' % (nsample)) print(' Sample mean = %14g' % (mean)) print(' Sample variance = %14g' % (variance)) print(' Sample maximum = %14g' % (xmax)) print(' Sample minimum = %14g' % (xmin)) # # Terminate. # print('') print('BETA_SAMPLE_TEST') print(' Normal end of execution.') return
def truncated_normal_a_variance_test(): #*****************************************************************************80 # ## TRUNCATED_NORMAL_A_VARIANCE_TEST tests TRUNCATED_NORMAL_A_VARIANCE. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 08 March 2015 # # Author: # # John Burkardt # import numpy as np import platform from truncated_normal_a_sample import truncated_normal_a_sample from r8vec_variance import r8vec_variance sample_num = 1000 seed = 123456789 a = 50.0 mu = 100.0 sigma = 25.0 print('') print('TRUNCATED_NORMAL_A_VARIANCE_TEST') print(' Python version: %s' % (platform.python_version())) print(' TRUNCATED_NORMAL_A_VARIANCE computes the variance') print(' of the Truncated Normal distribution.') print('') print(' The "parent" normal distribution has') print(' mean = %g' % (mu)) print(' standard deviation = %g' % (sigma)) print(' The parent distribution is truncated to') print(' the interval [%g,+oo)' % (a)) value = truncated_normal_a_variance(mu, sigma, a) print('') print(' PDF variance = %g' % (value)) x = np.zeros(sample_num) for i in range(0, sample_num): x[i], seed = truncated_normal_a_sample(mu, sigma, a, seed) value = r8vec_variance(sample_num, x) print('') print(' Sample size = %d' % (sample_num)) print(' Sample variance = %g' % (value)) # # Terminate. # print('') print('TRUNCATED_NORMAL_A_VARIANCE_TEST:') print(' Normal end of execution.') return