小编Gvx*_*ørt的帖子

MT19937 不会通过将种子值保持为常数来重现相同的伪随机序列

我正在 Fortran 90/95 的 Monte Carlo 模拟中编写一个检查点函数,我使用的编译器是 ifort 18.0.2,在详细说明我正在使用的伪随机生成器的版本之前:

A C-program for MT19937, with initialization, improved 2002/1/26.
Coded by Takuji Nishimura and Makoto Matsumoto.

Code converted to Fortran 95 by Josi Rui Faustino de Sousa
Date: 2002-02-01
Run Code Online (Sandbox Code Playgroud)

源代码见mt19937

我的蒙特卡罗模拟代码的一般结构如下:

program montecarlo
 call read_iseed(...)
 call mc_subroutine(...)
end 
Run Code Online (Sandbox Code Playgroud)

read_iseed

subroutine read_iseed(...)
  use mt19937

    if (Restart == 'n') then

    call system('od -vAn -N4 -td4 < /dev/urandom > '//trim(IN_ISEED)
    open(unit=7,file=trim(IN_ISEED),status='old')
    read(7,*) i
    close(7)

    !This is only used to initialise the PRNG …
Run Code Online (Sandbox Code Playgroud)

random fortran mersenne-twister

5
推荐指数
1
解决办法
254
查看次数

标签 统计

fortran ×1

mersenne-twister ×1

random ×1