A method for generating pseudo-random sequences for integer data in signal processing
By selecting seeds within the integer data range and using data shift addition instead of multiplication and remnant calculation, the problem of slow generation of linear congruence algorithms is solved, and faster pseudo-random sequence generation and resource saving are achieved, which is suitable for multiple access communications, encryption algorithms and other fields.
Patent Information
- Application Number
- CN202211393917.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-08
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2042-11-08
AI Technical Summary
When the existing linear congruence algorithm generates pseudo-random sequences, multiplication calculation results in slow generation speed, which is difficult to meet the needs of rapidity, and at the same time, resource consumption is high.
A new pseudo-random sequence generation method is adopted to generate pseudo-random sequences by selecting seeds within the integer data range, and using data shift and addition operations instead of multiplication and remnant operations.
It realizes that the generation speed of pseudo-random sequences is faster, the resource consumption is less, and the output sequence period is maintained for a long time, which is suitable for information security fields such as multiple access communications and encryption algorithms.
Smart Images

Figure CN115833796B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of signal processing, and particularly relates to a method for generating pseudo-random sequences for integer data in signal processing. Background Art
[0002] Pseudo-random sequences are widely used in many fields such as information security, signal processing, simulation testing, etc. It is of great significance to study the generation of pseudo-random sequences. Among many methods for generating pseudo-random sequences, the linear congruence algorithm is the simplest and most widely used pseudo-random number generator. The Linear Congruence Generator (LCG for short) has the characteristics of fast generation speed and long output sequence period.
[0003] The iterative formula of the linear congruence algorithm is as follows:
[0004] X j =(a×X j-1 +b)(mod m)
[0005] The algorithm has four parameters: modulus m (m > 0), multiplier a (0 < a < m), increment b (0 < b < m), and seed X0 (0 ≤ X0 < m). {X j} is periodic, and the maximum period is m. To make the period as large as possible, m should be as large as possible.
[0006] To achieve the maximum sequence period, the following conditions must be met:
[0007] (1) b and m are relatively prime;
[0008] (2) (a - 1) is divisible by every prime factor of m;
[0009] (3) If 4 divides m, then (a - 1) should be divisible by 4.
[0010] The multiplication calculation of the linear congruence algorithm is the main factor affecting the generation speed of pseudo-random sequences. When m is as large as possible, it will cause the algorithm to take a long time to run, making it difficult to meet the rapidity requirements in applications. Summary of the Invention
[0011] To overcome the deficiencies of the prior art, the present invention provides a method for generating a pseudo-random sequence for integer data in signal processing. The seed can be arbitrarily selected within the range of integer data. The sequence iteration algorithm does not use multiplication and modulo operations, and the sequence data traverses the entire data range. The present invention simplifies the linear congruence algorithm, making the generation speed of the pseudo-random sequence faster and more resource-saving, while still retaining the characteristic of a long output sequence period. The present invention is applicable to various integer data types and can also be extended to any hexadecimal data with a bit number n≥8. Pseudo-random sequences play an important role in information security fields such as multi-access communication, encryption algorithms, data scrambling, signal synchronization, error code testing, security protocols, digital watermarks, and cryptographic chips.
[0012] The technical solution adopted by the present invention to solve its technical problems includes the following steps:
[0013] Step 1: In signal processing, let the bit number of integer data with modulus m = 2 n be n, and the bit order from high to low is b n-1 、b n-2 ……b1, b0; let k be a natural number satisfying 2≤k≤n / 4;
[0014] Step 2: The pseudo-random sequence {X j} is iteratively generated by the following algorithm:
[0015] Step 2-1: Select a seed X0 between 0 and (2 n -1);
[0016] Step 2-2: Take the b j-1 ……b0 bit data of X n-k-1 , pad k zeros at the low position to form a new n-bit data, add the original value of X j-1 , ignore the highest bit overflow, and store it in X j ;
[0017] Step 2-3: Add an arbitrary integer relatively prime to 2 j as an increment to X n , ignore the highest bit overflow, save and output the value of X j ;
[0018] Step 2-4: Let j increment by 1, and loop from Step 2-2 to Step 2-4;
[0019] Step 3: The period of the obtained pseudo-random sequence {X j} is equal to the modulus m = 2 n .
[0020] Preferably, the type of the integer data is four types of integer data: char, short, int, and long;
[0021] Preferably, the integer data is any hexadecimal data with the number of bits n≥8. In the sequence iteration operation, the signed number is equivalent to the unsigned number, and the sign bit is determined as the highest bit data.
[0022] Preferably, the seed of the pseudo-random sequence is arbitrarily selected within the entire data range, and the iteration algorithm does not use multiplication and modulo operations.
[0023] Preferably, when the parameter k of the pseudo-random sequence iteration algorithm does not satisfy 2≤k≤n / 4, the period of the pseudo-random sequence {X j} is less than the modulus m = 2 n .
[0024] The beneficial effects of the present invention are as follows:
[0025] 1. The algorithm of the present invention is simple, fast, requires few resources for implementation, and has high reliability. In addition to the field of signal processing, it also plays an important role in information security fields such as multiple access communication, encryption algorithms, data scrambling, signal synchronization, error code testing, security protocols, digital watermarks, and cryptographic chips.
[0026] 2. The present invention simplifies the linear congruence algorithm, making the generation speed of the pseudo-random sequence faster and more resource-saving, while still retaining the characteristic of the long period of the output sequence. The present invention is applicable to various integer data types and can also be extended to any hexadecimal data with the number of bits n≥8. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is the pseudo-random number distribution diagram of short integer data (k = n / 4) in the embodiment of the present invention.
[0028] Figure 2 It is the pseudo-random number distribution diagram of short integer data (k>n / 4) in the embodiment of the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0029] The present invention will be further described below in conjunction with the drawings and embodiments.
[0030] The purpose of the present invention is to provide a simple algorithm for generating a pseudo-random sequence. By using the characteristics of integer data, the seed is arbitrarily selected within the integer data range, and the sequence iteration algorithm does not use multiplication and modulo operations. Only the data shift of some bits of the integer data is added to the original data, and the formed integer data is added with an arbitrary integer relatively prime to the modulus.
[0031] A method for generating a pseudo-random sequence for integer data in signal processing, comprising the following steps:
[0032] Let the modulus m = 2 n The number of bits of the integer data is n, and the bit order from high to low is b n-1 , bn-2 ……b1, b0. Let k be a natural number satisfying 2 ≤ k ≤ n / 4.
[0033] The pseudo - random sequence {X j} is iteratively generated by the following algorithm:
[0034] (1) Select a seed X0 between 0 and (2 n - 1);
[0035] (2) Take the b j-1 ...b0 bits of data of X n-k-1 , pad k zeros at the low - order end to form a new n - bit data, add the original value of X j-1 , ignore the highest - order overflow, and store it in X j ;
[0036] (3) Add an arbitrary integer relatively prime to 2 j to X n as an increment, ignore the highest - order overflow, save and output the value of X j ;
[0037] (4) Let j + 1, and loop from (2) to (4).
[0038] The period of the obtained pseudo - random sequence {X j} is equal to the modulus m = 2 n .
[0039] The pseudo - random sequence generation method of the present invention is applicable to four types of integer data: char, short, int, and long, and can also be extended to any hexadecimal data with the number of bit positions n ≥ 8. Signed numbers are equivalent to unsigned numbers in the sequence iteration operation, and the sign bit is considered as the highest - order bit data.
[0040] The pseudo - random sequence seed can be arbitrarily selected within the entire data range, and the iterative algorithm does not use multiplication and modulo operations.
[0041] When the parameter k of the pseudo - random sequence iterative algorithm does not satisfy 2 ≤ k ≤ n / 4, the statistical characteristics of the pseudo - random sequence {X j} may deteriorate, or the period is less than the modulus m = 2 n . Specific embodiments:
[0043] When performing signal processing, taking short - integer (short) data as an example, illustrate the generation of the pseudo - random sequence.
[0044] Regardless of signed or unsigned, the modulus m of short - integer (short) data is 2 16 = 65536, the value range is 0 to 65535, the number of binary bit positions n = 16, and the bit - order from high to low is b 15, b 14 ……b1, b0, occupying a 2-byte register, denoted as DH and DL respectively. The high 8-bit data b 15 , b 14 ……b9, b8 are stored in DH, and the low 8-bit data b7, b6……b1, b0 are stored in DL.
[0045] Let k = n / 4 = 4, then the b n-k-1 ……b0 data bits in DH and DL correspond to b 11 , b 10 ……b1, b0.
[0046] Optionally, the seed is 0 (0x0000H) and the increment is 3 (0x0003H). The generation process of the pseudo-random sequence is as follows:
[0047] (1) The seed 0x0000H is stored in DH and DL;
[0048] (2) Take the 12-bit data of b 11 , b 10 ……b1, b0 in DHDL, fill 4 (k = 4) zeros at the low position to form a new 16-bit data, add the original value of DHDL, ignore the highest-bit overflow, and store it in DHDL;
[0049] (3) DHDL + 0x0003H, ignore the highest-bit overflow, save and output the value of DHDL;
[0050] (4) Loop (2) to (3).
[0051] Table 1 shows the results of the first 500 pseudo-random numbers generated (converted to decimal):
[0052] Table 1
[0053]
[0054] Its distribution diagram is as shown in the appendix Figure 1 as shown.
[0055] When the loop runs 65536 times, the output result is 0, which repeats with the seed. During this period, the sequence data traverses 0 to 65535. Therefore, the cycle period of the pseudo-random sequence described in the present invention can reach the maximum value of 2 16 = 65536.
[0056] If k = 1 < 2 is set, the seed is 0 (0x0000H), and the increment is 3 (0x0003H). Using the above sequence iteration generation method, when the loop runs 32768 times, the output result is 0, which repeats with the seed. The cycle period of the generated random sequence is 32768 and cannot reach the maximum value.
[0057] If we let k = 8 > n / 4, select the seed as 0 (0x0000H), and select the increment as 3 (0x0003H), and use the above sequence iteration generation method, although the cycle period of the generated random sequence can reach the maximum value, the lattice effect is obvious (as shown in Figure 2 the attached figure), the amplitude of the sequence spectrum increases, the frequency doubling components increase, and the statistical characteristics deteriorate.
Claims
1. A method for generating a pseudo-random sequence for integer data in signal processing, characterized in that, Including the following steps: Step 1: In signal processing, assume that the number of bits of the integer data with the analog-to-digital m = 2 n is n , and the bit order from high to low is b n-1 , b n-2 ... b1, b0; assume k is a natural number that satisfies 2 ≤ k ≤ n / 4; the type of the integer data is one of the four types of integer data: char, short, int, and long; the integer data is any hexadecimal data with the number of bits n ≥ 8. A signed number is equivalent to an unsigned number in sequence iteration operations, and the sign bit is determined as the highest-bit data; Step 2: The pseudo-random sequence { X j} is iteratively generated by the following pseudo-random sequence iteration algorithm: Step 2-1: Select a seed between 0 and (2 n -1); X 0; Step 2-2: Take X j-1 's b n-k-1 …… b0-bit data, padded with k zeros at the low position to form a new n bit data, added with X j-1 's original value, ignoring the highest-bit overflow, and stored in X j ; Step 2-3: X j Add an arbitrary integer that is relatively prime to 2 n as an increment, ignore the highest-bit overflow, save and output X j the value; Step 2-4: Let j be incremented by 1, and loop from Step 2-2 to Step 2-4; Step 3: Obtain that the period of the pseudo-random sequence { X j} is equal to the modulus m = 2 n .
2. The pseudo-random sequence generation method for integer data in signal processing according to claim 1, wherein The seed of the pseudo-random sequence is arbitrarily selected within the entire data range, and the iterative algorithm does not use multiplication and modulo operations.
3. A method for generating a pseudo-random sequence for integer data in signal processing according to claim 1, characterized in that, The parameters of the pseudo-random sequence iteration algorithm k do not satisfy 2 ≤ k ≤ n / 4, the period of the pseudo-random sequence { X j} is less than the modulus m = 2 n .
Citation Information
Patent Citations
Generating method and system of floating point random number
CN102981799A
Aperiodic pseudo-random number generator based on a linear congruential generator
US10990355B1