Envoyé par
niceowen
Bonsoir, je ne suis pas du tout un spécialiste de l'informatique, j'essaie de générer des nombres aléatoires dans ]0,1[ en utilisant la méthode de Box-Muller mais j'ai un problème pour l'implémentation. Voici mon code:
program gaussienne
implicit none
real :: pi
real,dimension( : ),allocatable :: tableau
integer, dimension(8) :: graine
real, dimension(50) ::tab1,tab2
pi = 2*asin (1.0000)
call date_and_time (values=graine)
call random_seed(put=graine(8:1:-1))
call random_number(tab1)
call date_and_time (values=graine)
call random_seed(put=graine(8:1:-1))
call random_number(tab2)
tab1 = sqrt((-2)*log(tab1))*cos(2*pi*tab2)
print *,tab1
end program
Partager