CN110580142B - Method and device for generating random number - Google Patents

Method and device for generating random number Download PDF

Info

Publication number
CN110580142B
CN110580142B CN201810597296.8A CN201810597296A CN110580142B CN 110580142 B CN110580142 B CN 110580142B CN 201810597296 A CN201810597296 A CN 201810597296A CN 110580142 B CN110580142 B CN 110580142B
Authority
CN
China
Prior art keywords
probability density
random number
random numbers
original random
original
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.)
Active
Application number
CN201810597296.8A
Other languages
Chinese (zh)
Other versions
CN110580142A (en
Inventor
范超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201810597296.8A priority Critical patent/CN110580142B/en
Publication of CN110580142A publication Critical patent/CN110580142A/en
Application granted granted Critical
Publication of CN110580142B publication Critical patent/CN110580142B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/58Random or pseudo-random number generators
    • G06F7/588Random number generators, i.e. based on natural stochastic processes

Abstract

The invention discloses a method and a device for generating random numbers, and relates to the technical field of computers. One embodiment of the method comprises the following steps: obtaining measured data; determining probability distribution of the measured data; generating uniformly distributed original random numbers in a distribution interval of the measured data; calculating a probability density value of the original random number according to the probability density function; taking the minimum value in the probability density values as a reference value, and calculating the probability density ratio of the original random number according to the reference value and the probability density value of the original random number; generating uniformly distributed random numbers in a clinical domain of the original random numbers, wherein the number of the random numbers is a value obtained by rounding up or down based on a probability density ratio of the original random numbers. According to the embodiment, the random number which is more in accordance with the actual probability distribution of the actual measured data can be generated, and the simulation degree is high.

Description

Method and device for generating random number
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, an electronic device, and a computer readable medium for generating a random number.
Background
The random number is the result of a specific random test. Random numbers are required in statistically different techniques, such as when a representative sample is drawn from a statistical population, or during the assignment of experimental animals to different test groups, or when performing monte carlo simulation calculations, etc. Some random numbers in the actual situation are not pure random numbers, but are 'pseudo random numbers' with a certain distribution rule, for example, the observed actual data (i.e. actual data) are not necessarily completely random, but accord with a certain distribution rule according to the actual situation, i.e. the probability of generating some actual data is large, and the probability of generating some actual data is small. Therefore, the random number needs to be generated better according to the actual situation, which is an important link in the current simulation test, namely, the corresponding random number is generated as a business variable according to the actual performance of the business to realize the simulation verification of the algorithm and the plan, and the generated result of the random number directly influences the simulation result of the algorithm and the plan, thereby influencing the evaluation, analysis, verification, improvement and the like of the existing algorithm and the plan.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
in the prior art, a random number is generated by a parameter estimation method, namely, a distribution function closest to measured data is selected as a probability density function according to a known probability density function (such as normal distribution, exponential distribution and the like), and the random number is generated by an inversion method, a rounding method, a combination method and the like, but the probability density of actual measured data in reality is often a very complex unknown distribution and cannot be represented by the known probability density function, so that the random number generated by the prior art cannot reflect the actual measured data faithfully and has low simulation degree.
Disclosure of Invention
In view of this, the embodiment of the invention provides a method and a device for generating random numbers, which can generate random numbers more conforming to the actual probability distribution of measured data, thereby being beneficial to reducing experimental errors and improving simulation degree.
To achieve the above object, according to one aspect of an embodiment of the present invention, there is provided a method of generating a random number, including: obtaining measured data; determining a probability density function of the measured data; generating uniformly distributed original random numbers in a distribution interval of the measured data; calculating a probability density value of the original random number according to the probability density function; taking the minimum value in the probability density values as a reference value, and calculating the probability density ratio of the original random number according to the reference value and the probability density value of the original random number; generating uniformly distributed random numbers in a clinical domain of the original random numbers, wherein the number of the random numbers is a value obtained by rounding up or down based on a probability density ratio of the original random numbers.
Optionally, a non-parametric estimation method is used to determine a probability density function of the measured data.
Optionally, the non-parameter estimation method is to determine a probability density function of the measured data based on a kernel function.
Optionally, the probability density ratio is a quotient of the probability density value and the reference value.
Optionally, the threshold of the original random number ranges from a difference of half the difference between the original random number and the adjacent original random number to a sum of half the difference between the original random number and the adjacent original random number.
Optionally, after the step of generating uniformly distributed random numbers in the domain of the original random numbers, the method further comprises: the number of the random numbers is recorded as L, and L is a positive integer; ordering said random numbers from small to large, denoted as z 1 ,z 2 ,…z L The method comprises the steps of carrying out a first treatment on the surface of the In interval [1, L]And randomly generating the preset number of integers which are uniformly distributed, and taking the random number with the integer as a subscript as a preferable random number.
To achieve the above object, according to another aspect of an embodiment of the present invention, there is provided an apparatus for selecting a random number, including: the data module is used for acquiring actual measurement data; the distribution module is used for determining a probability density function of the measured data; the original number module is used for generating original random numbers which are uniformly distributed in the distribution interval of the actual measurement data; the probability module is used for calculating the probability density value of the original random number according to the probability density function; the ratio module is used for taking the minimum value in the probability density values as a reference value and calculating the probability density ratio of the original random numbers according to the reference value and the probability density value of the original random numbers; and the generation module is used for generating random numbers which are uniformly distributed in the adjacent domain of the original random numbers, wherein the number of the random numbers is a value obtained by rounding up or down based on the probability density ratio of the original random numbers.
Optionally, the distribution module is further configured to determine a probability density function of the measured data using a non-parametric estimation method.
Optionally, the non-parameter estimation method is to determine a probability density function of the measured data based on a kernel function.
Optionally, the probability density ratio is a quotient of the probability density value and the reference value.
Optionally, the threshold of the original random number ranges from a difference of half the difference between the original random number and the adjacent original random number to a sum of half the difference between the original random number and the adjacent original random number.
Optionally, the generating module is further configured to record the number of the random numbers as L, where L is a positive integer; ordering said random numbers from small to large, denoted as z 1 ,z 2 ,…z L The method comprises the steps of carrying out a first treatment on the surface of the In interval [1, L]And randomly generating the preset number of integers which are uniformly distributed, and taking the random number with the integer as a subscript as a preferable random number.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided an electronic device including: one or more processors; and a storage device for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement any one of the methods of generating random numbers.
To achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided a computer-readable medium having stored thereon a computer program which, when executed by one or more processors, implements any one of the methods of generating random numbers.
One embodiment of the above invention has the following advantages or benefits: because the technical means of generating random numbers according to any probability density distribution of measured data is adopted, the technical problem of low simulation degree of the random numbers generated by the traditional technology is solved, and the technical effect of improving the simulation degree is achieved.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method of generating random numbers according to an embodiment of the invention;
FIG. 2-1 is a statistical histogram of the actual length of left turn of an AGV cart plotted according to Table 1;
fig. 2-2 is a graph of a calculated probability density function of actual duration of left turn of a trolley according to an embodiment of the present invention.
FIG. 3 is a schematic diagram of the main parts of an apparatus for generating random numbers according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 5 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of main steps of a method for generating random numbers according to an embodiment of the present invention, as shown in fig. 1:
step S101, obtaining actual measurement data; the purpose of this step is to generate a random number based on the measured data, so that the generated random number has a higher degree of simulation. The actual measurement data is the actual data observed, for example, in the simulation verification test of the unmanned warehouse, the actual business data specifically related to the actual data include picking efficiency, AGV (Automated Guided Vehicle, automatic guided vehicle) trolley performance parameters (speed, turning time, lifting time and the like) and the like. As shown in table 1, the actual time length of left turn of the AGV cart was used as the actual measurement data, wherein table 1 is a statistical table of the actual measurement data with a sample size of 33170, and includes minimum time length of 4s, maximum time length of 10s, average time length of 5.89s, etc. of left turn of the AGV cart.
Step S102 represents determining a probability density function of the measured data. The method for calculating the probability density function is divided into a parameter estimation method and a non-parameter estimation method, both of which can obtain the probability density function thereof according to measured data. The probability density function is a function describing the probability distribution in the form of a mathematical formula. The parameter estimation method is to determine the probability density of the measured data on the premise that the measured data accords with a known probability density function, for example, determine the parameter of the known probability density function through a maximum likelihood method. After the probability density of the measured data is determined by using the parameter estimation method, a method for solving an inverse function of the measured data is generally used to generate the random number, and since not all functions can solve the inverse function of the measured data, the method has a great limitation. Moreover, the probability distribution of the measured data may not necessarily be embodied by a known probability density function, which would also result in the random number determined from the known probability density function not actually reflecting the measured data. A preferred embodiment of the invention is to determine the probability density function of the measured data using a non-parametric estimation method. The non-parameter estimation method is to use measured data to generalize the probability density function, and the probability density function solved by the method can be closer to the probability density of real data, so that the simulation is higher. The existing nonparametric estimation methods include Parzen window estimation method and k neighbor estimation method.
Still further in accordance with a preferred embodiment of the present invention, the non-parametric estimation method is a probability density function based on a kernel function for determining the measured data. The kernel functions include linear kernel functions, polynomial kernel functions, gaussian kernel functions, and the like.
For example, using equation (1) as a probability density function of measured data:
wherein,representing a probability density function, x i For the ith measured data, n is the total number of measured data,is a gaussian kernel function.
h is the bandwidth of the signal, and,h minimizes the mean square error integral MISE of the measured data, is the standard deviation of the measured data. The bandwidth h=0.145 in table 1 is a bandwidth value when the probability density function of 33170 pieces of measured data is calculated using formula 1.
FIG. 2-1 is a statistical histogram of the actual length of left turn of an AGV cart plotted according to Table 1; fig. 2-2 is a graph of a probability density function of actual duration of left turn of a trolley calculated according to an embodiment of the present invention, and as can be seen by comparing, the probability density function of actual duration of left turn of a trolley calculated according to an embodiment of the present invention has irregularities shown in fig. 2-1, and has a better fitness with real data.
It should be noted that the present application is not limited to using a non-parametric estimation method to determine the probability density function of the measured data. In the case where the measured data corresponds to a known probability density function, a parameter estimation method may be used to determine the parameters of the probability density function, thereby determining the probability density function of the measured data, and then a random number for simulation is generated based on the determined probability density function using a method of selecting a random number as described below.
Step S103 represents generating an original random number uniformly distributed in a distribution section of the actual measurement data. The range of a certain value is selected from the measured data as a distribution interval, or the range of the values of all measured data is selected as a distribution interval, wherein two end points of the distribution interval are respectively the maximum value and the minimum value of the measured data, and are marked as [ a, b ]]In [ a, b ]]Generating m uniformly distributed original random numbers y at equal intervals k K=1, 2,3 …, m, m being a positive integer, the larger the value of m the better the effect.
In another embodiment of the present invention, a plurality of distribution intervals are selected from the measured data, and the calculation method is the same as that of one section of the distribution intervals, and each section is calculated independently.
Step S104 represents calculating a probability density value of the original random number from the probability density function. Substituting the original random numbers generated in the step S103 into the probability density function in the step S102, and solving probability density values corresponding to the original random numbers. Obviously, the probability density value of the original random number can be calculated according to the probability density function, whether the probability density function of the actual measurement data is determined by the parameter estimation method or the non-parameter estimation method, namely, the original random number accords with the probability density function of the actual measurement data, and then the original random number accords with the probability distribution of the actual measurement data.
One embodiment of the present invention is to calculate probability density values of m original random numbers yk generated on [ a, b ] in step S103 using formula (1), and record the probability density values as fyk, k=1, 2,3, …, m.
Step S105 represents calculating a probability density ratio of the original random number from the reference value and the probability density value of the original random number, using the minimum value of the probability density values as the reference value. Wherein the probability density ratio g may be the probability density value f yk And the base areThe quotient of the standard values t, i.e. g=f yk The probability density ratio is the ratio of the probability density value to a constant, and thus it can be seen that the probability density ratio is also a probability distribution conforming to the original random number. The probability density ratio represents the probability density of the original random number that is several times the minimum value, and can be used to measure how much the original random number generates the random number. For example, the original random number is in the distribution interval [ a, b]In the upper order [4.0,4.5,5.0,5.5,6.0,6.5,7.0 ]]The corresponding probability density is [0.02,0.05,0.1,0.5,0.1,0.05,0.02 ]]The smallest probability density is 0.02, i.e. the reference value is 0.02, so the probability density ratio corresponding to the original random number is [1,2.5,5,25,5,2.5,1 ]]The description will generate 1 random number for the original random number 4.0 and 25 random numbers for the original random number 5.5.
Step S106 represents generating uniformly distributed random numbers in a domain of the original random numbers, wherein the number of the random numbers is a value obtained by rounding up or down based on a probability density ratio of the original random numbers. The threshold range of the original random number is from the difference of half of the difference value between the original random number and the adjacent original random number to the sum of half of the difference value between the original random number and the adjacent original random number. Specifically, δ is set to y i In [ y ] i -δ/2,y i +δ/2]Equidistant generation of [ g ]]A uniform random number, wherein δ=y i+1 -y i . For example, if two adjacent original random numbers are 1 and 2, then the threshold of the original random number 1 is [0.5,1.5 ]]. Since the original random number is calculated by the probability density function of the measured data, the original random number conforms to the probability distribution of the measured data, and since the random number generated by the original random number in step S106 conforms to the probability distribution of the original random number, the random number generated by the original random number also conforms to the probability distribution of the measured data.
With the original random number as [ y ] 1 y 2 y 3 ]For example, the probability density ratio is [ 1.2.3]In the original random number y 1 Generates 1 random number in the critical domain of y 2 Generates 2 random numbers in the critical domain of y 3 Generates 3 in the clinical domain of (2)Random numbers are generated into 6 random numbers in total, and y is drawn when the 6 random numbers are sampled with equal probability 1 The probability of random number generated in the adjacent domain is 1/6, and the random number is drawn to y 2 The probability of random number generated in the adjacent domain is 2/6, and the random number is drawn to y 3 The probability of the random number generated in the clinical domain is 3/6, and the probability of random sampling exactly accords with the probability density ratio of the original random number, so the generated 6 random numbers accord with the probability distribution of the original random number. Further, after the step of generating uniformly distributed random numbers in the domain of the original random numbers, the method further comprises: the number of the random numbers is recorded as L, and L is a positive integer; ordering said random numbers from small to large, denoted as z 1 ,z 2 ,…z L The method comprises the steps of carrying out a first treatment on the surface of the In interval [1, L]And randomly generating the preset number of integers which are uniformly distributed, and taking the random number with the integer as a subscript as a preferable random number. That is, the preferred random number is selected from the random numbers with equal probability, and the generated preferred random number also accords with the probability distribution of the measured data.
Fig. 3 is a schematic diagram of a main part of an apparatus 300 for selecting random numbers according to an embodiment of the present invention, as shown in fig. 3:
a data module 301, configured to obtain measured data; the purpose is to generate random numbers based on measured data, so that the simulation degree of the generated random numbers is higher. The actual measurement data is the actual data observed, for example, in the simulation verification test of the unmanned warehouse, the actual business data specifically related to the actual data include picking efficiency, AGV (Automated Guided Vehicle, automatic guided vehicle) trolley performance parameters (speed, turning time, lifting time and the like) and the like. As shown in table 1, the actual time length of left turn of the AGV cart was used as the actual measurement data, wherein table 1 is a statistical table of the actual measurement data with a sample size of 33170, and includes minimum time length of 4s, maximum time length of 10s, average time length of 5.89s, etc. of left turn of the AGV cart.
A distribution module 302 is configured to determine a probability density function of the measured data. There are many programs for calculating probability density functions, such as a program integrating a parameter estimation method and a non-parameter estimation method, which can obtain the probability density function from measured data. The probability density function is a function describing the probability distribution in the form of a mathematical formula. The parameter estimation method is to determine the probability density of the measured data on the premise that the measured data accords with a known probability density function, for example, determine the parameter of the known probability density function through a maximum likelihood method. After the probability density distribution of the measured data is determined by using the parameter estimation method, a method for solving an inverse function of the probability density distribution is generally used to generate random numbers, and since not all functions can solve the inverse function of the probability density distribution, the probability density distribution has a great limitation. Moreover, the probability distribution of the measured data may not necessarily be embodied by a known probability density function, which would also result in the random number determined from the known probability density function not actually reflecting the measured data.
A preferred embodiment of the present invention uses a non-parametric estimation method for the distribution module 302 to determine the probability density function of the measured data. The non-parameter estimation method is to use measured data to generalize the probability density function, and the probability density function solved by the method can be closer to the probability density of real data, so that the simulation is higher. The existing nonparametric estimation methods include Parzen window estimation method and k neighbor estimation method.
Still further in accordance with a preferred embodiment of the present invention, the non-parametric estimation method is a probability density function based on a kernel function for determining the measured data. The kernel functions include linear kernel functions, polynomial kernel functions, gaussian kernel functions, and the like.
For example, using equation (2) as a probability density function of measured data:
wherein,representing a probability density function, x i For the ith measured data, n is the total number of measured data,is a gaussian kernel function.
h is the bandwidth of the signal, and,h minimizes the mean square error integral MISE of the measured data, is the standard deviation of the measured data. The bandwidth h=0.145 in table 1 is a bandwidth value when the probability density function of 33170 pieces of measured data is calculated using formula 1.
FIG. 2-1 is a statistical histogram of the actual length of left turn of an AGV cart plotted according to Table 1; fig. 2-2 is a graph of a probability density function of actual duration of left turn of a trolley calculated according to an embodiment of the present invention, and as can be seen by comparing, the probability density function of actual duration of left turn of a trolley calculated according to an embodiment of the present invention has irregularities shown in fig. 2-1, and has a better fitness with real data.
It should be noted that the present application is not limited to using a non-parametric estimation method to determine the probability density function of the measured data. In the case where the measured data corresponds to a known probability density function, a parameter estimation method may be used to determine the parameters of the probability density function, thereby determining the probability density function of the measured data, and then a random number for simulation is generated based on the determined probability density function using a method of selecting a random number as described below.
The primitive number module 303 is configured to generate uniformly distributed primitive random numbers within a distribution interval of the measured data. The range of a certain value is selected from the measured data as a distribution interval, or the range of the values of all measured data is selected as a distribution interval, wherein two end points of the distribution interval are respectively the maximum value and the minimum value of the measured data, and are marked as [ a, b ]]In [ a, b ]]Generating m uniformly distributed original random numbers y at equal intervals k K=1, 2,3 …, m, m is a positive integer, m has the valueThe larger the effect is, the better.
In another embodiment of the present invention, a plurality of distribution intervals are selected from the measured data, and the calculation mode is the same as that of one section of the distribution intervals, and each section is calculated independently.
A probability module 304, configured to calculate a probability density value of the original random number according to the probability density function. The original random numbers generated by the original number module 303 are substituted into probability density functions in the distribution module 302, and probability density values corresponding to the original random numbers are solved. Obviously, the probability density value of the original random number can be calculated according to the probability density function, whether the probability density function of the actual measurement data is determined by the parameter estimation method or the non-parameter estimation method, namely, the original random number accords with the probability density function of the actual measurement data, and then the original random number accords with the probability distribution of the actual measurement data.
In one embodiment of the present invention, the probability density values of m original random numbers yk generated on [ a, b ] by the original number calculation module 303 are calculated using formula (2), and the probability density values are denoted as fyk, k=1, 2,3, …, m.
A ratio module 305 for calculating a probability density ratio of the original random number from the reference value and the probability density value of the original random number by using the minimum value of the probability density values as the reference value, wherein the probability density ratio g may be a quotient of the probability density value fyk and the reference value t, i.e., g=f yk The probability density ratio is the ratio of the probability density value to a constant, and thus it can be seen that the probability density ratio is also a probability distribution conforming to the original random number. The probability density ratio represents the probability density of the original random number that is several times the minimum value, and can be used to measure how much the original random number generates the random number. For example, the original random number is in the distribution interval [ a, b]In the upper order [4.0,4.5,5.0,5.5,6.0,6.5,7.0 ]]The corresponding probability density is [0.02,0.05,0.1,0.5,0.1,0.05,0.02 ]]The smallest probability density is 0.02, i.e. the reference value is 0.02, so the probability density ratio corresponding to the original random number is [1,2.5,5,25,5,2.5,1 ]]The description will generate 1 random number for the original random number 4.0 and 25 random numbers for the original random number 5.5.
A generating module 306, configured to generate random numbers with uniform distribution in a domain of the original random numbers, where the number of random numbers is a value obtained by rounding up or down based on a probability density ratio of the original random numbers. The rounding may also be rounded.
The threshold range of the original random number is from the difference of half of the difference value between the original random number and the adjacent original random number to the sum of half of the difference value between the original random number and the adjacent original random number. Specifically, δ is set to y i In [ y ] i -δ/2,y i +δ/2]Equidistant generation of [ g ]]A uniform random number, wherein δ=y i+1 -y i . For example, if two adjacent original random numbers are 1 and 2, then the threshold of the original random number 1 is [0.5,1.5 ]]. Since the original random number is calculated by the probability density function of the measured data, the original random number conforms to the probability distribution of the measured data, and since the random number generated by the original random number through the generation module 306 conforms to the probability distribution of the original random number, the random number generated by the original random number also conforms to the probability distribution of the measured data.
With the original random number as [ y ] 1 y 2 y 3 ]For example, the probability density ratio is [ 1.2.3]In the original random number y 1 Generates 1 random number in the critical domain of y 2 Generates 2 random numbers in the critical domain of y 3 Generates 3 random numbers in the clinical domain, generates 6 random numbers in total, and extracts y when the 6 random numbers are sampled with equal probability 1 The probability of random number generated in the adjacent domain is 1/6, and the random number is drawn to y 2 The probability of random number generated in the adjacent domain is 2/6, and the random number is drawn to y 3 The probability of the random number generated in the clinical domain is 3/6, and the probability of random sampling exactly accords with the probability density ratio of the original random number, so the generated 6 random numbers accord with the probability distribution of the original random number.
Further, after the step of generating uniformly distributed random numbers in the domain of the original random numbers, the method further comprises: the number of random numbers is denoted as L,l is a positive integer; ordering said random numbers from small to large, denoted as z 1 ,z 2 ,…z L The method comprises the steps of carrying out a first treatment on the surface of the In interval [1, L]And randomly generating the preset number of integers which are uniformly distributed, and taking the random number with the integer as a subscript as a preferable random number. That is, the preferred random number is selected from the random numbers with equal probability, and the generated preferred random number also accords with the probability distribution of the measured data.
Fig. 4 illustrates an exemplary system architecture 400 to which a method of generating random numbers or an apparatus for generating random numbers of embodiments of the present invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 is used as a medium to provide communication links between the terminal devices 401, 402, 403 and the server 405. The network 404 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 405 via the network 404 using the terminal devices 401, 402, 403 to receive or send messages or the like. Various applications, such as an application for collecting measured data, may be installed on the terminal devices 401, 402, 403.
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 405 may be a server providing various services, such as a background management server providing statistics on measured data collected by the user using the terminal devices 401, 402, 403. The background management server may analyze the received measured data, and feedback the processing result (for example, probability density function of the measured data, random number corresponding to the distribution of the measured data) to the terminal device.
It should be noted that, in the embodiment of the present invention, a method for generating a random number is generally executed by the server 405, and accordingly, a device for generating a random number is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Fig. 5 is a schematic diagram of a computer system 500 suitable for use in implementing the terminal device of the embodiment of the present invention. The terminal device shown in fig. 5 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input section 506 including a keyboard, a mouse, and the like; an output portion 507 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker, and the like; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The drive 510 is also connected to the I/O interface 505 as needed. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as needed so that a computer program read therefrom is mounted into the storage section 508 as needed.
In particular, the processes described in the above step diagrams may be implemented as computer software programs according to the disclosed embodiments of the invention. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the step diagrams. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 509, and/or installed from the removable media 511. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 501.
The computer readable medium shown in the present invention includes a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium includes, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, semiconductor system, apparatus, or device, or any combination of the preceding. Computer-readable storage media include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any combination of the foregoing. In the context of this disclosure, a computer-readable storage medium includes any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device; a computer readable signal medium includes a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave, and the propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF (radio frequency), or the like, or any combination of the foregoing.
The steps of the figures or block diagrams, which illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention, may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical functions. It should be noted that in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or step diagrams, and combinations of blocks in the block diagrams or step diagrams, can be implemented by special purpose hardware-based systems that perform the specified functions or operations, or combinations of special purpose hardware and computer instructions.
The modules or units involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules or units may also be provided in a processor, for example, as: a processor comprises a data module, a distribution module, a primitive number module, a probability module, a ratio module and a generation module. The names of these modules or units do not limit the modules or units themselves in some cases, and for example, a data module may also be described as "a module for acquiring measured data".
In another aspect, the embodiment of the present invention further provides a computer readable medium, which may be included in the apparatus described in the above embodiment; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include: obtaining measured data; determining probability distribution of the measured data; generating uniformly distributed original random numbers in a distribution interval of the measured data; calculating a probability density value of the original random number according to the probability density function; taking the minimum value in the probability density values as a reference value, and calculating the probability density ratio of the original random number according to the reference value and the probability density value of the original random number; generating uniformly distributed random numbers in a clinical domain of the original random numbers, wherein the number of the random numbers is a value obtained by rounding up or down based on a probability density ratio of the original random numbers.
According to the technical scheme provided by the embodiment of the invention, random numbers meeting any probability density distribution of measured data can be generated, and the simulation degree is high.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (14)

1. A method of generating random numbers, comprising:
obtaining measured data; the actual measurement data comprise actual service data involved in a simulation verification test of the unmanned warehouse;
determining a probability density function of the measured data;
generating uniformly distributed original random numbers in a distribution interval of the measured data;
calculating a probability density value of the original random number according to the probability density function;
taking the minimum value in the probability density values as a reference value, and calculating the probability density ratio of the original random number according to the reference value and the probability density value of the original random number;
generating uniformly distributed random numbers in a clinical domain of the original random numbers, wherein the number of the random numbers is a value obtained by rounding up or down based on a probability density ratio of the original random numbers.
2. The method of claim 1, wherein the probability density function of the measured data is determined using a non-parametric estimation method.
3. The method of claim 2, wherein the non-parametric estimation method is a probability density function that determines the measured data based on a kernel function.
4. The method of claim 1, wherein the probability density ratio is a quotient of the probability density value and the reference value.
5. The method of claim 1, wherein the threshold of the original random number ranges from a difference of half the difference between the original random number and the adjacent original random number to a sum of half the difference between the original random number and the adjacent original random number.
6. The method of claim 1, wherein after the step of generating uniformly distributed random numbers in the neighborhood of the original random numbers, the method further comprises:
the number of the random numbers is recorded as L, and L is a positive integer;
ordering said random numbers from small to large, denoted as z 1 ,z 2 ,…z L
Randomly generating a preset number of integers which are uniformly distributed on the interval [1, L ], and taking the random number with the integers as a subscript as a preferable random number.
7. An apparatus for selecting a random number, comprising:
the data module is used for acquiring actual measurement data; the actual measurement data comprise actual service data involved in a simulation verification test of the unmanned warehouse;
the distribution module is used for determining a probability density function of the measured data;
the original number module is used for generating original random numbers which are uniformly distributed in the distribution interval of the actual measurement data;
the probability module is used for calculating the probability density value of the original random number according to the probability density function;
the ratio module is used for taking the minimum value in the probability density values as a reference value and calculating the probability density ratio of the original random numbers according to the reference value and the probability density value of the original random numbers;
and the generation module is used for generating random numbers which are uniformly distributed in the adjacent domain of the original random numbers, wherein the number of the random numbers is a value obtained by rounding up or down based on the probability density ratio of the original random numbers.
8. The apparatus of claim 7, wherein the distribution module is further configured to determine a probability density function of the measured data using a non-parametric estimation method.
9. The apparatus of claim 8, wherein the non-parametric estimation method is a probability density function that determines the measured data based on a kernel function.
10. The apparatus of claim 7, wherein the probability density ratio is a quotient of the probability density value and the reference value.
11. The apparatus of claim 7, wherein the threshold of the original random number ranges from a difference of half the difference between the original random number and the adjacent original random number to a sum of half the difference between the original random number and the adjacent original random number.
12. The apparatus of claim 7, wherein the means for generating is further configured to record the number of random numbers as L, L being a positive integer;
ordering said random numbers from small to large, denoted as z 1 ,z 2 ,…z L
Randomly generating a preset number of integers which are uniformly distributed on the interval [1, L ], and taking the random number with the integers as a subscript as a preferable random number.
13. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-6.
14. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by one or more processors, implements the method according to any of claims 1-6.
CN201810597296.8A 2018-06-11 2018-06-11 Method and device for generating random number Active CN110580142B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810597296.8A CN110580142B (en) 2018-06-11 2018-06-11 Method and device for generating random number

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810597296.8A CN110580142B (en) 2018-06-11 2018-06-11 Method and device for generating random number

Publications (2)

Publication Number Publication Date
CN110580142A CN110580142A (en) 2019-12-17
CN110580142B true CN110580142B (en) 2024-02-02

Family

ID=68809548

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810597296.8A Active CN110580142B (en) 2018-06-11 2018-06-11 Method and device for generating random number

Country Status (1)

Country Link
CN (1) CN110580142B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6052677A (en) * 1995-02-24 2000-04-18 Fujitsu Limited Next alternative generating apparatus using simulated annealing and method thereof
CN106407627A (en) * 2016-11-23 2017-02-15 西南石油大学 Wind speed probability distribution modeling method and system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6052677A (en) * 1995-02-24 2000-04-18 Fujitsu Limited Next alternative generating apparatus using simulated annealing and method thereof
CN106407627A (en) * 2016-11-23 2017-02-15 西南石油大学 Wind speed probability distribution modeling method and system

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
任意分布随机序列的产生方法;曾治丽;李亚安;金贝立;;声学技术(第06期);全文 *
任意概率分布的伪随机数研究和实现;朱晓玲;姜浩;;计算机技术与发展(第12期);全文 *
混合粒径风沙流情况下的一种沙粒起跃速度概率密度函数;郑晓静;朱伟;谢莉;;中国科学(G辑:物理学 力学 天文学)(第06期);全文 *

Also Published As

Publication number Publication date
CN110580142A (en) 2019-12-17

Similar Documents

Publication Publication Date Title
CN111209347B (en) Method and device for clustering mixed attribute data
CN113034059B (en) Abnormal power information positioning method and device, electronic equipment and computer medium
CN115085196B (en) Power load predicted value determination method, device, equipment and computer readable medium
CN110852882A (en) Packet consensus method, apparatus, device, and medium for blockchain networks
CN110766348B (en) Method and device for combining goods picking tasks
CN110879776A (en) Test case generation method and device
CN114049072B (en) Index determination method and device, electronic equipment and computer readable medium
CN116827971B (en) Block chain-based carbon emission data storage and transmission method, device and equipment
CN111932348B (en) Alarm method and device for abnormal order, electronic equipment and readable medium
CN110580142B (en) Method and device for generating random number
CN113282456B (en) Data processing method and device
CN111026629A (en) Method and device for automatically generating test script
CN114996503A (en) Node positioning method and device
CN113902230A (en) Electric quantity deviation control method, system, storage medium and electronic equipment
CN113779335A (en) Information generation method and device, electronic equipment and computer readable medium
CN111709366A (en) Method, apparatus, electronic device, and medium for generating classification information
CN114826976B (en) Statistical method and device for uplink flow data based on edge computing service
CN114089712B (en) Data processing method and device
CN113361739B (en) Method and device for generating picking path
CN110703119B (en) Method and device for evaluating battery health status
CN113723657A (en) Activity information prediction model generation method, apparatus, electronic device, and medium
CN109240878B (en) Data processing method and device
CN113282471B (en) Equipment performance testing method and device and terminal equipment
CN114692063A (en) Method and device for fitting particle average absorption efficiency factor based on piecewise index
CN109840196B (en) Method and device for testing business logic

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant