A random number generation method and system based on difference uniform distribution
Patent Information
- Application Number
- CN202611259434.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-19
- Publication Date
- 2026-10-23
AI Technical Summary
[0003]•伪随机数生成器(PRNG):基于确定算法,存在周期性与可预测性风险,难以满足高安全需求;真随机数生成器(TRNG):基于物理熵源,成本高且原始输出需复杂后处理,实现复杂度大
[0023]严格可证均匀性:双射映射证明S在上均匀分布(每个值概率1/n²);
Smart Images

Figure CN122963506A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of random number generation technology, specifically to a random number generation method and system based on the principle of bijective mapping with provably uniform distribution characteristics, and its applications in cryptography, financial engineering, artificial intelligence, and other fields. Background Technology
[0002] Uniformly distributed random numbers are fundamental to modern information technology, and their quality directly impacts the security of cryptographic systems, the accuracy of numerical simulations, and the performance of machine learning models. Current mainstream technologies suffer from the following shortcomings:
[0003] • Pseudo-random number generators (PRNGs): Based on deterministic algorithms, they suffer from periodicity and predictability risks, making it difficult to meet high security requirements. True random number generators (TRNGs): Based on physical entropy sources, they are costly and require complex post-processing of the original output, resulting in high implementation complexity. Therefore, the industry urgently needs a random number generation scheme that combines strictly provable uniformity, simple implementation, flexible parameters, and strong adaptability to source randomness. Summary of the Invention
[0004] 3.1 Core Principles
[0005] Based on bijective mapping, in a specific set of arithmetic sequences A and B, the absolute value of the difference between elements is independently and uniformly selected as the target random number, which follows a strictly uniform distribution on the discrete set.
[0006] 3.2 Methods and Steps
[0007] S1: Set parameters: real number x, real number d>0, integer n≥2.
[0008] S2: Construct sets: (both sets have n elements) set (First term x, common difference d,) set (First item) ,tolerance )
[0009] S3: Independent sampling: Independent and uniform sampling from A and B and The selection methods include: physical devices: digital carriers such as polyhedral dice, spinning wheels, two sets of spheres or card combinations, with the numbers marked on the carriers corresponding to the positions of elements in A and B respectively. Electronic generators: truly random numbers or algorithmic pseudo-random numbers based on physical entropy sources, mapped to the corresponding positions of elements in A and B.
[0010] S4: Difference Calculation: .because , x is canceled out, therefore Heng was established. .
[0011] S5: Output random numbers: S in the set The upper part follows a uniform distribution (see Section 4 for proof).
[0012] S6: Post-processing via mold taking Or refuse sampling, adapt to the target range or .
[0013] 3.3 System Composition
[0014] Parameter configuration module: Receives and stores x, d, and n, and generates definitions for A and B;
[0015] Random source provision module: independently and uniformly acquires data through physical or electronic means. , ;
[0016] Sampling and Calculation Module: Execution Operations;
[0017] Control output module: Outputs S and subsequent mapping parameters (such as standardized coefficients) (e.g., modulus M, target interval boundary, etc.), or directly output the result of S after mapping.
[0018] 3.4 Multi-domain application solutions
[0019] Cryptography: Generate S, and use S or the result mapped by a deterministic algorithm as the private key, initialization vector (IV), random salt, or random number seed for the encryption algorithm; specifically applied to the Diffie-Hellman key exchange protocol, let p be a large prime number, and map S to the integer range. Obtain the private key.
[0020] Financial Engineering: Generate S, standardized as (U is uniformly distributed on [0,1]), and U is transformed into a target distribution random variable through probability integral transformation, which can be used for financial asset price path simulation, derivative pricing or risk assessment.
[0021] Artificial intelligence: Generate S, which is mapped to the desired interval and used for neural network weight initialization, decision-making for retaining randomly deactivated (Dropout) neurons, random shuffling of training datasets, or stochastic gradient selection in stochastic optimization algorithms.
[0022] 3.5 Beneficial Effects
[0023] Rigorous provable homogeneity: Prove S in bijective mapping Uniformly distributed (each value has a probability of 1 / n²);
[0024] Flexible parameter configuration: Adjust x (translation), d (scaling), and n (range n²d) to adapt to different scenarios;
[0025] Simple and efficient implementation: The core operations only involve subtraction and absolute value (complexity) );
[0026] The source randomness is highly adaptable: Since the uniform distribution of the bijective mapping is independent of the distribution of the source random numbers, only the source random numbers need to satisfy the independence, so the quality requirements of the upstream random source are relaxed.
[0027] Wide range of applications: covering high-requirement fields such as cryptography, finance, and AI. Mathematical Principles and Proofs
[0028] 4.1 Parameter and Set Definitions
[0029] Set real number Construct two sets of arithmetic sequences with n elements and introduce index variables K and M: where .but: , .
[0030] 4.2 Proof of Bijective Mapping and Uniform Distribution
[0031] Sample space: Independent selection Sample points ,common Each point has a probability. .
[0032] Target expression: .
[0033] because ,
[0034] but: .
[0035] bijective mapping
[0036] Floodability: ,
[0037] but ;
[0038] Singletonity: ,
[0039] but .
[0040] The left side is a multiple of n ,
[0041] right When it is established, it is injective.
[0042] Double-shot guarantee: each probability Therefore exist It is strictly and evenly distributed.
[0043] Conclusion: Through bijective mapping The uniformity of the source random numbers, each The random number is passed to the target random number with equal probability. ,exist The upper bound follows a uniform distribution. The core logic is that bijective mapping guarantees an unbiased mapping, which is rigorously verified through surjective and injective properties. Attached Figure Description
[0044] Figure 1 Flowchart of random number generation method (Start → S1 Parameter setting → S2 Set construction → S3 Independent sampling → S4 Difference calculation → S5 Output S → End);
[0045] Figure 2 System module composition and data flow diagram (parameter configuration → random source provision + calculation → control output, data flow direction marked).
[0046] Figure 3 Cryptographic Application Flowchart (Diffie-Hellman Key Generation: Security Requirements → n Derivation → S Generation → Range Verification → Key);
[0047] Figure 4 Financial Application Flowchart (Generate S → Standardize u → Monte Carlo Simulation → Price Estimation);
[0048] Figure 5 AI Application Flowchart (Generate s1, s2 → Obtain coordinates by modulus → Random cropping → Augmenting data).
[0049] Figure 6 : A schematic diagram of bijective mapping (examples of the correspondence between (k,m) and t=mn-k when n=3, such as (0,1)=3, (1,1)=2, (2,1)=1, etc.).
[0050] Figure 7 Schematic diagram of a dual-rotor random number generator (Example 1). ① is the first digital state carrier, ② is the second digital state carrier, ③ is the tray, and ④ is the pointer. Detailed Implementation
[0051] Example 1: Double-rotating random number generation scheme (assuming parameters x=0, d=1, n=6)
[0052] like Figure 7As shown, this embodiment uses two independent, juxtaposed turntables as the digital carrier. Each turntable is divided into six equally divided sector areas, and the numbers marked in each area correspond to elements in sets A and B, respectively.
[0053] The numbers marked on turntable A are 0, 1, 2, 3, 4, 5, corresponding to A = {0, 1, 2, 3, 4, 5};
[0054] The numbers marked on turntable B are 6, 12, 18, 24, 30, 36, corresponding to B = {6, 12, 18, 24, 30, 36}.
[0055] Two turntables are rotated in opposite directions by a driving mechanism (such as a motor) and then randomly stopped. The numbers a∈A on turntable A and b∈B on turntable B, as indicated by the pointer, are read. The absolute value of the difference, S=|ab|, is calculated. According to the principle of bijective mapping, S follows a uniform distribution on the integer interval [1,36].
[0056] This device uses a transparent, intuitive, and reliable random source to generate target random numbers with uniform distribution characteristics. It not only solves the problem of uneven distribution in traditional physical devices (the sum of two dice), but also transforms a limited range of random numbers into a wider range of target random numbers. It is particularly suitable for educational demonstrations, lottery draws, gaming devices, and applications requiring high transparency of the random source.
[0057] Example 2: Cryptographic Key Generation (Diffie-Hellman Protocol)
[0058] Scenario A (Elliptic Curve): Generate a 256-bit ECC private key in the range [1, q-1], where q is the order of the elliptic curve.
[0059] step:
[0060] 1. Let x=0, d=1, n=⌈√(q-1)⌉ (n²≥q-1, round up);
[0061] 2. Construction
[0062] 3. Cryptographically secure independent selection of random sources , ;
[0063] 4. Calculation (because );
[0064] 5. If private key Otherwise, refuse to sample and retry.
[0065] Scenario B (Prime Field DH): Let p be a 2048-bit large prime number, g be a primitive root modulo p, and the private key range be [1, p-2].
[0066] step:
[0067] 1. Let ;
[0068] 2. Construction , (make sure );
[0069] 3. Independently and uniformly select a∈A, b∈B;
[0070] 4. Calculation ;
[0071] 5. If Private key a=S, public key is Otherwise, refuse to sample and retry.
[0072] Example 3: Financial Monte Carlo Pricing (European Call Option)
[0073] Scenario: Generating uniformly distributed random numbers in the range [0,1] to drive the simulation;
[0074] step:
[0075] 1. Let ;
[0076] 2. Construction ;
[0077] 3. High-performance random source selection ;
[0078] 4. Calculation ,standardization ([0,1] uniform distribution);
[0079] 5. Simulate the asset price path using u, repeat the process a million times, and take the average to obtain the option price.
[0080] Example 4: Artificial Intelligence Data Augmentation (Random Pruning)
[0081] Scene: A 256×256 image is cropped into a 224×224 sub-image, with coordinates in the range [0, 32).
[0082] step:
[0083] 1. Let ;
[0084] 2. Construction ;
[0085] 3. Use this invention to independently generate s1 and s2 (target random numbers);
[0086] 4. Obtain coordinates by taking the modulus. ;
[0087] 5. Clip by (r,c) to ensure all positions are accessed with equal probability.
[0088] Conclusion: This invention realizes a method and system for generating random numbers with provable uniformity, flexible parameters, and high efficiency and reliability through the principle of bijective mapping, providing a new option for demanding fields.
Claims
1. A method for generating uniform random numbers based on the principle of bijective mapping, characterized in that, include: S1: Set parameters: real number x, positive real number d>0, integer n≥2; S2: Construct sets A and B, each with n elements, based on set parameters; , 。 2.S3: Independently and uniformly select elements a∈A and b∈B from A and B respectively as source random numbers. 3.S4: Calculation Used as the target random number.
4. The method according to claim 1, characterized in that, In step S1, d=1 is set, so the target random number S is in the discrete set {1, 2, …, n}. 2 A random integer uniformly distributed on}.
5. The method according to claim 1 or 2, characterized in that, In step S3 and It is selected independently and uniformly through a physical random number generation device; the device includes, but is not limited to, any of the following: paired polyhedral dice, a turntable, two sets of spheres or cards.
6. The method according to claim 1, characterized in that, The method is applied to key generation in the field of cryptography, including: generating S, and using S or the result mapped by a deterministic algorithm as the private key, initialization vector (IV), random salt value, or random number seed of the encryption algorithm.
7. The method according to claim 4, characterized in that, Specifically applied to the Diffie-Hellman key exchange protocol, it includes: assuming p is a large prime number, mapping S to an integer range. Obtain the private key, use it to calculate and exchange the public key to generate a shared key.
8. The method according to claim 1, characterized in that, The method is applied to Monte Carlo simulations in the field of financial engineering, including: generating S, and standardizing it to... (U is uniformly distributed on [0,1]), and U is transformed into a target distribution random variable through probability integral transformation, which can be used for financial asset price path simulation, derivative pricing or risk assessment.
9. The method according to claim 1, characterized in that, The method is applied to model training and optimization in the field of artificial intelligence, including: generating S, mapping it to the required interval and using it for neural network weight initialization, decision-making for retaining randomly deactivated (Dropout) neurons, random shuffling of training datasets, or stochastic gradient selection in stochastic optimization algorithms.
10. A random number generation system implementing the method according to any one of claims 1-7, characterized in that, include: Parameter configuration module: Receives and stores the set parameters x, d, and n, and generates definitions A and B; Random source provider module: Obtains source random numbers through physical devices or electronic generators. ; Sampling and Calculation Module: Independently and uniformly selects a and b, and calculates... ; Control output module: Outputs S and subsequent mapping parameters or result information.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-8.
