avatar
l*y
1
我想生成随机数,在fortran的code里用了random_number()这个函数,可是运行后,发现每
次生成的随机数都是一样的. 请问这是什么回事啊?应该如何改进啊?
谢谢指点
avatar
g*e
2
reset random seed

【在 l****y 的大作中提到】
: 我想生成随机数,在fortran的code里用了random_number()这个函数,可是运行后,发现每
: 次生成的随机数都是一样的. 请问这是什么回事啊?应该如何改进啊?
: 谢谢指点

avatar
l*y
3
可以说详细点吗? 怎么reset?
谢谢

现每

【在 g********e 的大作中提到】
: reset random seed
avatar
g*e
4
CALL RANDOM_SEED ( ) ! Processor reinitializes seed
! value
【 在 leephy (leephy) 的大作中提到: 】
avatar
x*r
5
They are pseudorandom numbers.
Not real random numbers

现每

【在 g********e 的大作中提到】
: reset random seed
avatar
l*y
6
我加了这个函数在程序中,可是每次运行时还是没有改变random number......
是不是要在这个函数中加入什么参数啊? 请指点

【在 g********e 的大作中提到】
: CALL RANDOM_SEED ( ) ! Processor reinitializes seed
: ! value
: 【 在 leephy (leephy) 的大作中提到: 】

avatar
g*e
7
看你什么要求了,要求不高么就凑合着用用.呵呵..

【在 x******r 的大作中提到】
: They are pseudorandom numbers.
: Not real random numbers
:
: 现每

avatar
g*e
8
try this test code, u will see...
program test
implicit none
real::a
integer::i
call random_seed()
do i=1,10
call random_number(a)
print*,a
end do
end program

【在 l****y 的大作中提到】
: 我加了这个函数在程序中,可是每次运行时还是没有改变random number......
: 是不是要在这个函数中加入什么参数啊? 请指点

avatar
y*t
9
Try ran(idum) of numerical recipe(f90). It is good.

【在 g********e 的大作中提到】
: try this test code, u will see...
: program test
: implicit none
: real::a
: integer::i
: call random_seed()
: do i=1,10
: call random_number(a)
: print*,a
: end do

avatar
a*s
10
随机数要看种子的,种子一样的话,当然出来的随机数就一样了,换种子就行了。
比如那当前机器时间做种子,etc.

【在 l****y 的大作中提到】
: 我加了这个函数在程序中,可是每次运行时还是没有改变random number......
: 是不是要在这个函数中加入什么参数啊? 请指点

avatar
x*r
11
right.
Using current time as the seed is a common way to do it.

【在 a******s 的大作中提到】
: 随机数要看种子的,种子一样的话,当然出来的随机数就一样了,换种子就行了。
: 比如那当前机器时间做种子,etc.

avatar
t*o
12
different machine has different random function
try man ...
I think mostly there should be a parameter to set the seed

【在 l****y 的大作中提到】
: 我加了这个函数在程序中,可是每次运行时还是没有改变random number......
: 是不是要在这个函数中加入什么参数啊? 请指点

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。