JPH04199225A - Arithmetic random number generating method in computer - Google Patents

Arithmetic random number generating method in computer

Info

Publication number
JPH04199225A
JPH04199225A JP2317799A JP31779990A JPH04199225A JP H04199225 A JPH04199225 A JP H04199225A JP 2317799 A JP2317799 A JP 2317799A JP 31779990 A JP31779990 A JP 31779990A JP H04199225 A JPH04199225 A JP H04199225A
Authority
JP
Japan
Prior art keywords
random numbers
computer
random number
vector
processing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2317799A
Other languages
Japanese (ja)
Inventor
Ikuo Yoshihara
郁夫 吉原
Akira Muramatsu
晃 村松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2317799A priority Critical patent/JPH04199225A/en
Publication of JPH04199225A publication Critical patent/JPH04199225A/en
Pending legal-status Critical Current

Links

Landscapes

  • Complex Calculations (AREA)

Abstract

PURPOSE:To increase the speed in this method by generating plural pieces of random numbers in a batch and simultaneously performing vector processing for the generation of the plural random numbers. CONSTITUTION:A vector computer is constituted of a scalar processor 400, vector processor 500, input-output processor 600, and main storage device 700 and an extended storage device 800 may be added to the computer. In addition, a function which can generate numerous uniform random numbers by a product combining method is provided and N pieces of powers of multipliers or already generated random numbers are held so that vector processing can be performed by independently performing random number generating calculation on the N pieces of random numbers. Therefore, the processing speed of the vector computer is increased.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明は、計算機における算術乱数 (arithmetj、c random numbe
r)の生成方法に係わり、特に、ベクトル計算機やアレ
イ計算機を用いるのに好適な処理方法に関する。
DETAILED DESCRIPTION OF THE INVENTION [Industrial Field of Application] The present invention relates to the use of arithmetic random numbers in computers.
r), and particularly relates to a processing method suitable for using a vector computer or an array computer.

〔従来の技術〕[Conventional technology]

算術乱数(擬似乱数)は、与えられた初期値に、ある決
った数値演算を施し、順次生成される。算術乱数として
は、種々の分布に従うものが必要とされるが、特に、一
様乱数が基本的で、重要である。なぜなら、一様乱数が
得られれば、他の分布に従う乱数は、一様乱数をもとに
生成できるからである。乱数を算出するための数式は、
例えば、津田孝夫著「モンテカルロ法とシミュレーショ
ン」。
Arithmetic random numbers (pseudo-random numbers) are sequentially generated by performing certain numerical operations on given initial values. Arithmetic random numbers that follow various distributions are required, but uniform random numbers are particularly fundamental and important. This is because if a uniform random number is obtained, random numbers following other distributions can be generated based on the uniform random number. The formula for calculating random numbers is
For example, "Monte Carlo Method and Simulation" by Takao Tsuda.

培風館(昭和44)、第7〜37頁に詳しく示されてい
る。
Baifukan (1968), pages 7 to 37 provide detailed information.

一様乱数の代表的生成法である、乗積合同法について説
明する。初期値M04乗数a、 (M、、、 aは正整
数)を与えたとき、 Mr+=aMn−0(mod L )        
−(1)ただし、n=1..2,3゜ なる整数列M。2M2.・・・を作れば、区間(0,L
)に一様分布する算術乱数が得られる。これ゛が摩積合
同法である。
The product congruence method, which is a typical method for generating uniform random numbers, will be explained. When the initial value M04 multiplier a, (M, , a is a positive integer) is given, Mr+=aMn-0 (mod L)
-(1) However, n=1. .. An integer sequence M of 2,3 degrees. 2M2. If you create ..., the interval (0, L
) is obtained, which is a uniformly distributed arithmetic random number. This is the multiplication joint method.

整数型変数をΩ+1ビツト(先頭の1ビツトが符号を表
わし、領域は[−2’、2’−1]である)で表わし、
整数演算時の桁あふれを許容する(割込みを生じない)
計算機を用いる場合、n=21とし、(1)式右辺の乗
算a”Mn−1を実行し最上位の符号ビットを無視する
(即ち、0とみなす)と、下位Qビットが表わす数は、
M、をLで割った余りになる。この方法は、法をとる処
理(一般には検算、切り捨て演算2乗算、減算が必要)
が不要なため広く用いられている。
An integer type variable is represented by Ω+1 bits (the first bit represents the sign, and the area is [-2', 2'-1]),
Allow overflow during integer operations (does not cause interrupts)
When using a calculator, if n = 21 and the multiplication a''Mn-1 on the right side of equation (1) is performed and the most significant sign bit is ignored (i.e., treated as 0), the number represented by the lower Q bits is:
This is the remainder when M is divided by L. This method requires processing to take the modulus (generally requires verification, rounding down, multiplication by 2, and subtraction)
It is widely used because it does not require

一様乱数は、区間(0,1)に分布するよう規格して用
いることが多いが、このためには、Mn(modL)を
して割っておけばよい。
Uniform random numbers are often used after being standardized so that they are distributed in the interval (0, 1), but for this purpose, they can be divided by Mn (mod L).

Mnの数値表現上の範囲は[0,L−1]であるが1M
0及びaとして、2でない素数を選べば。
The numerical expression range of Mn is [0, L-1], but 1M
If we choose prime numbers other than 2 as 0 and a.

Mn=Oとなることはなく、O<M、< L  となる
ため、O<R,<1  となる。
Since Mn=O does not hold and O<M and <L, O<R and <1.

乱数を用いる数値シミュレーションは、一般にモンテカ
ルロ法またはモンテカルロシミュレーションと言われる
が、この方法は多くの自然現象。
Numerical simulation using random numbers is generally referred to as the Monte Carlo method or Monte Carlo simulation, and this method is applicable to many natural phenomena.

社会現象、の解明に使われている。さらに現象の解明(
これは状態方程式を解くことに相当)ができることから
、機器の制御装置の一部としても使うことができる。モ
ンテカル法の応用は極めて広く、例えば。
It is used to elucidate social phenomena. Further elucidation of the phenomenon (
This is equivalent to solving an equation of state), so it can also be used as part of a device control device. The application of the Monte Cal method is extremely wide, for example.

・雑音現象 ・粒子の衝突過程 ・待ち現象 ・交通流の解析 ・電子回路の解析 ・プラズマの熱伝導 ・ノイズによる巨視的不安定性 ・格子振動 がある。これらは、上記、津田氏の著書の第8〜第9章
に詳細に記載されている。
・Noise phenomenon, particle collision process, waiting phenomenon, analysis of traffic flow, analysis of electronic circuits, thermal conduction of plasma, macroscopic instability due to noise, and lattice vibration. These are described in detail in Chapters 8 and 9 of Mr. Tsuda's book mentioned above.

〔発明が解決しようとする課題〕[Problem to be solved by the invention]

第2図は、FORTRAN言語で書いた、一様乱数を用
いるプログラムの一例である。同図において、右端の数
字はカード番号であり、100〜160は一様乱数を生
成するサブプログラムRANDOMを呼出しているプロ
グラムの一部であり、200〜250は、サブプログラ
ムRANDOMの内容を示す。
FIG. 2 is an example of a program using uniform random numbers written in the FORTRAN language. In the figure, the numbers at the right end are card numbers, 100 to 160 are part of the program that calls the subprogram RANDOM that generates uniform random numbers, and 200 to 250 indicate the contents of the subprogram RANDOM.

ここで、K、Mはそれぞれ(1)式のM、 、 aに対
応し、そ九ぞれ97,13としている。文240は、先
頭ビットが1のとき、Rが負数となるので、正数に直す
処理である。なお1文220でKは負になることもあり
、符号ビット以下Qビットを取るのと絶対値を取るのと
では一般に値は異なるが、一般にはこの例のような処理
で済ますことが多い。
Here, K and M correspond to M, , and a in equation (1), respectively, and are 97 and 13, respectively. Statement 240 is a process for converting R to a positive number since when the first bit is 1, R becomes a negative number. Note that in one sentence 220, K may be negative, and the values are generally different depending on whether the Q bits below the sign bit are taken or the absolute value, but in general, processing as shown in this example is often sufficient.

このように、乱数生成部を関数サブプログラム又はサブ
ルーチンサブプログラムとして実装する方法は、ライブ
ラリとして提供しやすく便利であるため広く行なわれて
いる。しかし、この使い方は、乱数を1個作るたびに外
部手続きの呼び出しが必要であり、負荷が大きい(従っ
て時間がかかる)という欠点がある。
As described above, the method of implementing the random number generation unit as a function subprogram or a subroutine subprogram is widely used because it is convenient and easy to provide as a library. However, this method has the disadvantage of requiring a call to an external procedure each time a random number is generated, resulting in a heavy load (and therefore time).

更に、ベクトル計算機を用いる場合は、外部手続き呼び
出しを含むD○ループはベクトル化できないという欠点
もある。ここでベクトル計算機と言うのは、複数のベク
トル演算機、ベクトルレジスターを備えた、いわゆるス
ーパーコンピュータのことである。これら計算機の諸元
は、村田健部他著「スーパーコンピュータ」、丸善(昭
和60年発行)の23頁1表1.11に示されている。
Furthermore, when a vector computer is used, there is a drawback that a D* loop that includes an external procedure call cannot be vectorized. Here, a vector computer is a so-called supercomputer equipped with multiple vector calculation machines and vector registers. The specifications of these computers are shown in Table 1.11 on page 23 of "Supercomputer" by Kenbe Murata et al., Maruzen (published in 1985).

−例として、日立製作所製S−810/20を採ると、
その構成は第3図に示すように、スカシプロセッサ40
0.ベクトルプロセツサ50o、入呂力処理装置600
.主記憶装置700がらなり、拡張記憶装置800が付
加されることもある。
- As an example, if we take Hitachi S-810/20,
Its configuration is as shown in FIG.
0. Vector processor 50o, bathing force processing device 600
.. It consists of a main storage device 700, and an extended storage device 800 may be added.

ところで、外部手続呼出しの負荷を軽減するためには、
第4図のように、関数サブプログラムをインライン展開
すればよい。しかし、上述のベクトル計算機を用いる場
合、単にインライン展開したたけでは、あまり速くなら
ない。なぜなら、この計算は一次巡回演算を含むからで
あり、このタイプの演算は、加減乗除算に比べて遅いか
らである。
By the way, in order to reduce the load of external procedure calls,
As shown in FIG. 4, the function subprogram can be expanded inline. However, when using the above-mentioned vector calculator, simply performing inline expansion does not speed up the process very much. This is because this calculation involves first-order cyclic operations, and this type of operation is slow compared to addition, subtraction, multiplication, and division.

本発明の目的は、ヘクトル計算機やアレイ計算機など並
列計算機を使う際の上記問題点を回避する、乱数生成方
法を提供することにある。
An object of the present invention is to provide a random number generation method that avoids the above-mentioned problems when using a parallel computer such as a hector computer or an array computer.

〔課題を解決するための手段〕[Means to solve the problem]

このような目的を達成するために、本発明は。 In order to achieve such an object, the present invention.

乗積合同法により、多数の一様乱数を生成する機能を有
する計算機において、乗数の・−乗をN個、若しくは既
作成の乱数N個を保持しておくことにより、N個の乱数
生成計算を互いに非依存にし、ベクトル処理を行うこと
を特徴とする。
Using a computer that has the function of generating a large number of uniform random numbers using the product congruence method, you can generate N random numbers by storing N multipliers raised to the power of - or N pre-created random numbers. It is characterized by making them mutually independent and performing vector processing.

〔作用〕[Effect]

本発明は、複数個の乱数を一括して生成することにより
、外部手続き呼び出しの負荷を軽減するとともに、複数
個の乱数生成をベクトル処理できるようにする。さらに
、乱数列M 1. 、 M 2.・・・。
By generating a plurality of random numbers at once, the present invention reduces the load of external procedure calls and enables vector processing of the generation of a plurality of random numbers. Furthermore, a random number sequence M1. , M2. ....

Mn、・・・を求める際、−次巡回型演算が含まれない
ように導出方法を工夫し、処理速度を高める。
When calculating Mn, . . . , the derivation method is devised so that −th order cyclic operations are not included, thereby increasing the processing speed.

(1)式の定義より、任意の正数m、nに対し、M、+
、=a″+1−M、          =−(3)=
 a ”−MIl−(3)’ ” an−M *           ・−(3) 
’が成り立つ。従って、相続くN個の乱数M、。
From the definition of equation (1), for any positive numbers m and n, M, +
, =a″+1-M, =-(3)=
a ”-MIl-(3)' ” an-M* ・-(3)
' holds true. Therefore, N successive random numbers M,.

MIl+1.+・・・MII+N−□が求まっていれば
、関係式MII+N= a N1Mn        
    、、、 (4)ただし、m < n < m 
+ N により、それに続くN個の乱数M tn+N+ M1n
+N+、。
MIL+1. +...If MII+N-□ is found, the relational expression MII+N= a N1Mn
,,, (4) However, m < n < m
+ N, the following N random numbers M tn+N+ M1n
+N+,.

・・・9M、ヤ2N−0は単なる乗算だけで求めること
ができる。即ち、高速なベクトル処理が可能である。
...9M, ya2N-0 can be obtained by simple multiplication. That is, high-speed vector processing is possible.

ここで、aNはインデックスr1に依らないので、−度
求めておくだけでよい。
Here, since aN does not depend on the index r1, it is only necessary to calculate - degrees.

〔実施例〕〔Example〕

まず1本発明の原理について説明する。 First, the principle of the present invention will be explained.

第1図は、本発明による乱数生成の基本千顆を示す。FIG. 1 shows a basic method for random number generation according to the present invention.

ステップS1は、初期化処理であり、初期値Moにaを
掛け、Ml を求め、さらにaを掛けM2 を求める。
Step S1 is an initialization process, in which the initial value Mo is multiplied by a to obtain Ml, and further multiplied by a to obtain M2.

以下同様にくり返してMN まで求める。初期値1に対
し同様の計算を行なうとaNが求まる。ステップS2は
、初期化が完了している状態、即ちaN及び相続くN個
の乱数M。。
Repeat the same procedure to find up to MN. A similar calculation is performed for the initial value 1 to find aN. Step S2 is a state in which initialization is completed, that is, aN and N successive random numbers M. .

Mnや8.・・・Mn+N−1が求まっているとき、そ
れにつづくN個の乱数を求める部分である。(4)式に
従い、 M n+N−t =  a N −Mn       
              −(4)’ただし、i=
o、1,2.N−1 とすればよい。ただし、2回目以降(M、、)を求める
には、初期化部を通る必要はないので、ステップS1と
ステップS2の間にエントリーを設けることにする(第
4図以降の実施例参照)。なお。
Mn and 8. . . . When Mn+N-1 has been found, this is the part to find N random numbers following it. According to formula (4), M n + N - t = a N - Mn
-(4)'where i=
o, 1, 2. It may be set to N-1. However, in order to obtain (M, .) from the second time onwards, it is not necessary to go through the initialization section, so an entry is provided between step S1 and step S2 (see the embodiments from FIG. 4 onwards). In addition.

規格化処理については、第1図では省略している。The standardization process is omitted in FIG.

以下1本発明の一実施例を第5図に従い説明する。同図
ブロック7までは、aN及びMユ9M2゜・・2MNを
求める、初期化処理を示すF A I)図である。
An embodiment of the present invention will be described below with reference to FIG. The blocks up to block 7 in the figure are FAI) diagrams showing the initialization process for obtaining aN and Myu9M2°...2MN.

以下、同図箱枠順に処理内容を説明する。The processing contents will be explained below in the order of the boxes in the figure.

1;初期化処理への入口である。1: Entrance to initialization processing.

2:パラメータANに初期値1をセットする。2: Set the initial value 1 to the parameter AN.

ANは 、Nを表わす整数型変数である。AN is an integer type variable representing N.

3:手続き4〜6を繰り返すループ制御を行う。3: Perform loop control to repeat procedures 4 to 6.

4 : A N (= a ’−′(mad L ))
にaを掛けa′l+1を求め、改めてANとする。MS
Kは、先頭ビットがOで以下のΩビットがすべて1の定
数であり、IANDはビットごとに論理積をとるベクト
ル処理関数である。これにより、桁あふれのため、AN
の先頭ビットに1が立っていても取り除かれる。
4: AN (= a'-'(mad L))
Multiply a by a to find a'l+1 and set it as AN again. M.S.
K is a constant whose first bit is O and the following Ω bits are all 1, and IAND is a vector processing function that performs logical product for each bit. As a result, AN
Even if the first bit is set to 1, it is removed.

5 : (1)式に従いMnを求める。符号操作は4と
同様である。
5: Find Mn according to equation (1). The sign operation is the same as in 4.

6 : Mnを法して割り、規格化する。この除算は実
数型(普通は浮動小数点表現を用いる)変数同士の演算
として実行しなければならない。
6: Multiply and divide Mn to standardize. This division must be performed as an operation between real variables (usually using floating point representation).

FLOATは整数型変数を実数型変数に変える型変換関
数である。
FLOAT is a type conversion function that converts an integer type variable to a real number type variable.

2回目以降の乱数列作成にはブロック8から入ればよい
To create a random number sequence for the second and subsequent times, it is sufficient to enter from block 8.

9:3と同様のループ制御を行う。9: Performs loop control similar to 3.

10 : (4)式に従いaN−Mnを算出し、符号ビ
ットを取り除き改めてMnとする。即ちMnはM n+
 Nの値に更新される。
10: Calculate aN-Mn according to equation (4), remove the sign bit, and set Mn again. That is, Mn is M n+
It is updated to the value of N.

]に6と同様にMゎを規格化する。], standardize Mゎ in the same way as in 6.

第5図の実施例では、初期化の部分に関しては定義式通
りの一次巡回型処理を行っているが、2回目以降と同様
の方法を繰り返して並列処理することもできる。
In the embodiment shown in FIG. 5, the initialization part is performed in accordance with the definition formula, but it is also possible to perform parallel processing by repeating the same method from the second time onwards.

まず、ANに関しては、a、a”、a’、・・・と順次
自乗してゆく、Nがちょうど2の一乗のときは、log
2N回の乗算でよく、そうでないときは、Nを越えない
最大の2の一乗の数Kを求め、aKを求めたのち、aを
N−に回掛ければよい。Kを求めるには、k、 = [
log2Nコ([]はガガラの記号)なるkを求め、k
=2’とすればよい。例えば、N=10のときに=8で
あり、まずa2. a4. a8 を求め、次に810
=ag・a’a  とする。但し、aを2回掛ける部分
に関しては、a2 を用いてもよく、一般にaN−にの
計算には、既に計算済みのa2.a4.′・・aK2を
利用することができる。
First, regarding AN, square it in order as a, a'', a', etc. When N is exactly the first power of 2, log
It is sufficient to perform 2N multiplications; if not, find the largest number K of the first power of 2 that does not exceed N, find aK, and then multiply a by N- times. To find K, k, = [
Find k that is log2N ([ ] is the Gagara symbol), and k
= 2'. For example, when N=10, =8, and first a2. a4. Find a8, then 810
=ag・a'a. However, for the part where a is multiplied twice, a2 may be used, and generally when calculating aN-, a2. a4. '...aK2 can be used.

次に、M□2M2.・・MNの求め方を説明する。Next, M□2M2. ...Explain how to find MN.

Moにaを掛けM工を作ったのち、次のように進める。After multiplying Mo by a to create M, proceed as follows.

1)M□にaを掛け、M2 を求める。1) Multiply M□ by a to find M2.

2)Mo、M2にa2を掛け、M、、M、を求める。2) Multiply Mo, M2 by a2 to find M,,M.

3)Ml、M2.−M、にa4を掛け、M、、 ・M。3) Ml, M2. -M, multiplied by a4, M, ・M.

を求める。seek.

以下同様にして、Ml、まで、M3□までという風にM
Kまで求まる。Mxヤ□、・・・、MNは、M n =
 a ’−M n−K            ・・・
(5)ただし、n = K + 1 、・・・、Nによ
り並列に求めることができる。以上計算において、乗算
の度に第5図のブロック4,5の様な符号ビット処理が
必要である。
In the same way, up to Ml, up to M3□, and so on.
Find up to K. Mxya□,..., MN is M n =
a'-M n-K...
(5) However, it can be calculated in parallel using n = K + 1, . . . , N. In the above calculation, sign bit processing like blocks 4 and 5 in FIG. 5 is required every time multiplication is performed.

(3)′式に示したように、MnとMn+N(nは任意
の正整数)には、 Mn+w= a rl−MN (mod L )   
    −(6)なる関係が成り立つ。従って、M工7
M2.・・・。
As shown in formula (3)', Mn and Mn+N (n is any positive integer) have the following formula: Mn+w= a rl-MN (mod L)
-(6) holds true. Therefore, M-engineer 7
M2. ....

MNの代わりにa、a2.・・、aNを記憶しておけば
、nにつづくN個の乱数Mnヤ1.・・・、Mn+Nを
並列に生成することができる。
a, a2. instead of MN. ..., aN, then N random numbers Mn ya 1. following n are stored. ..., Mn+N can be generated in parallel.

第6@は、この考えに従う乱数生成方法を示すPAD図
である。同図ブロック21〜27は、初期化処理であり
、a、a”、・・・、aNを求め、それぞれ配列A工、
A2.・・・、ANに格納する。ただし、Ao=1  
とする。また、A、が求まる度にMnを求め(M、は、
記憶しておく必要がないので一時的変数tで表わす。)
、それを規格化して一様乱数R,を得る。tの終値は、
M、であり2回目以降の計算に引継れる。同図、ブロッ
ク28〜32は、2回目以降即ちA 1g A 21・
・、ANが作成済みの場合の手順である。
The 6th @ is a PAD diagram showing a random number generation method according to this idea. Blocks 21 to 27 in the same figure are initialization processing, in which a, a'', .
A2. ..., stored in AN. However, Ao=1
shall be. Also, find Mn every time A is found (M, is
Since there is no need to store it, it is represented by a temporary variable t. )
, and then normalize it to obtain a uniform random number R. The closing price of t is
M, and can be carried over to the second and subsequent calculations. In the same figure, blocks 28 to 32 are used for the second and subsequent times, that is, A 1g A 21.
・This is the procedure when the AN has already been created.

第6図の方法は、第5図の方法に比べ、2回目以降の乱
数生成個数がN個以下でありさえすれば任意に変えられ
る点で優れている。
The method shown in FIG. 6 is superior to the method shown in FIG. 5 in that it can be changed arbitrarily as long as the number of random numbers generated from the second time onwards is N or less.

第5図、第6図の方法はいずれも、M、lが負数のとき
、符号ビットを無視する(1の場合Oにおきかえる)と
いう定義通りの方法を採っている。
Both of the methods shown in FIGS. 5 and 6 employ a method as defined in which when M and l are negative numbers, the sign bit is ignored (if it is 1, it is replaced with O).

従来は、この他、第3図に示したように絶対値をとる方
法、負値の場合1よ乱数として採用しない方法などの簡
便法も行なわれている。いずれにしても符号ビットが1
のときのための特別な処理が必要である。
Conventionally, other convenient methods have been used, such as a method of taking an absolute value as shown in FIG. 3, and a method of not using 1 as a random number in the case of a negative value. In any case, the sign bit is 1
Special handling is required for these cases.

ところで、Mnは符号ビットも含めて1つの整数を表わ
していると考えれば、その値域は[−り。
By the way, if we consider that Mn represents one integer including the sign bit, its range is [-ri.

L−1コである。従って、Mrlを2L=2”1で割れ
ば−0,5<Mn/2L<0.5  となる。ただし、
Mo、aとして適当な素数を選べば、Mn=−Lとなる
ことはないので、実際は−0,5<Mn/2L<0.5
 である。(Mll)に代って、次のように乱数列(M
’ n)を作る。
It is L-1. Therefore, if Mrl is divided by 2L=2"1, -0,5<Mn/2L<0.5. However,
If you choose an appropriate prime number for Mo, a, Mn=-L will never hold, so in reality -0,5<Mn/2L<0.5
It is. (Mll) is replaced with a random number sequence (M
' Make n).

M ’ p= a ’ M’ n−0n−0(2L )
    ・= (7)ただし、M′。=MO L Rl、は、上述の理由で、(−0,5,0,5)の一様
乱数となる。さらに、 R′、= o、E5 + R′、          
−(9)とすれば、R’nは(0,1)の一様乱数とな
る。
M'p=a'M'n-0n-0(2L)
・= (7) However, M′. =MO L Rl is a uniform random number of (-0, 5, 0, 5) for the above-mentioned reason. Furthermore, R', = o, E5 + R',
-(9), R'n becomes a uniform random number (0, 1).

この数値表現を用いた一様乱数生成手順を第7図に示す
。第5図ブロック4,5.10で必要であった符号ピン
ト処理が、第7図ブロック44゜45.50では不要と
なっている。その代わり、ブロック46.51において
0.5 の加算が必要になる。一般には、第7図の方法
の方が計算負荷が小さい。この方法の乱点が顕著に現わ
れるのは、一様乱数を用いて、種々の分布に従う乱数を
求めるときである。
FIG. 7 shows a uniform random number generation procedure using this numerical expression. The code focus processing that was necessary in blocks 4, 5, and 10 in FIG. 5 is no longer necessary in blocks 44, 45, and 50 in FIG. 7. Instead, an addition of 0.5 is required in block 46.51. Generally, the method shown in FIG. 7 requires less calculation load. The randomness of this method becomes noticeable when uniform random numbers are used to obtain random numbers that follow various distributions.

上記RIo又はRIToは生成方法を用いた、種々の分
布に従う乱数生成方法を示す。
The above RIo or RITo indicates a random number generation method according to various distributions using a generation method.

(1ン正規乱数 一対の(0,L)一様乱数ξ31′、ξ5″から、一対
の正規乱数η3“1.ηけゝが作られる。
(1) A pair of normal random numbers η3'1.η is created from a pair of (0, L) uniform random numbers ξ31' and ξ5''.

ここで、一様乱数としてRlnを用いる。即ち、lξ”
 =R’ n+にR’ n+、+0.5  −(13)
とする。
Here, Rln is used as a uniform random number. That is, lξ”
= R' n+ to R' n+, +0.5 - (13)
shall be.

cos、2xξ” =cos(2x R’ n+□+ 
π)=−cos2πR’n+1 同様に、 ゆえに、正規乱数を作って、その余弦、正弦を取る代わ
りに、 R#′、=−M’ +1−(16) なる(−π、π)の一様乱数を作り、その余弦。
cos, 2xξ" = cos(2x R' n+□+
π) = -cos2πR'n+1 Similarly, Therefore, instead of creating a normal random number and taking its cosine and sine, R#', = -M' +1-(16) The uniformity of (-π, π) becomes Create a random number and its cosine.

正弦を取ればよい。Just take the sine.

一方、(10)式、 (11)式のη3”1 を含む項
については、(12)式を用いる。RJ n、 R”i
l及び(10)式。
On the other hand, for the terms including η3"1 in equations (10) and (11), equation (12) is used. RJ n, R"i
l and formula (10).

(11)式の評価を同一反復ループ内で処理する方法を
第8図に示す9同図で、AN=a’(第1図に同じ) 
ts、tz、+3 は−時的変数、α=1/2L。
(11) A method for processing the evaluation of the expression within the same iteration loop is shown in Figure 8.9 In the same figure, AN=a' (same as in Figure 1)
ts, tz, +3 are −temporal variables, α=1/2L.

β=π/L、Nは偶数である。β=π/L, N is an even number.

ブロック61は、ブロック62〜68の処理をN/2回
実行する。ループ制御を表わす。nは、1、.3..5
.  ・、N−1と変化する。し、はR″。。
Block 61 executes the processing of blocks 62 to 68 N/2 times. Represents loop control. n is 1, . 3. .. 5
.. , N-1.し、はR″.

t2はR”n、、に対応する。 (14)式、 (1,
5)式を用いて、(10)式、 (11)式の値を求め
、一対の正規乱数η。、η。十、が求まる。このループ
内の演算は、いずれもベクトル処理可能であるから、合
計N個の正規乱数が並列生成される。
t2 corresponds to R”n, . Equation (14), (1,
5) Using equations, find the values of equations (10) and (11), and obtain a pair of normal random numbers η. ,η. Ten is found. Since all operations within this loop can be vector processed, a total of N normal random numbers are generated in parallel.

このように、一様乱数と正規乱数を同一ループ内で作、
ることにより、一様乱数をメモリにストアする必要がな
い、(0,1)に規格しなくてよい部分が生じる。ルー
プ制御の負荷が減るなどにより、従来より高速な処理が
可能となる。
In this way, uniform random numbers and regular random numbers can be created in the same loop,
By doing this, there is a part where there is no need to store uniform random numbers in memory and where there is no need to standardize them to (0, 1). By reducing the load on loop control, faster processing than before is possible.

(2)三角乱数 三角分布f(x)=1−1 x 1(−1<x<1)に
従う乱数は1.− 対の一様乱数ξ11.ξ32ゝから
次のように作る。
(2) Triangular random number The random number that follows the triangular distribution f(x) = 1-1 x 1 (-1<x<1) is 1. - a pair of uniform random numbers ξ11. Make it from ξ32゜ as follows.

η=ξ  −ξ             ・・(]+
7ξ11′、ξ01として、R’ 、、((19)式)
を用いることにすれば、 η” R’ n  R” n+。
η=ξ −ξ ・・・(]+
7ξ11', ξ01, R', (Formula (19))
If we decide to use η"R' n R" n+.

” R’ n −” R’ n +、        
  ・(+8)となるから、(8)式の(−0,5,0
,5) 一様乱数をそのまま用いることができる。即ち
、(9)式の規格化が不要になる。そして、正規乱数の
場合と同様、一様乱数と同一ループ内で(η。)夕作り
効率化を図ることができる。
"R' n -"R' n +,
・(+8), so (-0, 5, 0 in equation (8)
, 5) Uniform random numbers can be used as is. That is, standardization of equation (9) becomes unnecessary. As in the case of normal random numbers, it is possible to improve the efficiency of making dinner (η.) within the same loop as with uniform random numbers.

(3)その他分布に従う計算においても、規格化処理を
不要にしたり、軽減することができる。
(3) Even in calculations according to other distributions, normalization processing can be eliminated or reduced.

a)fk(x)=kx” (0<x<1)なる分布に従
う乱数は、 η=max(ξ3゛3.ξi21...ξ(kl )、
、、、 j 19)から求まる。この場合もξ′Jlと
してR″。を採り、R’ n = 0 、5 + R’
。なる性質を用いれば、’Q =max(R’  fl
l  R’  n+0.−  、 R’  −十に−t
)+ 0.5・・・(]、、+9’となり、規格化処理
(0,5の加算)の負荷が軽減される。
a) A random number following the distribution fk(x)=kx” (0<x<1) is η=max(ξ3゛3.ξi21...ξ(kl),
, , j 19). In this case too, R'' is taken as ξ'Jl, and R' n = 0, 5 + R'
. Using the property, 'Q = max(R' fl
l R' n+0. -, R'-ten-t
)+0.5...(],,+9', and the load on normalization processing (addition of 0 and 5) is reduced.

b)gk(x)=k(,1−x)’−” (0<k<1
)なる分布に従う乱数は、 η=min(ξ”’ * ξ”Z 、、ξ”’)   
  (20)から求まる。この場合もξす1として、R
″0を採れば、 η=min(R’ ny R’ n+、t ”’R’ 
n+に一、)+0.5  ”’(20)’となり、規格
化処理の負荷が軽減される。
b) gk(x)=k(,1-x)'-"(0<k<1
) is a random number that follows the distribution η=min(ξ”' * ξ”Z , ξ”')
It can be found from (20). In this case as well, R
If we take ``0, η=min(R' ny R' n+, t ``'R'
1 for n+)+0.5''(20)', and the load on the standardization process is reduced.

C)−次元正規分布(平均09分散1)を、で近似する
方法がある。この場合は、ξ(gl  としてR′oを
採れば、 となり、規格化処理は全く不要になる。
C) There is a method of approximating a -dimensional normal distribution (mean 09 variance 1). In this case, if R′o is taken as ξ(gl), then the normalization process becomes completely unnecessary.

〔発明の効果〕〔Effect of the invention〕

本発明によれば、多数の算術乱数を一括生成できるため
、乱数サブプログラムを呼び出す負荷が相対的に軽減で
きる。また、乱数算出式を一次巡回型でなくしているた
め、ベクトル計算機、並列計算機の特性を生かした処理
が可能である。
According to the present invention, since a large number of arithmetic random numbers can be generated at once, the load of calling a random number subprogram can be relatively reduced. Furthermore, since the random number calculation formula is not a linear cyclic type, processing that takes advantage of the characteristics of vector computers and parallel computers is possible.

他の実施例の方法によれば、符号ビットを取除くための
計算負荷が不要となるとともに、法の値を大きくとれる
(従来法の2倍)ため、周期が長くなる利点がある。ま
た、種々の分布に従う算術乱数を生成するさい、そのも
ととなる一様乱数を(0,1)に規格化しないまま用い
ることができ、高速処理が可能になる。
According to the method of the other embodiments, there is no need for calculation load for removing the sign bit, and the value of the modulus can be increased (twice as much as that of the conventional method), so there is an advantage that the period becomes longer. Furthermore, when generating arithmetic random numbers according to various distributions, the uniform random numbers that are the basis thereof can be used without being normalized to (0, 1), making high-speed processing possible.

さらに、一様乱数算出と関数分布に従う乱数計算と同一
ループに構成することにより、ループ制御負荷が軽減さ
れ、かつ、一様乱数のメモリーへのストアを回避するこ
とができ、処理時間が短縮される。
Furthermore, by configuring uniform random number calculation and random number calculation according to a functional distribution in the same loop, the loop control load is reduced, and the storage of uniform random numbers in memory can be avoided, reducing processing time. Ru.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図は、本発明の一様乱数生成方法の基本的手順を示
すPAD図、第2図は、従来の一様乱数生成プログラム
の例を示す図、第3図はベクトル計算機の内部構成を表
わす図、第4図は、第2図の本発明のプログラムの例を
示す図、第5図、第6図は本発明の一実施例の手順を示
すPAD図、第7図は、Moの数値表現を変えた場合の
一様乱数生成法を示すPAD図、第8図は一様乱数を生
¥、  1 図 第  Z 図 oa   ttw  r=t、NtIρrr (RAM
95M()、((T、  θ5ン丁HEN      
 /lρZ(I) = ArX(D + Y(1)  
      t2(ILL S E         
           t3ρ、Z(Iン= ρρ  
                     14ρE
NDrF                  t5ρ
100  C?1NTINuE           
                   161)RJ
NC7IγN  RANf)’ijM()      
   200DATA  K /q7乙M /13/ 
    ’     Z/θに=MtK       
             22θT?=  FL7j
Ar(K)/I−L2IAす(2181)      
    230RANρiTM= IIBS(R)  
                 240RETUR
N                    250E
ND                     26
θ第 3  ス 第 /i 図 VO/θθ  エニl、/#            
     3θθ1、C=に’*M         
         31θR=’rLiAT(K)/r
L11T(21731)     3zOIF (A 
BS(R) 、 f(7θ5) THEN      
33θK(1)= A!X(J)すY(1)     
  3i。 ELSE35ρ z(1)二ρρ              ゴロθE
Nf) IF                  3
7ρ100 C0NTINLAE          
        3231)第 5 図 v t 図 第 7 図 亨 3 図
Figure 1 is a PAD diagram showing the basic procedure of the uniform random number generation method of the present invention, Figure 2 is a diagram showing an example of a conventional uniform random number generation program, and Figure 3 is the internal configuration of a vector computer. FIG. 4 is a diagram showing an example of the program of the present invention shown in FIG. 2, FIGS. 5 and 6 are PAD diagrams showing the procedure of an embodiment of the present invention, and FIG. PAD diagram showing the uniform random number generation method when changing the numerical expression, Figure 8 generates uniform random numbers.
95M(), ((T, θ5ndingHEN
/lρZ(I) = ArX(D + Y(1)
t2(ILL S E
t3ρ, Z(In= ρρ
14ρE
NDrF t5ρ
100 C? 1NTINuE
161) R.J.
NC7IγN RANf)'ijM()
200DATA K /q7 Otsu M /13/
'Z/θ=MtK
22θT? = FL7j
Ar(K)/I-L2IAsu (2181)
230RANρiTM=IIBS(R)
240 RETUR
N250E
ND26
θth 3rd stage /i Figure VO/θθ enil, /#
3θθ1, C=to'*M
31θR='rLiAT(K)/r
L11T (21731) 3zOIF (A
BS(R), f(7θ5) THEN
33θK(1)=A! X(J)suY(1)
3i. ELSE35ρ z(1)2ρρ Ground ball θE
Nf) IF 3
7ρ100 C0NTINLAE
3231) Figure 5 v t Figure 7 Figure 3

Claims (1)

【特許請求の範囲】 1、乗積合同法により、多数の一様乱数を生成する機能
を有する計算機において、乗数の■乗をN個、若しくは
既作成の乱数N個を保持しておくことにより、N個の乱
数生成計算を互いに非依存にし、ベクトル処理を行うこ
とを特徴とする算術生成方法。 2、整数型変数に対する、演算時の桁あふれ許容機能を
用いて剰余を求める計算機において、符号ビットも含め
た数値表現を用いて乱数を生成することを特徴とする算
術乱数の生成方法。 3、一様乱数を生成し、かつその乱数を用いて与えられ
た分布に従う算術乱数を生成する処理を、同一の反復ル
ープ内で行うことを特徴とする請求項1または2記載の
計算機における算術乱数の生成方法。
[Claims] 1. In a computer that has the function of generating a large number of uniform random numbers using the multiplication product congruence method, by storing N multipliers raised to the power of ■ or N pre-created random numbers. , N random number generation calculations are made mutually independent and vector processing is performed. 2. A method for generating arithmetic random numbers, characterized by generating random numbers using a numerical representation including a sign bit in a computer that calculates a remainder using an overflow tolerance function during calculations for integer type variables. 3. Arithmetic in a computer according to claim 1 or 2, characterized in that the processes of generating uniform random numbers and using the random numbers to generate arithmetic random numbers according to a given distribution are performed within the same iterative loop. How to generate random numbers.
JP2317799A 1990-11-26 1990-11-26 Arithmetic random number generating method in computer Pending JPH04199225A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2317799A JPH04199225A (en) 1990-11-26 1990-11-26 Arithmetic random number generating method in computer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2317799A JPH04199225A (en) 1990-11-26 1990-11-26 Arithmetic random number generating method in computer

Publications (1)

Publication Number Publication Date
JPH04199225A true JPH04199225A (en) 1992-07-20

Family

ID=18092172

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2317799A Pending JPH04199225A (en) 1990-11-26 1990-11-26 Arithmetic random number generating method in computer

Country Status (1)

Country Link
JP (1) JPH04199225A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012014591A (en) * 2010-07-02 2012-01-19 Mizuho Dl Financial Technology Co Ltd Efficient parallel processing method of monte carlo method
EP4033348A1 (en) 2020-12-17 2022-07-27 Fujitsu Limited Random number generation program and random number generation method, random number generation apparatus

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012014591A (en) * 2010-07-02 2012-01-19 Mizuho Dl Financial Technology Co Ltd Efficient parallel processing method of monte carlo method
EP4033348A1 (en) 2020-12-17 2022-07-27 Fujitsu Limited Random number generation program and random number generation method, random number generation apparatus

Similar Documents

Publication Publication Date Title
Pan Complexity of computations with matrices and polynomials
Yu et al. Fast algebraic rewriting based on and-inverter graphs
Qiu et al. On the construction, comparison, and local characteristic decomposition for high-order central WENO schemes
Bini et al. Polynomial and matrix computations: fundamental algorithms
Smart The algorithmic resolution of Diophantine equations: a computational cookbook
He et al. GPU-accelerated parallel sparse LU factorization method for fast circuit analysis
Höreth et al. Formal verification of word-level specifications
Arjevani et al. On lower and upper bounds for smooth and strongly convex optimization problems
Gadakh et al. Design and optimization of 16× 16 Bit multiplier using Vedic mathematics
Kidwai et al. Quantum curves from refined topological recursion: the genus 0 case
Rushdi et al. Derivation of all particular solutions of a ‘big’Boolean equation with applications in digital design
Hansen et al. Synthesis by spectral translation using Boolean decision diagrams
JPH04199225A (en) Arithmetic random number generating method in computer
Capinski et al. Computer assisted proofs of attracting invariant tori for ODEs
Vavasis Gaussian elimination with pivoting is P-complete
Sundaramurthy et al. Some results in fixed-point fast Fourier transform error analysis
Gheorghiu On the numerical treatment of the eigenparameter dependent boundary conditions
Kalla et al. High-level design verification using Taylor Expansion Diagrams: first results
Chang et al. Automated least-significant bit datapath optimization for FPGAs
Ogbereyivwe et al. BEHIND WEERAKOON AND FERNANDO’S SCHEME: IS WEERAKOON AND FERNANDO SCHEME VERSION COMPUTATIONALLY BETTER THAN ITS POWER-MEANS VARIANTS?
Fulling Kernel asymptotics of exotic second-order operators
Palmer Accelerating Implicit Finite Difference Schemes Using a Hardware Optimized Tridiagonal Solver for FPGAs
Greenberg et al. Functional analytic treatment of the transport equation
Bianchetti Infinite time computation: strong and weak infinite time turing machines
Shirayanagi et al. Reducing exact computations to obtain exact results based on stabilization techniques