[Dart-dev] DART/branches Revision: 12688

dart at ucar.edu dart at ucar.edu
Wed Jun 27 16:11:54 MDT 2018


jla at ucar.edu
2018-06-27 16:11:54 -0600 (Wed, 27 Jun 2018)
237
Modified arguments to use shape and scale consistently for testing both gamma and inverse_gamma. Corrected
use of a rate to a scale as the input for test_inv_gamma consistent with change to the inverse gamma
generator in random_seq_mod.



Modified: DART/branches/gigg/developer_tests/random_seq/test_gamma.f90
===================================================================
--- DART/branches/gigg/developer_tests/random_seq/test_gamma.f90	2018-06-27 22:02:00 UTC (rev 12687)
+++ DART/branches/gigg/developer_tests/random_seq/test_gamma.f90	2018-06-27 22:11:54 UTC (rev 12688)
@@ -26,7 +26,7 @@
 
 type (random_seq_type) :: r
 integer :: i, j, n, f
-real(r8) :: r1, sum, sumsq, k, h
+real(r8) :: r1, sum, sumsq, shape, scale
 real(r8) :: mean, var, sd, compmean, compvar, compsd, compdiffm, compdiffsd
 logical  :: write_this_one
 character(len=50) :: formf = '(I12,2(F8.3),4(F12.5),2(F16.10),2(F12.5))'
@@ -36,9 +36,9 @@
 integer :: write_limit = 1000000   ! but only if rep count is not greater than this limit
 
 type t_inputs
- real(r8) :: t_kappa
- real(r8) :: t_theta
- integer  :: t_nreps
+   real(r8) :: t_shape
+   real(r8) :: t_scale
+   integer  :: t_nreps
 end type
 
 
@@ -80,7 +80,7 @@
 call register_module(source,revision,revdate)
 
 write(*, *) ''
-write(*, *) 'sample size     input k & t       computed mean, sd         actual mean, sd       diff mean         diff sd        % diff mean,  sd'
+write(*, *) 'sample size   shape & scale     computed mean, sd       actual mean, sd       diff mean         diff sd        % diff mean,  sd'
 write(*, *) ''
 
 do j=1, ntests
@@ -87,8 +87,8 @@
 
    call init_random_seq(r, 5)
 
-   k = t(j)%t_kappa
-   h = t(j)%t_theta
+   shape = t(j)%t_shape
+   scale = t(j)%t_scale
    n = t(j)%t_nreps
 
    ! save all values in a file for post-plotting?
@@ -95,20 +95,20 @@
    write_this_one = (write_me .and. n <= write_limit)
 
    if (write_this_one) then
-      write(temp, "(A,F8.3,A,F8.3,A,I10)"), "gamma_", k, "_", h, "_", n
+      write(temp, "(A,F8.3,A,F8.3,A,I10)") "gamma_", shape, "_", scale, "_", n
       call squeeze_out_blanks(temp, fname)
       f = open_file(fname)
    endif
 
    ! analytical values:
-   mean = k * h  
-   sd = sqrt(k * (h*h))
+   mean = shape * scale
+   sd = sqrt(shape * (scale*scale))
 
    sum = 0.0_r8
    sumsq = 0.0_r8
 
    do i = 1, n
-      r1 = random_gamma(r, k, h)
+      r1 = random_gamma(r, shape, scale)
 
       if (write_this_one) write(f,*) r1
 
@@ -126,7 +126,7 @@
    compdiffm  = compmean - mean
    compdiffsd = compsd - sd
 
-   write(*, formf) n, k, h, mean, sd, compmean, compsd, compdiffm, compdiffsd, &
+   write(*, formf) n, shape, scale, mean, sd, compmean, compsd, compdiffm, compdiffsd, &
                       abs(compdiffm/mean) * 100._r8, abs(compdiffsd/sd) * 100._r8
    
 

Modified: DART/branches/gigg/developer_tests/random_seq/test_inv_gamma.f90
===================================================================
--- DART/branches/gigg/developer_tests/random_seq/test_inv_gamma.f90	2018-06-27 22:02:00 UTC (rev 12687)
+++ DART/branches/gigg/developer_tests/random_seq/test_inv_gamma.f90	2018-06-27 22:11:54 UTC (rev 12688)
@@ -26,7 +26,7 @@
 
 type (random_seq_type) :: r
 integer :: i, j, n, f
-real(r8) :: r1, sum, sumsq, a, b, l
+real(r8) :: r1, sum, sumsq, shape, scale
 real(r8) :: mean, var, sd, compmean, compvar, compsd, compdiffm, compdiffsd
 logical  :: write_this_one
 character(len=256) :: fname, temp
@@ -36,8 +36,8 @@
 integer :: write_limit = 1000000   ! but only if rep count is not greater than this limit
 
 type t_inputs
- real(r8) :: t_alpha
- real(r8) :: t_beta
+ real(r8) :: t_shape


More information about the Dart-dev mailing list