testing random sampling
This commit is contained in:
parent
f40d731fe1
commit
f833d348e0
2
PRIVATE
2
PRIVATE
|
@ -1 +1 @@
|
|||
Subproject commit 2ad27552c43316735b6ef425737fe3c8a5231598
|
||||
Subproject commit 96c32ba4237a51eaad92cd139e1a716ee5b32493
|
20
src/math.f90
20
src/math.f90
|
@ -1431,6 +1431,26 @@ subroutine selfTest
|
|||
if (dNeq0(math_LeviCivita(ijk(1),ijk(2),ijk(3)))) &
|
||||
error stop 'math_LeviCivita'
|
||||
|
||||
normal_distribution: block
|
||||
real(pReal), dimension(500000) :: r
|
||||
real(pReal) :: mu, sigma
|
||||
|
||||
call random_number(mu)
|
||||
call random_number(sigma)
|
||||
|
||||
sigma = 1.0_pReal + sigma*5.0_pReal
|
||||
mu = (mu-0.5_pReal)*10_pReal
|
||||
|
||||
call math_normal(r,mu,sigma)
|
||||
|
||||
if (abs(mu -sum(r)/real(size(r),pReal))>5.0e-2_pReal) &
|
||||
error stop 'math_normal(mu)'
|
||||
|
||||
mu = sum(r)/real(size(r),pReal)
|
||||
if (abs(sigma**2 -1.0_pReal/real(size(r)-1,pReal) * sum((r-mu)**2))/sigma > 5.0e-2_pReal) &
|
||||
error stop 'math_normal(sigma)'
|
||||
end block normal_distribution
|
||||
|
||||
end subroutine selfTest
|
||||
|
||||
end module math
|
||||
|
|
Loading…
Reference in New Issue