📄 randomlib.h
字号:
/*
This Random Number Generator is based on the algorithm in a FORTRAN
version published by George Marsaglia and Arif Zaman, Florida State
University; ref.: see original comments below.
At the fhw (Fachhochschule Wiesbaden, W.Germany), Dept. of Computer
Science, we have written sources in further languages (C, Modula-2
Turbo-Pascal(3.0, 5.0), Basic and Ada) to get exactly the same test
results compared with the original FORTRAN version.
April 1989
Karl-L. Noell <NOELL@DWIFH1.BITNET>
and Helmut Weber <WEBER@DWIFH1.BITNET>
This random number generator originally appeared in "Toward a Universal
Random Number Generator" by George Marsaglia and Arif Zaman.
Florida State University Report: FSU-SCRI-87-50 (1987)
It was later modified by F. James and published in "A Review of Pseudo-
random Number Generators"
THIS IS THE BEST KNOWN RANDOM NUMBER GENERATOR AVAILABLE.
(However, a newly discovered technique can yield
a period of 10^600. But that is still in the development stage.)
It passes ALL of the tests for random number generators and has a period
of 2^144, is completely portable (gives bit identical results on all
machines with at least 24-bit mantissas in the floating point
representation).
The algorithm is a combination of a Fibonacci sequence (with lags of 97
and 33, and operation "subtraction plus one, modulo one") and an
"arithmetic sequence" (using subtraction).
Use IJ = 1802 & KL = 9373 to test the random number generator. The
subroutine RANMAR should be used to generate 20000 random numbers.
Then display the next six random numbers generated multiplied by 4096*4096
If the random number generator is working properly, the random numbers
should be:
6533892.0 14220222.0 7275067.0
6172232.0 8354498.0 10633180.0
*/
#ifndef _RANDOMLIB_H_
#define _RANDOMLIB_H_
#ifdef __cplusplus
extern "C" {
#endif
void RandomInitialise(int,int);
double RandomUniform(void);
double RandomGaussian(double,double);
int RandomInt(int,int);
double RandomDouble(double,double);
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -