A reproducible and portable computation method for multiplicative congruential random numbers, where the product of two positive, relatively prime single-precision integers is modulo d, and 2d is less than the double-precision integer limit, using only integer and real-number double-precision operations.

By decomposing the modulus into the product of two relatively prime integers and applying the Chinese Remainder Theorem, the MC random number generation method achieves efficient and reproducible high-precision results, overcoming the limitations of impractical quadruple-precision integer calculations.

JP7876747B2Active Publication Date: 2026-06-22中泽直也

Patent Information

Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
中泽直也
Filing Date
2022-01-31
Publication Date
2026-06-22

AI Technical Summary

Technical Problem

Existing multiplicative congruential (MC) random number generation methods face challenges in achieving long periods and efficient computation, particularly when using odd prime numbers as moduli, requiring impractical quadruple-precision integer calculations.

Method used

Employing the Chinese Remainder Theorem to decompose the modulus into the product of two relatively prime integers, utilizing double-precision arithmetic to generate MC random numbers, ensuring reproducibility and portability across different computer models and programming languages.

Benefits of technology

Achieves a 10x speedup in calculation time while maintaining high precision, generating MC random numbers with a period exceeding 2^54, suitable for practical use as double-precision real numbers.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader

Abstract

To provide a calculation method for generating random numbers only with operations of double precision integers and double precision real numbers.SOLUTION: In a method, modulo d=ef, which is a product of relatively prime positive integers e, f, which have no two common prime factors, in a multiplicative congruential random number (d, z, n) consisting of a multiplier z prime to d, and a seed n prime to d, a sequence of positive integers {zk|k=0, 1, 2, ...}, z0=mod(n, d), zk+1=mod(zzk, d), and k=0, 1, 2, ..., are obtained to obtain uniformly independent random numbers {vk:=zk / d|k=0, 1, 2, ...} by the recurrence congruence expression obtained sequentially from an arbitrarily given initial value n of integers.SELECTED DRAWING: None
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] A multiplicative congruential (MC) random number generation mechanism given by a triple of integers (d, z, n), where d > 0, z > 0 which is relatively prime to d and is called a multiplier, and n which is relatively prime to d and is an initial value or seed, generates a sequence of integers {X0, X1, X2, …} in the open interval (0, d) by a recursive congruence relation modulo d X0 = mod(n, d), X k+1 = mod(zX k , d) k = 0, 1, 2, …, or as a power of the multiplier z X k k = mod(nz k , d), k = 0, 1, 2, … Here and below, the function mod(A, d) takes as its value the remainder R of an integer A greater than or equal to 0 minus Q times the integer quotient of A by d, where R is an integer greater than or equal to 0 and less than d. The MC uniform rational random number sequence distributed within the open interval (0, 1) is {V k := X k / d, k = 0, 1, 2, …, 0 < V k < 1} obtained and is actually used as a random number.

[0002] To obtain an excellent random number sequence, it is not possible to simply take any arbitrary integer triple (d, z, n) that satisfies the conditions. The only technical realization means is to try (test) various moduli d and various multipliers z and discover and adopt those that give an output that appears to be excellently uniformly independent. This simplest and in a sense primitive method is, however, the most extensive and powerful among random number generation methods, and for any finite uniform random number sequence (注1) {U k , k = 0, 1, 2, …}, regardless of the number k, there exists an MC random number sequence {V k , k = 0, 1, 2, …} such that 0 < (the absolute value of (V k - U k ) < 1 / z, k = 0, 1, 2, … This approximates the same. This is a fact discovered in the 21st century, and it is thus known that the MC random number generation method has the most reliable verification method over the entire period. (See Reference 1). MC random numbers exhibiting such excellent performance already exist. Here, we report new techniques for their practical application. (Reference 1) Naoya Nakazawa / Hiroshi Nakazawa: “Random Number Generator on Computers,” Jenny Stanford Publishing. It has received excellent reviews and is currently undergoing final proofreading for publication, including index creation and cover design. (注1) Since the amount of information a computer can hold is finite, infinite sequences are impossible on a computer. Only integers with a finite number of digits, or at most finite repeating (rational) sequences, can be represented as 'real numbers'.

[0003] When designing an MC generation mechanism (d, z, n), the first problem is the period T of the generated random number sequence. There are various cases, but the basic case is when modulo d is an odd prime number and z is its primitive root, giving the longest period T obtainable modulo d = (d-1) / 2, and in all other cases the ratio T / d is smaller than that. The simulation must be performed with a single MC random number generation mechanism, and the use of two or more MC random number generation mechanisms, no matter how good the individual statistics are, cannot be used without testing the combined whole sequence. In that sense, the "composite MC random number generation mechanism of a combination of a pair of prime numbers modulo and their respective primitive root multipliers according to Sun Tzu's theorem," which has been confirmed to be superior through testing, is a generation method that boasts excellent uniform independence. If the integer d=p is an odd prime number and the multiplier z is its primitive root, then the period T=(p-1) / 2 that can actually be used is, in current simulations, 2 40 Since it is required that the value is greater than or equal to 2, p is 2 41 It must be something enormous. That is, in an MC random number generation mechanism with odd prime numbers p and primitive root z, modulo p must be a 'double-precision integer'. This presents a great difficulty in the operations used by an MC random number generation mechanism (p, z, n) that has a structure with modulo p of a prime number and its primitive root z. In the basic structure of MC random numbers, the integer output X in the previous stage k=mod(nz k Since we multiply (,p) by z again and take the modulo p to calculate, it is always mod(z·X k , p), We must find zX. The symbol · representing the product will be omitted from now on. k Since the calculation exceeds integer multiple precision, computers and computational languages ​​capable of handling quadruple-precision integers are rare and impractical. Therefore, we must take the approach of performing the calculation using more readily available quadruple-precision real numbers and taking the integer part to achieve reproducibility. However, 2 40 Small periods of this magnitude are used up very quickly in simulation calculations, and employing such large-scale quadruple-precision calculations is an excessive burden compared to the effect.

[0004] The difficulty of calculating the modulo of a single prime number and its primitive root multiplier, as well as the difficulty of the short period, was only discovered when MC random numbers were given a deeper consideration, revealing that Sun Tzu's theorem provides a magical solution. The current invention is a theoretic technique based on the discovery by Naoya Nakazawa. First, keeping in mind the modulo d of positive integers and a non-negative integer A, we prepare an unambiguous definition of the modulo function mod(A, d), which will be used frequently from now on. (Definition 1) For an integer A greater than or equal to 0 and a modulo d of a positive integer, mod(A, d) is: From A, remove the quotient Q of a non-negative integer that is modulo a positive integer d, It is the remainder, which is an integer between 0 and d (exclusive of 0). This is defined as follows. Expressed as a division equation, A = Qd + R, where R is an integer between 0 and d (exclusive of 0). Based on this, we define mod(A, d) = R. (End of Definition 1)

[0005] The core of the problem lies in the structure where modulo d is the product d = e1e2 of two relatively prime positive integers. Sun Tzu's theorem can take various forms, but the form (Theorem 2) below is the most convenient for our current discussion. (Theorem 2) (Sun Tzu's Theorem A) Let d = e1e2 be the product of relatively prime integers (with the greatest common divisor 1) whose modulo d > 0 is positive. 'Any integer A between 0 and d (exclusive)' is: A=A1D1D1 -1 +A2D2D2 -1 , A1 = mod (A, e1), where A1 is greater than or equal to 0 and less than e1. A2 = mod (A, e2), where A2 is greater than or equal to 0 and less than e2, (*) It can be uniquely broken down into its shape. (注2) Here, D1 = d / e1 (= e2) and D2 = d / e2 (= e1), (#)D1 -1 This is the reciprocal of D1=e2 modulo e1. mod(D1D1 -1 , e1) = 1, D2 -1 D2 is the reciprocal of D2 = e1 modulo e2. mod(D2D2 -1 , e2)=1, It exists as such. (Proof) Since e1 and e2 are relatively prime and their greatest common divisor is 1, the conclusion of the Euclidean algorithm is that for integers M and N, the greatest common divisor is 1, which is given by the following 'equation'. Me1 + Ne2 = MD2 + Ne2 = 1 It is given by this. Looking at this as a congruence, we can see that Me1=MD2 is '1 modulo e2', and the integer M is 'the reciprocal of D2 modulo e2', and therefore exists between 1 and e2 'modulo e2'. In fact M=D2 -1 This can be obtained by setting M sequentially as 1, 2, ..., e2-1 and multiplying by D2=e1, and finding the value that "is 1 modulo e2". Similarly, N is Ne2=1-Me1, that is, "the reciprocal of e2=D1 as seen modulo e1, D1 -1 It exists as ', and by setting N from 1 to e1-1 and trying them, we can find 'the one that is 1 modulo e1' by multiplying D1=e2. Before using the MC random number generation mechanism, M=D2 -1 and N=D1 -1 Calculate it in this way, integer D1D1 -1 and D2D2 -1 Prepare the following. For any positive integer A, the right-hand side of equation (*) modulo (A, e k ) consider (#) (注3) mod(A, e1) = mod(A1D1D1) -1 , e1) =mod(A1×1,e1)=A1 mod(A, e2) = mod(A2D2D2) -1 , e2) =mod(A2×1,e2)=A2 Note that A1 is defined as being between 0 and e1 (inclusive), and A2 as being between 0 and e2 (inclusive). Now, a positive integer B is also expressed in the same form (*). B=A1D1D1 -1 +A2D2D2 -1 Let's assume it has that. That is, A1=mod(B, e1), A2=mod(B, e2) Assume the following holds. Expressed using the division equation, there exist non-negative integer quotients Q and Q' such that B = Qe1 + A1 and A = Q'e1 + A1, and BA = (QQ')e1; the integer BA is a multiple of e1. Similarly, we can see that BA is a multiple of e2. e1 and e2 are relatively prime, meaning their greatest common divisor is 1 and they have no common prime factors, so BA is a multiple of their product e1e2 = d. Since both A and B are greater than or equal to 0 and less than d, the difference between B and A must be 0. Therefore, the integer A is unique modulo d = e1e2. (End of proof of Theorem 2) (注2) I have deliberately rewritten D1=e2 and D2=e1 here, but I believe that this slight difference in expression greatly affects the understanding of the proof of Sun Tzu's theorem described here. If you have any doubts, I encourage you to try the proof without such rephrasing. Even so, understanding the breadth of Sun Tzu's theorem is difficult. (注3) This relationship is mod(D j D j -1 , e k )=δ jk , δ jk This can also be expressed as the Kronecker delta; if j and k are different, then D j is e k Therefore, the left side is 0.

[0006] The following 'understanding' of Theorem 2 (Sun Tzu's Theorem A) above is important, even though it is 'simply a restatement'. (Corollary 3. Sun Tzu's Theorem B) Let the modulus d > 0 of integers be positive and the product d = e1e2 of relatively prime integers (with the greatest common divisor of 1). Then any positive integer A between 0 and d (exclusive) is modulo e k e is greater than or equal to 0 k A value less than A K =mod(A, e k )(k=1, 2) is a linear combination that is unique modulo d. A = mod (A1D1D1) -1 +A2D2D2 -1 (d=e1e2) This is how it is expressed. (End of System 3) That being said, the impression that it's like magic is hard to shake off. To gain an intuitive understanding, let's look at a concrete example of System 3 above (Example 4). (Example 4) The modulus d of MC random number generation mechanism #001 is d=e1e2, e1=134265023, e2=134475827, d=e1e2=18055400005099021=2 54.00… D1=e2=134475827, D1 -1 =52577007, D2=e1=134265023, D2 -1 =81816271, This gives us the following solution. For any positive integer A = 7759097958782935, (corollary 3) gives us the following solution: A1 = mod (A, e1) = 19061252, A2 = mod (A, e2) = 77600525, (%)A=mod(A1D1D1 -1 +A2D2D2 -1 d=e1e2). Verify the percentage (%) using a computer calculator such as CALC. Theoretically, this is obvious as shown in (Corollary 3) for any non-negative integer A, but I would like you to try it yourself to understand it.

[0007] There are two points to note regarding the modulo functions of addition and multiplication for non-negative integer variables X and Y. (1) Let d be a positive integer. The modulo addition function of non-negative integer variables X, Y, ... mod(X+Y, d) mod(X+Y, d) =mod(mod(X, d)+mod(Y, d), d) This is the correct formula. Considering it as a division equation, we can denote the integer quotients of the division as Q and Q'. X=Qd+mod(X, d), Y=Q'd+mod(Y, d), mod(X+Y, d) =mod({mod(X, d)+mod(Y, d)}, d), This is obvious; all integer multiples modulo d can be dropped, but mod (X, d) + mod (Y, d) may exceed d, so the outer 'last modulo function' is generally necessary. (2) Similarly, if the variable of the modulo function is the product of an integer X and Y that is 0 or greater mod(XY, d)=mod({mod(X, d)×mod(Y, d)}, d) Note that the following holds true. In fact, in terms of the equation... X=Qd+mod(X, d), Y=Q'd+mod(Y, d) The following holds true. Q and Q' are integer quotients in division. Therefore XY = integer multiple of d + mod(X, d) × mod(Y, d) And, mod(XY, d) =mod({mod(X, d)×mod(Y, d)}, d) This is the result. Since mod(X, d) × mod(Y, d) may be greater than d, the outermost modulo function is generally necessary. This alone will not suffice for the discussions to come, but I hope you will be satisfied with the ingenuity used in each step.

[0008] Now we can consider the structure of MC random numbers modulo d = e1e2, which is the product of two relatively prime positive submodals. The index of the MC integer random number sequence generated by (d, z, n) is denoted as t (to avoid the slightly obscured j), keeping in mind the time. The t-th integer term of the MC random number sequence is {X t = mod(nz t 、 d), t = 0, 1, 2, …,} can be expressed as. In the form of a recurrence relation X0 = mod(n, d), X t+1 = mod(zX t 、 d), t = 0, 1, 2, … can also be expressed as. The partial multiplier and the partial initial value Partial multiplier: {z k = mod(z, e k ), k = 1, 2}, Partial initial value: {n k = mod(n, e k ), k = 1, 2} are denoted as. To use the Chinese Remainder Theorem for X t it is necessary to mod(X t 、 e k ) = mod(mod(nz t 、 d), e k ) be calculated. mod(nz t 、 d) is the result of removing multiples of d = e1e2 from nz t . Since "the removed part is 0 modulo e k ", mod(mod(nz t 、 d), e k ) = mod(nz t 、 e k ) can be used. Therefore, all multiples of e k generated during the calculation can be dropped. However,[[]] n = n k +(an integer multiple of e k ), z = z k +(an integer multiple of e k ), z t =(z k +an integer multiple of e​​​​​​​​​​​​​​​ mod(nz t 、e k )=n k (z k ) t ={the t-th output random number from the partial MC generation mechanism (e k 、z k 、n k )} holds. Summing up, it becomes the following Theorem 5. (Theorem 5) (Chinese Remainder Theorem C) If the modulus d > 0 is d = e1e2, the product of relatively prime partial moduli e1 > 0 and e2 > 0, then the "value modulo e k " of the t-th random number of the (d, z, n) MC random number generation mechanism is the same as the t-th random number of the partial MC random number generation mechanism (e k 、z k 、n k ). (Proof of Theorem 5, Chinese Remainder Theorem C ends)

[0009] The convenience and prospects of the technology provided by the Chinese Remainder Theorem are great. As a specific example, excellent MC random number generation mechanism #001 is taken. This random number is generated with modulus d = e1e2 d = 18055400005099021, about 2 54 powers as the modulus and multiplier z = 7759097958782935, about 2 52.78 powers . The detailed composition and performance are also disclosed in (Reference 1). The method using the Chinese Remainder Theorem of the present invention can be realized only by double-precision integer arithmetic and double-precision time arithmetic as illustrated in FIGS. 1 and 2 of the claims, and the CPU time for random number generation is approximately 0.28 seconds / 10 million. The simple multiplication method program via quadruple-precision real numbers as the (d, z, n) random number cannot use quadruple-precision integer arithmetic in ordinary computers and computing languages, so it is shown as FIG. 3 of the claims via quadruple-precision real arithmetic. Its form is much simpler compared to FIGS. 1 and 2. However, the calculation time takes about 10 times longer. I hope you can feel the speedup realized by the technical idea using the Chinese Remainder Theorem. The MC random number real number output of #001 realized by the programs in FIGS. 1 and 2 has an accuracy of 1 / d, about 2 -54It possesses a precision of [precision] and has a sufficient number of digits for practical use as a double-precision real number. Technical Outlook

[0010] The goal here is to generate (d, z, n)MC random numbers, and for that alone, the simplest X is the most straightforward. t =mod(nz t d) A recurrence relation requiring quadruple-precision real number calculations, X t+1 =mod(zX t d) This provides a reproducible and portable correct solution, and uses V as the random number. t =X t Taking / d yields a correct MC random number. However, considering the speed of calculation and feasibility on a computer, the structure d=e1e2 described here, the realization of Sun Tzu's theorem by the product of relatively prime submethods, achieves a calculation speed 10 times faster, reproducible and portable regardless of the computer model or programming language, for integer and real-number multiple precision calculations only. This is a significant advance in engineering technology. Please carefully examine Figures 1 and 2 of the calculation program described in the claims. Looking back at what has been understood here from a higher perspective, if the modulus d>0 is the product of relatively prime submethods d=e1e2, then the integer form of the (d, z, n) multiplicative congruential random number is Partial MC random number {X (1) 0, X (1) 1, X (1) 2, ...} Modulo e2 partial MC random number {X (2) 0, X (2) 1, X (2) 2, ...} shuffling {X t =mod(X (1) t D1D1 -1 +X (2) t D2D2 -1 d) t = 0, 1, 2, ... This serves as a mathematical proof of that fact. It is unlikely that Sun Tzu could have foreseen the possibility of such a computer structure in the 5th century, but one cannot help but feel awe. The inventors would be pleased if this could contribute to understanding from various perspectives.

Claims

[Claim 1] A multiplicative congruent (MC) random number generation method for generating multiplicative congruent (MC) random numbers on an information processing device, wherein the following items are performed prior to the calculation. (1) Modulus d is two different single-precision integer limit 2 32 The product d = ef of two odd primes e and f less than 2d = 2ef is a double-precision integer. * 8) Limit 2 64 Less than, take, (2) The reciprocal of f modulo e, F -1 (0 < F -1 <e) and the reciprocal of e modulo f is E -1 (0 < E -1 Calculate each of the following: (3) The exponent z and the initial value n are both prime integers to d, between 1 and d (inclusive). (4) Double-precision integer * MC(d, z, n) integer recurrence relation modulo d of 8 z 0 =mod(n、d=ef)、 z k+1 =mod(zz k 、d=ef)、k=0、1、2、… (*1) The components for the subroutines e and f of the two odd primes corresponding to this are (Partial multiplier modulo e) a = mod(z, e), (Partial initial value modulo e) a 0 =mod(z,e), (Partial multiplier modulo f) b = mod(z, f), (Partial initial value modulo f) b 0 =mod(z,f), It is determined that The following procedural items are given. (A) MC recurrence relation in the single-precision integer submethods e and f a k+1 =mod(1a k ,e), b k+1 =mod(bb k ,f) (*2) The solution is obtained by sequentially converting k = 0, 1, 2, ... to double-precision integers. * It is calculated using 8 registers. (B) The sequence of solutions a of each partial MC integer recurrence relation (*2) obtained in (A) above. k and b k From this, the sequence of solutions z of the integer recurrence relation MC(d, z, n) (*1) k This is one form of Sun Tzu's theorem, a linear combination. z k =mod{f・mod(a k F -1 、e)+ e・mod(b k E -1 、f)、d=ef} (*3) As such, 4x precision real * Double-precision integer without using 16 registers * The values ​​are obtained sequentially for k = 0, 1, 2, ... on the 8 registers. (C) From the integer solution (*3) of (B) above, the target MC method (d, z, n) random number sequence is a double-precision real number. * A sequence of 8 random numbers x k =z k / d、 k=0,1、2、…、 To obtain A multiplication congruence (MC) random number generation method which performs the above steps (A), (B), and (C) in that order, and generates quadruple-precision real numbers according to Sun Tzu's theorem. * Double-precision integer without using 16 registers * 8 registers and double-precision real numbers * A multiplication congruential (MC) random number generation method that uses only 8 registers.