US-12625679-B2 - Method and apparatus for generating random sequences, and device and medium thereof
Abstract
Provided is a method for generating random sequences. The method is applicable to generating a random sequence using a plurality of state machines, any state machine of which is configured to generate an output value. The method includes: selecting, in accordance with a first rule, a state machine from the state machines successively to output a value according to history output values of at least a portion of the state machines; acquiring an output value of each of the state machines; and forming a random sequence from the output values of the state machines according to an output order of the state machines.
Inventors
- XIANGYE WEI
Assignees
- Beijing Boe Technology Development Co., Ltd.
- BOE TECHNOLOGY GROUP CO., LTD.
Dates
- Publication Date
- 20260512
- Application Date
- 20210625
Claims (17)
- 1 . A method for generating random sequences, applicable to generate a random sequences using a plurality of state machines, wherein any state machine of the state machines is configured to generate an output value; the method comprising: selecting, in accordance with a first rule, a state machine from the state machines successively to output an output value according to history output values of at least a portion of the state machines; acquiring the output value of each of the state machines; and forming a random sequence from the output values of the state machines according to an output order of the state machines; and wherein a serial number is assigned to each of the state machines, the serial numbers of the state machines being integer and continuous values; the first rule is configured to calculate an indicator value of a second state machine according to an indicator value of a first state machine and an output value of the first state machine, the second state machine being a next one of the state machines which outputs a value following the first state machine; and selecting, in accordance with the first rule, the state machine from the state machines successively to output the output value according to the history output values of the at least a portion of the state machines comprises: calculating the indicator value of the second state machine using the first rule based on the indicator value of the first state machine and the output value of the first state machine; determining a serial number of the second state machine based on the indicator value of the second state machine; and controlling the second state machine to output the output value according to the serial number of the second state machine.
- 2 . The method according to claim 1 , wherein calculating the indicator value of the second state machine using the first rule based on the indicator value of the first state machine and the output value of the first state machine comprises: acquiring the indicator value of the second state machine by performing a Mod K operation on a sum of three portions, wherein the three portions comprise the indicator value of the first state machine, a product of the output value of the first state machine and a first parameter value, and a second parameter value; wherein K represents a quantity of the state machines, the first parameter value is greater than 0 and less than 1, the second parameter value is an integer, and the second parameter value ranges within [2, 2K−1].
- 3 . The method according to claim 2 , wherein determining the serial number of the second state machine based on the indicator value of the second state machine comprises: assigning an integer portion of the indicator value of the second state machine as the serial number of the second state machine.
- 4 . The method according to claim 1 , further comprising: controlling the state machines to stop outputting values when a boundary condition is satisfied; wherein the boundary condition comprises: one history indicator value in a set of the history indicator values being equal to an indicator value of the state machine currently outputting the value.
- 5 . The method according to claim 4 , wherein the quantity of the state machines is 2 t , wherein t is a positive integer.
- 6 . The method according to claim 1 , wherein a first value or a second value is selected as the output value to output the value at a first output.
- 7 . A computer device for generating random sequences, comprising a processor and a memory; wherein the memory is configured to store computer programs; and the processor is configured to perform, when executing the computer programs stored in the memory, the method as defined in claim 1 .
- 8 . A non-transitory computer-readable storage medium storing computer instructions therein, wherein the computer instructions, when executed by a processor, cause the processor to perform the method as defined in claim 1 .
- 9 . The computer device for generating random sequences according to claim 7 , wherein calculating the indicator value of the second state machine using the first rule based on the indicator value of the first state machine and the output value of the first state machine comprises: acquiring the indicator value of the second state machine by performing a Mod K operation on a sum of three portions, wherein the three portions comprise the indicator value of the first state machine, a product of the output value of the first state machine and a first parameter value, and a second parameter value; wherein K represents a quantity of the state machines, the first parameter value is greater than 0 and less than 1, the second parameter value is an integer, and the second parameter value ranges within [2, 2K−1].
- 10 . The computer device for generating random sequences according to claim 9 , wherein determining the serial number of the second state machine based on the indicator value of the second state machine comprises: assigning an integer portion of the indicator value of the second state machine as the serial number of the second state machine.
- 11 . The computer device for generating random sequences according to claim 7 , further comprising: controlling the state machines to stop outputting values when a boundary condition is satisfied; wherein the boundary condition comprises: one history indicator value in a set of the history indicator values being equal to an indicator value of the state machine currently outputting the value.
- 12 . The computer device for generating random sequences according to claim 11 , wherein the quantity of the state machines is 2 t , wherein t is a positive integer.
- 13 . The computer device for generating random sequences according to claim 7 , wherein a first value or a second value is selected as the output value to output the value at a first output.
- 14 . The non-transitory computer-readable storage medium according to claim 8 , wherein calculating the indicator value of the second state machine using the first rule based on the indicator value of the first state machine and the output value of the first state machine comprises: acquiring the indicator value of the second state machine by performing a Mod K operation on a sum of three portions, wherein the three portions comprise the indicator value of the first state machine, a product of the output value of the first state machine and a first parameter value, and a second parameter value; wherein K represents a quantity of the state machines, the first parameter value is greater than 0 and less than 1, the second parameter value is an integer, and the second parameter value ranges within [2, 2K−1].
- 15 . The non-transitory computer-readable storage medium according to claim 14 , wherein determining the serial number of the second state machine based on the indicator value of the second state machine comprises: assigning an integer portion of the indicator value of the second state machine as the serial number of the second state machine.
- 16 . The non-transitory computer-readable storage medium according to claim 8 , further comprising: controlling the state machines to stop outputting values when a boundary condition is satisfied; wherein the boundary condition comprises: one history indicator value in a set of the history indicator values being equal to an indicator value of the state machine currently outputting the value.
- 17 . The non-transitory computer-readable storage medium according to claim 16 , wherein the quantity of the state machines is 2 t , wherein t is a positive integer.
Description
CROSS-REFERENCE TO RELATED APPLICATION The present disclosure is a U.S. national stage of international application No. PCT/CN2021/102482, filed on Jun. 25, 2021, the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD The present disclosure refers to a method and apparatus for generating random sequences, and a device and a medium thereof. BACKGROUND ART Random sequences may be applied in the field of information encryption or the like. In the related art, a random sequence may be generated using a plurality of state machines. Each of the state machines may output 0 or 1 randomly, and the state machines output values in a fixed order. The output values of the state machines constitute the random sequence. SUMMARY Embodiments of the present disclosure provide a method and apparatus for generating random sequences, and a device and a medium thereof. In a first aspect, the embodiments of the present disclosure provide a method of random sequence generation. The method is applicable to generating a random sequence using a plurality of state machines, wherein any of the state machines is configured to generate an output value. The method includes: selecting, in accordance with a first rule, a state machine from the state machines successively to output a value according to history output values of at least a portion of the state machines; acquiring an output value of each of the state machines; and forming a random sequence from the output values of the state machines according to an output order of the state machines. In one implementation of the embodiments of the present disclosure, a serial number is assigned to each of the state machines, and the serial numbers of the state machines are integer and consecutive numbers. The first rule is configured to calculate an indicator value of a second state machine according to an indicator value of a first state machine and an output value of a first state machine. The second state machine is a next one of the state machines which outputs a value following the first state machine. In one implementation of the embodiments of the present disclosure, selecting, in accordance with the first rule, the state machine from the state machines successively to output the value according to history output values of the at least the portion of the state machines includes: calculating the indicator value of the second state machine using the first rule based on the indicator value of the first state machine and the output value of the first state machine; determining a number of the second state machine based on the indicator value of the second state machine; controlling the second state machine to output the value according to the serial number of the second state machine. In one implementation of the embodiments of the present disclosure, calculating the indicator value of the second state machine using the first rule based on the indicator value of the first state machine and the output value of the first state machine includes: acquiring the indicator value of the second state machine by performing a Mod K operation on a sum of the indicator value of the first state machine, the product of the output value of the first state machine and a first parameter value, and a second parameter value. K represents a quantity of the state machines, the first parameter value is greater than 0 and less than 1, the second parameter value is an integer, and the second parameter value ranges within [2, 2K−1]. In one implementation of the embodiments of the present disclosure, determining the serial number of the second state machine based on the indicator value of the second state machine, includes: assigning an integer portion of the indicator value of the second state machine as the serial number of the second state machine. In one implementation of the embodiments of the present disclosure, the method further includes controlling the state machines to stop outputting values when a boundary condition is satisfied. The boundary condition includes: one history indicator value in a set of history indicator values being equal to an indicator value of the state machine currently outputting the value. In one implementation of the embodiments of the present disclosure, the quantity of the state machines is 2t, wherein t is a positive integer In one implementation of the embodiments of the present disclosure, each of the state machines randomly selects one of a first value and a second value as the output value to output the value at a first output. In a second aspect, the embodiments of the present disclosure provide an apparatus for generating random sequences. The apparatus includes: a state module, a selecting module, an acquiring module, and a generating module. The state module includes a plurality of state machines, wherein any state machine of the state machines is configured to generate an output value. The selecting module is configured to select, in acc