WO2018040921A1 - 计算机系统中随机数的生成方法及装置 - Google Patents
计算机系统中随机数的生成方法及装置 Download PDFInfo
- Publication number
- WO2018040921A1 WO2018040921A1 PCT/CN2017/097779 CN2017097779W WO2018040921A1 WO 2018040921 A1 WO2018040921 A1 WO 2018040921A1 CN 2017097779 W CN2017097779 W CN 2017097779W WO 2018040921 A1 WO2018040921 A1 WO 2018040921A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- random
- determining
- random numbers
- random number
- amount
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F7/00—Methods or arrangements for processing data by operating upon the order or content of the data handled
- G06F7/58—Random or pseudo-random number generators
- G06F7/588—Random number generators, i.e. based on natural stochastic processes
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F7/00—Methods or arrangements for processing data by operating upon the order or content of the data handled
- G06F7/58—Random or pseudo-random number generators
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F7/00—Methods or arrangements for processing data by operating upon the order or content of the data handled
- G06F7/58—Random or pseudo-random number generators
- G06F7/582—Pseudo-random number generators
Definitions
- the present application relates to the field of computer technology, and in particular, to a method and an apparatus for generating a random number in a computer system.
- the specified number of random numbers are often randomly generated by calling a random function.
- the above random numbers are randomly generated, they cannot be effectively controlled (eg, , controlled within a certain range), which may result in a problem of uneven distribution of a specified number of random numbers generated.
- the "red envelope amount” randomly generated by the payment server may be very large or very small (for example, 0.01), which may bring a poor experience to the user.
- the present application describes a method and apparatus for generating a random number in a computer system, which can implement effective control of the generated random number.
- a method for generating a random number in a computer system comprising:
- each subset includes one or two random numbers, and when the subset includes two random numbers, the sum of the two random numbers is Two times the average, and the quotient of the two random numbers is a preset threshold;
- a device for generating a random number in a computer system comprising:
- a receiving unit configured to receive a first request, where the first request includes a sum of a random number to be generated and a number;
- a determining unit configured to determine an average according to the sum received by the receiving unit and the number
- a dividing unit configured to divide the random number of the number to be generated into multiple subsets, wherein each subset Combining one or two random numbers, when the subset includes two random numbers, the sum of the two random numbers is twice the average, and the quotient of the two random numbers is a preset threshold;
- the determining unit is further configured to determine one or two random numbers in each of the plurality of subsets, thereby obtaining the number of random numbers.
- the method and device for generating a random number in a computer system provided by the present application firstly divide a random number to be generated into a plurality of subsets when receiving the first request, and specify two when the subset includes two random numbers.
- the sum of the random numbers is twice the average, and the quotient of the two random numbers is a preset threshold; then one or two random numbers included in each subset are sequentially determined, thereby obtaining a specified number of random numbers;
- the purpose of controlling the generated random number is achieved.
- FIG. 1 is a flowchart of a method for generating a random number in a computer system according to an embodiment of the present application
- FIG. 2 is a flowchart of a method for determining a random number in a subset provided by the present application
- FIG. 3 is a schematic diagram of an application scenario of a method for generating a random number in a computer system according to the present application
- FIG. 4 is a flow chart of a method for generating a red envelope amount in the scenario shown in FIG. 3;
- FIG. 5 is a flow chart of a method for generating another red envelope amount in the scenario shown in FIG. 3;
- FIG. 6 is a schematic diagram of a device for generating a random number in a computer system according to an embodiment of the present application.
- the method and device for generating a random number in a computer system are applicable to a scenario for generating a random number when the sum of the random numbers to be generated and the number of random numbers are fixed; in particular, the sum of the random numbers to be generated and When the number is fixed, a scene with a uniformly distributed random number is generated.
- FIG. 1 is a flowchart of a method for generating a random number in a computing system according to an embodiment of the present application.
- the executor of the method may be a device with processing capability: a server or a system or a device, such as a server of the payment system. As shown in FIG. 1 , the method may specifically include:
- Step 110 Receive a first request.
- the first request may be any request for instructing the server or the system or the device to generate a random number.
- the first request may include a sum of random numbers to be generated, a number of random numbers to be generated, and the like.
- step 120 the average is determined according to the sum and the number.
- Step 130 Divide the number of random numbers to be generated into a plurality of subsets.
- Each sub-set includes one or two random numbers.
- the sum of the two random numbers is twice the average, and the quotient of the two random numbers is a preset threshold.
- the number of sub-sets may be determined according to the number of random numbers to be generated.
- the number of sub-sets may be calculated according to the following formula: INT (number/2) or INT (number/2)+1, wherein INT() is a rounding function, that is, it is used to obtain an integer part of a data.
- INT number/2
- INT number/2+1
- INT() is a rounding function, that is, it is used to obtain an integer part of a data.
- each of the subsets may include two random numbers; and in the case where the number of random numbers to be generated is an odd number, At least one subset contains only one random number.
- the number of random numbers to be generated is 10
- the sum of the two random numbers is twice the average, and the quotient of the two random numbers is a preset threshold.
- S 1 and S 2 respectively represent two random numbers in the subset
- AVG is the above average
- GAP refers to the above preset threshold, which can be determined according to actual needs.
- the two sub-sets may also be specified.
- the sum of the number of machines is twice the average, and the quotient of the two random numbers is a preset threshold.
- the two random numbers may also constitute the second formula as shown in the above formula 1. Yuan once equation.
- each random number is The intermediate area is relatively average, that is, each random number is within the range divided by the average number, thereby ensuring that the generated random number distribution is relatively uniform.
- Step 140 Determine one or two random numbers in each of the plurality of subsets, thereby obtaining the number of random numbers.
- the number of random numbers to be generated is an even number
- two random numbers in each sub-set can be determined according to formula 1; after determining two random numbers in each sub-set, the obtained The random number of the number; as in the foregoing example, after determining each of the five sub-sets, 10 random numbers can be obtained.
- the one random number may be determined according to the average number.
- the average number may be randomly attenuated as the above random number, or may pass The other method determines, for example, directly using the average number as the above random number, which is not limited in this application.
- Step 210 Determine a cycle period according to the number of random numbers to be generated.
- the cycle period can be determined according to Equation 2.
- Interval is the cycle period and count is the number of random numbers to be generated.
- Step 220 Determine an allocation factor according to a preset threshold.
- the allocation factor can be determined according to Equation 3.
- the primary is the allocation factor and the GAP is the preset threshold.
- Step 230 determining a maximum phase difference multiple based on the average and the distribution factor.
- the maximum phase difference multiple can be determined according to Equation 4.
- top is the maximum difference multiple
- AVG is the average
- primer is the distribution factor
- Math.min() is the most A small value function, for example, compares the size of two numbers (AVG*primer) with (2*AVG-1) and then takes the smallest number as the maximum difference multiple.
- step 240 the step is determined according to the maximum phase difference multiple, the average number, and the cycle period.
- the step can be determined according to Equation 5.
- stepM (top-AVG)/Interval (Equation 5)
- stepM is the step
- top is the maximum difference multiple
- AVG is the average
- Interval is the cycle.
- Step 250 determining an offset range of the random number according to the step.
- the offset range of the random number can be determined according to Equation 6.
- Ri is the offset range
- stepM is the step
- random.nextInt(25) is a random function that randomly selects any integer between 0-25.
- Ri can be determined as [0, 1/30*stepM] , that is, the offset range is [0, 1/30*stepM].
- Step 260 determining a first offset within the offset range.
- the first offset herein may refer to any value randomly selected from within the offset range [0, 1/30*stepM].
- Step 270 Determine a first random number of the two random numbers according to the maximum phase difference multiple, the step, the current step size, and the first offset.
- the first of the two random numbers can be determined according to Equation 7.
- S 1 is a first random number of two random numbers
- the first random number may refer to a larger random number of two random numbers
- top is a maximum phase difference multiple
- stepGo is a current step size, when determining When the first random number in a subset is set, stepGo can be 0. Then, when determining the first random number in the second subset, stepGo can be 1, that is, incrementing by 1 each time, and so on
- stepM is Step difference
- ri is the first offset.
- Step 280 Determine a second random number of the two random numbers according to the average number and the first random number.
- the second of the two random numbers can be determined according to Equation 8.
- S 2 is a second random number of two random numbers, and the second random number may refer to a smaller random number of two random numbers; AVG is an average; S 1 is a number of two random numbers A random number.
- the random number can be determined by the following steps:
- a random number in the second subset is determined according to the average of the random attenuation and the preset minimum random number.
- the second subset here may refer to any subset that includes only one random number.
- one of the second subsets may be determined according to Equation 9.
- S 1 is a random number in the second subset;
- MIN is a preset minimum random number, for example, may be 0.01;
- AVG is an average;
- FLUCTUATION may be a preset constant, which may be desired The value of the mean decay;
- Math.max() is the maximum function, for example, it compares the size of MIN and (AVG-1-random.nextInt(FLUCTUATION)), and then takes the largest number as the first A random number in a set of two children.
- step 140 it can be understood that one or two random numbers in each sub-set are determined in accordance with a determination method of one or two random numbers in one subset (for example, each step in FIG. 2). After that, the random number of the number can be obtained.
- step 140 after performing step 140, the following steps may also be performed:
- Step A Determine the remaining number based on the sum and the random number of the number.
- the sum of the random numbers of the numbers obtained according to the conventional method or the steps in FIG. 2 is often not equal to the sum.
- the sum of the red envelope amount of the red envelope number that is, the sum of the amount of the "red envelope” sent is not equal to the total amount of the red envelope, thereby causing the problem of capital loss.
- the remaining number may be determined according to the sum and the random number of the number.
- the remaining number may be determined by calculating the difference between the sum and the random number of the number. As in the foregoing example, in the case where the total amount of the red envelope is 100 yuan, assuming that the sum of the 10 red envelope amounts is 90 yuan, the remaining amount is 10 yuan.
- the remaining number can also be determined at the time of performing the steps of FIG. 2, whereby the determination efficiency of the remaining number can be improved.
- the remaining numbers may be initialized to a sum, and after each determination of one or two random numbers in a subset, the remaining number is updated to the difference between the remaining number and a random number, or The remaining number is updated to the difference between the remaining number and the sum of the two random numbers. It can be understood that after the random number determination in all the sub-sets is completed, the updated remaining number is the final remaining number.
- Step B Split the remaining number.
- the remaining number can be split into the number of sub-data.
- the sub-data obtained after the splitting may be 10 one yuan.
- the remaining number may be divided into other sub-data, and each sub-data may be different, which is not limited in this application.
- Step C superimposing the remaining number after the split into the random number of the number to obtain the updated random number of the number.
- the number of random numbers to be generated is 10, and the obtained 10 random numbers are: 1.2, 0.7, 1.1, 0.8, 1.3, 0.6, 1.5, 0.4, 1.0, and 0.9, respectively.
- the remaining number can be: 0.5; the remaining number 0.5 is divided into 10 0.05; then the updated 10 random numbers can be: 1.25, 0.75, 1.15, 0.85, 1.35, 0.65, 1.55, 0.45, 1.05, and 0.95.
- the loss of funds can be avoided by superimposing the remaining amount after the split into the red envelope amount of the red envelope number.
- step 140 after performing step 140, or after performing step C, the following steps may also be performed:
- Step X Reorder the random numbers of the number.
- the number of random numbers may be reordered in an arbitrary order to prevent each random number from being stored in order of size; in addition, it is also ensured that the sum and the number of random numbers to be generated are the same. In the following, the order of the random numbers of the number divided by two or more consecutive times is inconsistent.
- Step Y Store the random number of the reordered number into the list.
- the number of random numbers of the reordered number may also be stored in other types of storage units, which is not limited in this application.
- random number of the number in the above steps X and Y may also refer to the random number of the number of the remaining number after the split.
- FIG. 3 includes a sender client and multiple receiver clients.
- the sender client is configured to send a "red packet” to receive the notification
- the receiver client is configured to perform the corresponding "red packet” collection operation according to the "red packet” notification sent by the sender client.
- the sender client may include two types. : First, the Alipay client can send a "red envelope" to receive the notification in the group.
- the group can be established by the following steps: Address Book -> Group Chat -> Select Group Type (eg, Entertainment Group) -> Select User Second, the sender user can transfer to the red envelope generation interface by triggering the "red envelope” text or the corresponding "red envelope” pattern in the "Alipay” application interface; in the red envelope generation interface, the sender user inputs the password, and Enter “Total Amount” and “Red Packets” in the selected group type, then click on "Red Packet” After that, you can complete the delivery of the "red envelope” collection notice. It can be understood that the "red envelope” receiving notification sent by the above two methods may include information such as “total amount” and "red envelope number".
- the server may receive the first request, where the first request may include the total amount of the red envelope and the number of red packets to be sent, and then the server may receive the red envelope.
- the red packet amount of the red packet number is divided into the total amount; when the server receives the "red packet" receiving request sent by the receiving client, that is, when the receiving user receives the red envelope, one of the red packet amount is allocated to the receiving client. end.
- each red packet amount is usually randomly generated, and the amount of the red packet randomly generated by the server may be very large or may be very small (for example, 0.01), that is, There is a problem that the red envelope amount is uncontrollable.
- the method for generating a random number in the computer system of the present application When the method for generating a random number in the computer system of the present application is applied to the scenario shown in FIG. 3, the problem that the amount of the red envelope is uncontrollable can be solved.
- the method for generating a random number in the computer system of the present application when the method for generating a random number in the computer system of the present application is applied to the scenario shown in FIG. 3, the sum of the random numbers to be generated is equivalent to the total amount of the red packets, and the number of random numbers to be generated is equivalent to The number of the red packets to be sent, the random number is equivalent to the red packet amount, and the method for generating the random number may be a method for generating the red packet amount, wherein FIG. 4 provides a method for generating a red envelope amount. In FIG. 4, the method may specifically include the following step:
- Step 410 The server receives the first request sent by the sender client.
- the first request may include the total amount of red packets and the number of red packets to be sent.
- Step 420 Determine an average distribution amount according to the total amount of the red envelope and the number of red packets.
- Step 430 The red packet amount of the red packet number to be generated is divided into a plurality of red packet amount sub-sets.
- each red envelope amount sub-set includes one or two red envelope amounts.
- the red envelope amount subset includes two red envelope amounts
- the sum of the two red envelope amounts is twice the average distribution amount, and the quotient of the two red envelope amounts is Preset threshold.
- the number of red packet amount sub-sets may be determined according to the number of red packets to be sent.
- the number of red packets amount subsets may be calculated according to the following formula: INT (red packet number/2) or INT (red packet number/2)+1.
- INT() is a rounding function, that is, it is used to obtain an integer part of a data.
- the number of red packets amount subsets can be determined according to the formula: INT (red packet number/2)
- the number of red packets amount sub-sets can be determined according to the formula INT (red packet number/2)+1. Understand
- each red packet amount sub-set may include two red packets; and in the case where the number of red packets is odd, at least one red packet amount subset includes only one red packet amount. .
- the number of red packets to be sent is 10
- the number of red packets is even
- the sub-set of 5 red packet amounts obtained by dividing, when each red packet amount sub-set includes two red packet amounts, it may be specified that the sum of the two red packet amounts is twice the average distribution amount, and the two red packets amount
- the quotient is a preset threshold.
- the two red envelope amounts can constitute a binary one-time equation as shown in Formula 1.
- the sum of the two red packet amounts may be specified as an average distribution.
- the amount of the two red packets is twice the amount, and the quotient of the two red packets is a preset threshold.
- the two red packets may also constitute a binary one-time equation as shown in Equation 1.
- the purpose of controlling the difference between the two red packet amounts in the same red packet amount subset can be achieved.
- the amount of each red envelope is relatively average in the middle area, that is, the amount of each red envelope is within the range divided by the average distribution amount, thereby ensuring that the amount of the red envelope allocated by each recipient client is relatively average, that is, it can be guaranteed.
- the amount of "red envelope" allocated by the recipient user is relatively average, which can enhance the user's experience.
- Step 440 Determine one or two red packet amounts in each of the red packet amount subsets of the plurality of red packet amount subsets, thereby obtaining the red packet amount of the red packet amount.
- red envelope amount subset In the case that the number of red packets is even, according to formula 1, two red packets in each red envelope amount subset can be determined; after determining the two red packets in each red packet amount subset, the number of red packets can be obtained.
- the red envelope amount as in the foregoing example, after determining the amount of each red envelope in the five red envelope amount subsets, 10 red envelope amounts can be obtained.
- the one red envelope amount may be determined according to the average allocated amount. For example, the average allocated amount may be randomly attenuated as the above-mentioned one red envelope amount.
- the red envelope amount sub-set includes two red envelope amounts
- the above only gives a method for determining the two red envelope amounts.
- two of the red envelope amount subsets One The red envelope amount can also be determined by the steps shown in FIG. 2; that is, only the average number in each step shown in FIG. 2 is replaced with the average assigned amount, and the random number is replaced with the red envelope amount.
- the server determines the amount of one or two red packets in each subset of the red packet amount according to the method for determining the amount of one or two red packets in a red packet amount subset (for example, each step in FIG. 2).
- the red envelope amount of the red envelope number for example, each step in FIG. 2.
- step 440 After performing step 440, the following steps may also be performed:
- Step a Determine the remaining amount based on the total amount of the red envelope and the amount of the red envelope.
- the remaining amount may be determined according to the total amount of the red envelope and the red envelope amount of the red envelope number. For example, the remaining amount may be determined by calculating the difference between the sum of the total amount of the red envelope and the red envelope amount of the red envelope amount. As in the foregoing example, in the case where the total amount of the red envelope is 100 yuan, assuming that the sum of the 10 red envelope amounts is 90 yuan, the remaining amount is 10 yuan.
- the remaining amount can also be determined at the time of performing the steps of FIG. 2, whereby the determination efficiency of the remaining amount can be improved.
- the remaining amount may be initialized to the total amount of the red envelope, and after each determination of one or two red envelope amounts in a subset of the red envelope amount, the remaining amount is updated to the difference between the remaining amount and a red envelope amount. Value, or update the remaining amount to the difference between the remaining amount and the two red envelope amounts. It can be understood that after the red envelope amount in all the red envelope amount subsets is determined to be completed, the updated remaining amount is the final surplus. Amount.
- Step b Split the remaining amount.
- the remaining amount can be split into sub-data of the number of red packets.
- the sub-data obtained after the splitting may be 10 one yuan.
- the remaining amount may be split into other sub-data, and each sub-data may be different, which is not limited in this application.
- Step c superimpose the remaining amount after the split into the red envelope amount of the red envelope quantity, and obtain the red envelope amount of the updated red envelope quantity.
- the remaining amount can be: 0.5; the remaining amount of 0.5 is divided into 10 0.05; then the updated 10 red packets can be: 1.25, 0.75, 1.15, 0.85, 1.35, 0.65, 1.55, 0.45, 1.05 and 0.95.
- Loss of funds can be avoided by superimposing the remaining amount after the split into the red envelope amount of the red envelope quantity.
- step 440 or after performing step C, the following steps may also be performed:
- Step x Reorder the red packet amount of the red packet number.
- the red packet amount of the red packet number may be reordered in an arbitrary order to avoid storing the red packet amount in order of size; in addition, it is ensured that the total amount of the red packet and the number of red packets are the same, twice or more consecutively The order of the red envelope amount of the divided red packets is inconsistent.
- Step y Store the red packet amount of the redected red packets into the list.
- the amount of red packets of the number of red packets after reordering may be stored in other forms of storage units, which is not limited in this application.
- red packet amount of the red packet number in the above steps x and y may also refer to the red packet amount of the updated red packet number.
- Step 450 Receive a second request sent by the receiver client.
- the second request may include an identification of the recipient user (eg, account information of the recipient user, etc.).
- Step 460 According to the second request, allocate the target amount in the red packet amount of the red packet amount to the recipient client.
- the target amount here may refer to any red envelope amount of the red envelope amount of the red envelope quantity, or may also refer to any red envelope amount of the red envelope amount of the updated red envelope quantity.
- the server may read the target amount from the list; and then allocate the target amount to the recipient client.
- the present application provides the following specific embodiments.
- FIG. 5 is a flow chart of a method for generating another red envelope amount in the scenario shown in FIG. 3. As shown in FIG. 5, the method may specifically include:
- Step 510 Receive a first request sent by a sender client.
- the minimum allocated amount (eg, 0.01 yuan) may be preset before receiving the first request.
- the first request may include a total amount of red packets and a number of red packets.
- step 520 it is determined whether the number of red packets is 1 or not. If yes, step 530 is performed; if not, step 540 is performed.
- step 530 the total amount of the red envelope is put into the list.
- step 540 it is determined whether the total amount of the red envelope is the number of red packets * the preset minimum allocated amount, and if yes, step 550 is performed; if not, step 560 is performed.
- Step 550 using an average allocation algorithm to divide the total amount of the red envelope into the minimum allocated amount of the number of red packets, and It is placed in the list.
- Step 560 Calculate an average allocation amount, a maximum difference multiple, a step, and an offset range of the red envelope amount, and initialize the remaining amount to the total amount of the red envelope.
- the calculation method of the average allocation amount may refer to step 120 or 420
- the maximum difference multiple, the step difference, and the offset range of the red envelope amount may refer to step 210 to step 250, and details are not described herein.
- step 570 it is determined whether the red packet amount of the red packet number has been determined. If not, step 580 is performed, and if yes, step 5160 is performed.
- step 580 it is determined whether the currently determined red packet amount is the last red packet amount. If yes, step 590 is performed; if not, step 5120 is performed.
- step 590 the average allocated amount is randomly attenuated.
- Step 5100 Determine the last red envelope amount according to the average allocated amount after the random attenuation and the preset minimum allocated amount.
- step 5110 the last red envelope amount is added to the list, and the remaining amount is updated to the difference between the remaining amount and the last red envelope amount.
- Step 5120 randomly selecting any value from the offset range calculated in step 560 as the current offset.
- Step 5130 Calculate a red envelope amount according to the maximum phase difference multiple, the step, the first offset, and the current step size calculated in step 560.
- the calculation method of a red envelope amount may refer to step 370.
- Step 5140 Calculate another red envelope amount according to the average allocated amount and a red envelope amount.
- the calculation method of another red envelope amount may refer to step 380.
- step 5150 the remaining amount is updated to the difference between the remaining amount and the sum of the two red envelope amounts, and one red envelope amount and another red envelope amount are added to the list.
- step 5160 it is determined whether the remaining amount is greater than 0. If yes, step 5170 is performed; if not, step 5180 is performed.
- step 5170 the remaining amount is split; the remaining amount after the split is superimposed into the red packet amount of the red packet quantity, and the red packet amount of the updated red packet quantity is obtained.
- the method of splitting the remaining amount and the method of superimposing the remaining amount after splitting may refer to step B-step C or step b-step c.
- step 5180 the red packet amount of the red packet number or the red packet amount of the updated red packet number is reordered.
- Step 5190 Receive a second request sent by the receiver client.
- step 5200 the target amount in the red packet amount of the red packet number or the red packet amount of the updated red packet number is allocated to the recipient client.
- the red packet amount of the red packet number can be prevented from being stored in order of size.
- the method for generating the random number in the computer system proposed by the present application is not limited to the scenario in which the red envelope is sent, and may be applied to other scenarios, such as the amount of the merchant activity, which is not limited in this application.
- the embodiment of the present application further provides a device for generating a random number in a computer system, as shown in FIG. 6, the device includes:
- the receiving unit 601 is configured to receive a first request, where the first request includes a sum and a number of random numbers to be generated.
- the determining unit 602 is configured to determine an average number according to the sum and the number received by the receiving unit 601.
- the dividing unit 603 is configured to divide the random number of the number to be generated into multiple subsets, where each subset includes one or two random numbers, and when the subset includes two random numbers, the sum of the two random numbers It is twice the average and the quotient of the two random numbers is the preset threshold.
- the determining unit 602 is further configured to determine one or two random numbers in each of the plurality of subsets, thereby obtaining the random number of the number.
- the determining unit 602 is further configured to determine a cycle period according to the number of times;
- the step difference is determined according to the maximum phase difference multiple, the average number, and the cycle period;
- the determining unit 602 is specifically configured to:
- a second random number of the two random numbers is determined based on the average and the first random number.
- the determining unit 602 is further configured to perform random attenuation on the average number
- a random number in the second subset is determined according to the average of the random attenuation and the preset minimum random number.
- the device further includes: a splitting unit 603 and a superimposing unit 604.
- the determining unit 602 is further configured to determine a remaining number according to the sum and the random number of the number;
- a splitting unit 603, configured to split the remaining number determined by the determining unit 602;
- the superimposing unit 604 is configured to superimpose the remaining number after the splitting unit 603 is split into the random number of the number to obtain the updated random number of the number.
- the device further includes:
- a sorting unit 605, configured to reorder the random numbers of the number
- the storage unit 606 is configured to store the random number of the number after the sorting unit 605 is reordered into the list.
- the receiving unit 601 receives the first request, the first request includes a sum and a number of random numbers to be generated, and the determining unit 602 determines the average according to the sum and the number.
- the numbering unit 603 divides the number of random numbers to be generated into a plurality of subsets; the determining unit 602 determines one or two random numbers in each of the plurality of subsets, thereby obtaining the number of random numbers. This achieves the purpose of controlling the generated random number.
- the functions described herein can be implemented in hardware, software, firmware, or any combination thereof.
- the functions may be stored in a computer readable medium or transmitted as one or more instructions or code on a computer readable medium.
Landscapes
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- Mathematical Analysis (AREA)
- General Engineering & Computer Science (AREA)
- Computational Mathematics (AREA)
- Information Transfer Between Computers (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
- Indexing, Searching, Synchronizing, And The Amount Of Synchronization Travel Of Record Carriers (AREA)
- Mobile Radio Communication Systems (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Complex Calculations (AREA)
Abstract
Description
Claims (10)
- 一种计算机系统中随机数的生成方法,其特征在于,该方法包括:接收第一请求,所述第一请求包括待生成的随机数的总和以及个数;根据所述总和以及所述个数,确定平均数;将待生成的所述个数的随机数划分为多个子集合,其中,每个子集合包括一个或两个随机数,当子集合包括两个随机数时,所述两个随机数之和为所述平均数的两倍,且所述两个随机数之商为预设阈值;确定所述多个子集合中每个子集合中的一个或两个随机数,从而得到所述个数的随机数。
- 根据权利要求1所述的方法,其特征在于,当所述多个子集合中的第一子集合包括两个随机数时,在确定所述第一子集合中的两个随机数之前,所述方法还包括:根据所述个数,确定循环周期;根据所述预设阈值,确定分配因子;根据所述平均数以及所述分配因子,确定最大相差倍数;根据所述最大相差倍数、所述平均数以及所述循环周期,确定步差;根据所述步差,确定随机数的偏移范围;所述确定所述第一子集合中的两个随机数,包括:确定在所述偏移范围内的第一偏移量;根据所述最大相差倍数、所述步差、当前步长以及所述第一偏移量,确定所述两个随机数中的第一随机数;根据所述平均数以及所述第一随机数,确定所述两个随机数中的第二随机数。
- 根据权利要求1所述的方法,其特征在于,当所述多个子集合中的第二子集合包括一个随机数时,所述确定所述第二子集合中的一个随机数,包括:对所述平均数进行随机衰减;根据随机衰减后的平均数以及预设的最小随机数,确定所述第二子集合中的一个随机数。
- 根据权利要求1-3任一项所述的方法,其特征在于,所述方法还包括:根据所述总和以及所述个数的随机数,确定剩余数;对所述剩余数进行拆分;将拆分后的剩余数叠加至所述个数的随机数中,得到更新后的所述个数的随机数。
- 根据权利要求1-4任一项所述的方法,其特征在于,在所述得到所述个数的随机数之后,所述方法还包括:对所述个数的随机数进行重排序;将重排序后的所述个数的随机数存储到列表中。
- 一种计算机系统中随机数的生成装置,其特征在于,该装置包括:接收单元,用于接收第一请求,所述第一请求包括待生成的随机数的总和以及个数;确定单元,用于根据所述接收单元接收的所述总和以及所述个数,确定平均数;划分单元,用于将待生成的所述个数的随机数划分为多个子集合,其中,每个子集合包括一个或两个随机数,当子集合包括两个随机数时,所述两个随机数之和为所述平均数的两倍,且所述两个随机数之商为预设阈值;所述确定单元,还用于确定所述多个子集合中每个子集合中的一个或两个随机数,从而得到所述个数的随机数。
- 根据权利要求6所述的装置,其特征在于,当所述子集合中包括两个随机数时,所述确定单元,还用于根据所述个数,确定循环周期;根据所述预设阈值,确定分配因子;根据所述平均数以及所述分配因子,确定最大相差倍数;根据所述最大相差倍数、所述平均数以及所述循环周期,确定步差;根据所述步差,确定随机数的偏移范围;所述确定单元具体用于:确定在所述偏移范围内的第一偏移量;根据所述最大相差倍数、所述步差、当前步长以及所述第一偏移量,确定所述两个随机数中的第一随机数;根据所述平均数以及所述第一随机数,确定所述两个随机数中的第二随机数。
- 根据权利要求6所述的装置,其特征在于,当所述子集合中包括一个随机数时,所述确定单元,还用于对所述平均数进行随机衰减;根据随机衰减后的平均数以及预设的最小随机数,确定所述子集合中的一个随机数。
- 根据权利要求7-8任一项所述的装置,其特征在于,所述装置还包括:所述确定单元,还用于根据所述总和以及所述个数的随机数,确定剩余数;拆分单元,用于对所述确定单元确定的所述剩余数进行拆分;叠加单元,用于将所述拆分单元拆分后的剩余数叠加至所述个数的随机数中,得到更新后的所述个数的随机数。
- 根据权利要求7-9任一项所述的装置,其特征在于,所述装置还包括:排序单元,用于对所述个数的随机数进行重排序;存储单元,用于将所述排序单元重排序后的所述个数的随机数存储到列表中。
Priority Applications (6)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| SG11201901736SA SG11201901736SA (en) | 2016-08-29 | 2017-08-17 | Random number generation method and device utilized in computer system |
| KR1020197009107A KR102102088B1 (ko) | 2016-08-29 | 2017-08-17 | 컴퓨터 시스템에서 이용되는 난수 생성 방법 및 디바이스 |
| MYPI2019001031A MY192451A (en) | 2016-08-29 | 2017-08-17 | Random number generation method and device utilized in computer system |
| JP2019511915A JP6637219B2 (ja) | 2016-08-29 | 2017-08-17 | コンピュータシステムにおいて利用される乱数生成方法及び装置 |
| US16/287,617 US10649734B2 (en) | 2016-08-29 | 2019-02-27 | Random number generation method and device utilized in computer system |
| PH12019500451A PH12019500451A1 (en) | 2016-08-29 | 2019-02-28 | Random number generation method and device utilized in computer system |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610751289.X | 2016-08-29 | ||
| CN201610751289.XA CN106919365A (zh) | 2016-08-29 | 2016-08-29 | 计算机系统中随机数的生成方法及装置 |
Related Child Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| US16/287,617 Continuation US10649734B2 (en) | 2016-08-29 | 2019-02-27 | Random number generation method and device utilized in computer system |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2018040921A1 true WO2018040921A1 (zh) | 2018-03-08 |
Family
ID=59454597
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2017/097779 Ceased WO2018040921A1 (zh) | 2016-08-29 | 2017-08-17 | 计算机系统中随机数的生成方法及装置 |
Country Status (9)
| Country | Link |
|---|---|
| US (1) | US10649734B2 (zh) |
| JP (1) | JP6637219B2 (zh) |
| KR (1) | KR102102088B1 (zh) |
| CN (1) | CN106919365A (zh) |
| MY (1) | MY192451A (zh) |
| PH (1) | PH12019500451A1 (zh) |
| SG (1) | SG11201901736SA (zh) |
| TW (1) | TWI695317B (zh) |
| WO (1) | WO2018040921A1 (zh) |
Families Citing this family (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106919365A (zh) | 2016-08-29 | 2017-07-04 | 阿里巴巴集团控股有限公司 | 计算机系统中随机数的生成方法及装置 |
| CN107743091A (zh) * | 2017-11-20 | 2018-02-27 | 珠海市魅族科技有限公司 | 信息处理方法、装置、计算机装置及计算机可读存储介质 |
| US10990355B1 (en) * | 2020-06-19 | 2021-04-27 | Panagiotis Andreadakis | Aperiodic pseudo-random number generator based on a linear congruential generator |
| GB2602787A (en) * | 2020-12-17 | 2022-07-20 | Fusion Holdings Ltd | Systems and methods for resilient distribution of random numbers |
| WO2025188242A1 (en) * | 2024-03-04 | 2025-09-12 | National University Of Singapore | Ticket generation for approximating an unknown reference ticket |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20060123073A1 (en) * | 2001-04-13 | 2006-06-08 | Science Applications International Corporation | Random number generators |
| CN101127575A (zh) * | 2007-09-12 | 2008-02-20 | 中兴通讯股份有限公司 | 一种均匀分布随机数发生器及均匀分布随机数产生方法 |
| CN102520908A (zh) * | 2011-12-20 | 2012-06-27 | 大唐微电子技术有限公司 | 一种伪随机数生成器及伪随机数生成方法 |
| CN102799413A (zh) * | 2011-05-25 | 2012-11-28 | 清华大学 | 一种随机数生成方法和装置 |
| CN106919365A (zh) * | 2016-08-29 | 2017-07-04 | 阿里巴巴集团控股有限公司 | 计算机系统中随机数的生成方法及装置 |
Family Cites Families (28)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US4687988A (en) | 1985-06-24 | 1987-08-18 | International Business Machines Corporation | Weighted random pattern testing apparatus and method |
| US4688223A (en) | 1985-06-24 | 1987-08-18 | International Business Machines Corporation | Weighted random pattern testing apparatus and method |
| US4801870A (en) | 1985-06-24 | 1989-01-31 | International Business Machines Corporation | Weighted random pattern testing apparatus and method |
| US7077746B2 (en) | 2001-06-05 | 2006-07-18 | Torango Lawrence J | Progressive wagering system |
| US7384336B2 (en) | 1997-01-15 | 2008-06-10 | Torango Lawrence J | Progressive system and methods |
| US6061819A (en) * | 1997-12-29 | 2000-05-09 | Hewlett-Packard Company | Generation of reproducible random initial states in RTL simulators |
| WO2000016182A1 (en) | 1998-09-14 | 2000-03-23 | Silicon Gaming-Nevada, Inc. | Random number generator seeding method and apparatus |
| JP2001117756A (ja) | 1999-10-20 | 2001-04-27 | Iwaki Electronics Corp | ランダムパルス発生器ならびにそれを利用した乱数発生装置および確率発生装置 |
| JP4521708B2 (ja) | 2001-03-12 | 2010-08-11 | ルネサスエレクトロニクス株式会社 | 乱数生成装置 |
| JP4467216B2 (ja) | 2001-09-07 | 2010-05-26 | Necエレクトロニクス株式会社 | 乱数発生方法及び装置 |
| US7328228B2 (en) | 2003-09-02 | 2008-02-05 | Sap Aktiengesellschaft | Mapping pseudo-random numbers to predefined number ranges |
| JP4587687B2 (ja) | 2004-03-26 | 2010-11-24 | 株式会社三共 | 遊技機 |
| US7849121B2 (en) * | 2006-04-20 | 2010-12-07 | Hewlett-Packard Development Company, L.P. | Optical-based, self-authenticating quantum random number generators |
| WO2007148244A1 (en) * | 2006-06-20 | 2007-12-27 | Nxp B.V. | Random number generator system, method for generating random numbers |
| US8187076B2 (en) | 2007-09-26 | 2012-05-29 | Aruze Gaming America, Inc. | Slot machine performing payout of a predetermined amount of credits when the number of games reaches a predetermined number |
| JP4308293B2 (ja) | 2007-11-20 | 2009-08-05 | 際国 董 | 乱数生成装置及び方法 |
| US8298070B2 (en) | 2008-11-14 | 2012-10-30 | Aruze Gaming America, Inc. | Gaming machine that executes free game and the play method |
| JP5384221B2 (ja) | 2009-06-24 | 2014-01-08 | 京楽産業.株式会社 | 遊技機 |
| US8370411B2 (en) * | 2010-03-12 | 2013-02-05 | Plx Technology, Inc. | Generating unique random numbers for multiple instantiations |
| JP2012100872A (ja) | 2010-11-10 | 2012-05-31 | Daito Giken:Kk | 遊技台 |
| JP4991955B1 (ja) | 2011-07-25 | 2012-08-08 | 株式会社大都技研 | 遊技台 |
| JP2013106805A (ja) | 2011-11-21 | 2013-06-06 | Daito Giken:Kk | 遊技台 |
| JP5256478B2 (ja) | 2011-11-21 | 2013-08-07 | 株式会社大都技研 | 遊技台 |
| US9641598B1 (en) * | 2014-03-31 | 2017-05-02 | Amazon Technologies, Inc. | Contextually unique identifier generation service |
| US11200554B2 (en) | 2014-12-24 | 2021-12-14 | Isx Ip Ltd | Securing a transaction |
| WO2016118340A1 (en) * | 2015-01-20 | 2016-07-28 | Alibaba Group Holding Limited | Method and system for processing information |
| KR101920190B1 (ko) * | 2016-11-22 | 2019-02-08 | 한국인터넷진흥원 | 임의의 ip 생성 방법 및 그 장치 |
| US10146509B1 (en) * | 2017-05-10 | 2018-12-04 | Mbds, Inc. | ASCII-seeded random number generator |
-
2016
- 2016-08-29 CN CN201610751289.XA patent/CN106919365A/zh active Pending
-
2017
- 2017-06-15 TW TW106120042A patent/TWI695317B/zh not_active IP Right Cessation
- 2017-08-17 SG SG11201901736SA patent/SG11201901736SA/en unknown
- 2017-08-17 MY MYPI2019001031A patent/MY192451A/en unknown
- 2017-08-17 KR KR1020197009107A patent/KR102102088B1/ko active Active
- 2017-08-17 WO PCT/CN2017/097779 patent/WO2018040921A1/zh not_active Ceased
- 2017-08-17 JP JP2019511915A patent/JP6637219B2/ja active Active
-
2019
- 2019-02-27 US US16/287,617 patent/US10649734B2/en active Active
- 2019-02-28 PH PH12019500451A patent/PH12019500451A1/en unknown
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20060123073A1 (en) * | 2001-04-13 | 2006-06-08 | Science Applications International Corporation | Random number generators |
| CN101127575A (zh) * | 2007-09-12 | 2008-02-20 | 中兴通讯股份有限公司 | 一种均匀分布随机数发生器及均匀分布随机数产生方法 |
| CN102799413A (zh) * | 2011-05-25 | 2012-11-28 | 清华大学 | 一种随机数生成方法和装置 |
| CN102520908A (zh) * | 2011-12-20 | 2012-06-27 | 大唐微电子技术有限公司 | 一种伪随机数生成器及伪随机数生成方法 |
| CN106919365A (zh) * | 2016-08-29 | 2017-07-04 | 阿里巴巴集团控股有限公司 | 计算机系统中随机数的生成方法及装置 |
Also Published As
| Publication number | Publication date |
|---|---|
| US20190196791A1 (en) | 2019-06-27 |
| TWI695317B (zh) | 2020-06-01 |
| SG11201901736SA (en) | 2019-04-29 |
| MY192451A (en) | 2022-08-21 |
| US10649734B2 (en) | 2020-05-12 |
| KR102102088B1 (ko) | 2020-04-20 |
| JP2019534499A (ja) | 2019-11-28 |
| PH12019500451A1 (en) | 2020-01-20 |
| KR20190043587A (ko) | 2019-04-26 |
| JP6637219B2 (ja) | 2020-01-29 |
| TW201807566A (zh) | 2018-03-01 |
| CN106919365A (zh) | 2017-07-04 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2018040921A1 (zh) | 计算机系统中随机数的生成方法及装置 | |
| CN107566124B (zh) | 基于哈希运算的共识建立方法、区块链系统及存储介质 | |
| AU2018422776B2 (en) | Sybil-resistant identity generation | |
| US12541615B2 (en) | Multi-party data query methods and apparatuses for data privacy protection | |
| US20250015971A1 (en) | Data processing methods and apparatuses | |
| CN110351841A (zh) | 一种物理下行控制信道的检测方法、发送方法及设备 | |
| WO2022116176A1 (zh) | 数字签名的生成方法、装置和服务器 | |
| CN107995003A (zh) | 国际漫游通信的计费和结算方法、相关装置及分布式系统 | |
| JP2018515821A (ja) | サービス実装 | |
| KR20250139331A (ko) | 블록체인 키에 기반한 데이터 처리 방법, 장치, 기기 및 저장 매체 | |
| CN114021198A (zh) | 一种保护数据隐私的确定共有数据的方法及装置 | |
| US20260019247A1 (en) | Signature method and system | |
| CN115604765A (zh) | 计算卸载优化方法和装置、电子设备和存储介质 | |
| US12348608B2 (en) | Secure and efficient distributed processing | |
| CN107154915A (zh) | 防御分布式拒绝服务DDoS攻击的方法、装置及系统 | |
| CN106302111A (zh) | 一种信息处理方法、终端及服务器 | |
| CN113347208B (zh) | 用于确定网络节点的方法和装置 | |
| US8856531B1 (en) | Message bus key agreement scheme | |
| US20220138304A1 (en) | User authentication | |
| CN109981284B (zh) | 一种椭圆曲线数字签名的实现方法及装置 | |
| US12046109B2 (en) | Method and apparatus for conducting fair lottery while reducing transaction cost by using blockchain network | |
| CN105991588A (zh) | 一种防御消息攻击的方法及装置 | |
| CN115904726A (zh) | 安全多方计算方法及装置 | |
| CN112202562A (zh) | Rsa密钥生成方法、计算机设备及介质 | |
| CN110162293B (zh) | 一种用于均衡负载的随机编号生成方法、装置和终端 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 17845223 Country of ref document: EP Kind code of ref document: A1 |
|
| ENP | Entry into the national phase |
Ref document number: 2019511915 Country of ref document: JP Kind code of ref document: A |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| ENP | Entry into the national phase |
Ref document number: 20197009107 Country of ref document: KR Kind code of ref document: A |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 17845223 Country of ref document: EP Kind code of ref document: A1 |
