A random value method for two-dimensional probability distribution matrix

By creating a conversion matrix Θ and performing a binary search to determine the row number and column number, an efficient random value selection of the two-dimensional probability distribution matrix is ​​realized, which solves the problem that the existing technology cannot be directly applied to the two-dimensional situation and achieves the same goal as the traditional roulette wheel. The betting method is quite efficient.

CN111625959BActive Publication Date: 2024-10-11TAIZHOU UNIV (ZHEJIANG)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010456781.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-26
Publication Date
2024-10-11
Estimated Expiration
2040-05-26

AI Technical Summary

Technical Problem

Existing technology cannot directly and efficiently perform random value operations on a two-dimensional probability distribution matrix. The traditional roulette algorithm is mainly suitable for one-dimensional probability distribution vectors and cannot be directly applied to two-dimensional situations.

Method used

By creating a matrix Θ with u rows and v+1 columns, perform a pre-operation to convert the two-dimensional probability distribution matrix Φ into Θ, and perform a binary search in Θ to determine the row number and column number, and generate an integer tuple , the time complexity of the pre-step is O(u×v), and the time complexity of the value step is O(log(u)+log(v)).

Benefits of technology

It realizes the direct and efficient random value operation of the two-dimensional probability distribution matrix, with a time complexity comparable to the traditional roulette method, and solves the random value problem in the two-dimensional case.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111625959B_ABST
    Figure CN111625959B_ABST
Patent Text Reader

Abstract

The present invention provides a random value-taking method for a two-dimensional probability distribution matrix, and belongs to the technical field of mathematical modeling and analysis. It solves the technical problems that the existing roulette random value-taking algorithm cannot be applied to two-dimensional probability distribution matrix data. The algorithm includes: a pre-step: creating a matrix Θ with u rows and v+1 columns based on Φ; a value-taking step: randomly generating a real number δ1 in the interval (0.0,1.0] according to a uniform distribution, determining the row number i of the first element greater than or equal to δ1 from top to bottom in the v+1th column of Θ by a binary search, and randomly generating a real number δ1 in the interval (0.0,Θ according to a uniform distribution. i,v ], use binary search to determine the column number j of the first element from left to right in the i-th row of Θ that is greater than or equal to δ2, and use the row number i and column number j to form an integer tuple<i,j> The present invention can realize the random value operation of a two-dimensional probability distribution matrix.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of mathematical modeling and analysis, and relates to a theoretical research method of random value selection for computer simulation of complex systems and discrete probability distribution, and in particular to a random value selection method for a two-dimensional probability distribution matrix. Background Art

[0002] Computer simulation of complex systems often involves random value operations of discrete random events to generate simulation cases, and the Roulette Algorithm is a commonly used random value method.

[0003] The use of a two-dimensional matrix can more intuitively describe the probability distribution of some discrete random events in real life. For example, the OD demand probability distribution matrix is ​​often used to describe the proportion of passenger travel demand between stations in a certain period of time in an urban bus network. The matrix can be established based on the statistics of historical passenger travel records, and the elements of the i-th row and j-th column are defined as the proportion of passenger trips with the i-th station as the departure station and the j-th station as the destination station in the corresponding period of time to the total number of passenger trips in the entire network. In the passenger flow simulation of the urban bus network, each time a passenger travel simulation case is generated, its starting station and destination station can be randomly assigned according to the OD demand probability distribution matrix.

[0004] The basic process of the traditional roulette random value method usually includes: ①, the pre-stage: establish the cumulative probability distribution (CPD) vector corresponding to the discrete probability distribution (PD); ②, the value stage: each time the value is randomly selected, a real number in the interval (0.0,1.0] is randomly generated with a uniform distribution, and then the first element in the CPD vector that is greater than or equal to the real number is found, and the value is finally determined based on this. For example, suppose a discrete random event has three possible values: the probability of taking value A is 0.5, the probability of taking value B is 0.4, and the probability of taking value C is 0.1. It can be seen that the PD vector of the event is <0.5, 0.4, 0.1>, and the CPD vector is <0.5, 0.5+0.4=0.9, 0.9+0.1=1.0>, where the subscript 1 The corresponding value is A, the subscript 2 corresponds to the value B, and the subscript 3 corresponds to the value C. When using the roulette algorithm to perform a random value selection of this discrete random event, assume that the randomly generated real number is 0.95. Since the subscript of the first element from left to right in the CPD vector that is greater than or equal to 0.95 is 3, it can be determined that the value this time is C. Assuming that the value of a discrete random event contains n possibilities, the time complexity of the front stage in the above process is O(n); for each random value selection operation, a binary search method can be used to quickly locate the specified element of the CPD vector, and the time complexity is O(log(n)). It can be seen that the traditional roulette random value selection method has good performance, but it is based on probability distribution vectors to complete related operations and cannot be directly applied to the case of two-dimensional probability distribution matrices. Summary of the invention

[0005] In view of the above problems existing in the prior art, the present invention provides a random value-taking method for a two-dimensional probability distribution matrix. The technical problem to be solved by the present invention is: how to provide a simple and reliable random value-taking method for a two-dimensional probability distribution matrix.

[0006] The purpose of the present invention can be achieved by the following technical solutions:

[0007] A random value method for a two-dimensional probability distribution matrix. The algorithm randomly selects an integer tuple consisting of row number i and column number j according to a two-dimensional probability distribution matrix Φ with u rows and v columns.<i,j> The process includes the following steps 1 and 2:

[0008] Step 1 is a pre-step: it includes the following sub-steps in sequence:

[0009] ①. Create a matrix Θ with u rows and v + 1 columns. For the case where 1≤x≤u and 1≤y≤v, let Θ x,y =Φ x,y ;

[0010] ②, traverse each row of Θ, and in the process of traversing each row, traverse from the second element of the current traversal row to the vth element one by one: let the row number of the current traversal element be x and the column number be y, so that Θ x,y =Θ x,y-1 +Θ x,y ;

[0011] ③、Make 1,v+1 =Θ 1,v ;

[0012] ④、Traverse from the second element of the v+1th column of Θ to the uth element one by one: let the row number of the current traversal element be x, so that Θ x,v+1 =Θ x-1,v+1 +Θ x,v ;

[0013] Step 2 is the value acquisition step, which includes the following sub-steps in sequence:

[0014] ①, randomly generate a real number δ1 in the interval (0.0,1.0] according to uniform distribution, and use binary search to determine the row number i of the first element in the v+1th column of Θ that is greater than or equal to δ1 from top to bottom;

[0015] ②, randomly generate a real number δ2 in the interval (0.0, Θi, v] according to uniform distribution, and use binary search to determine the column number j of the first element from left to right in the i-th row of Θ that is greater than or equal to δ2;

[0016] ③. Use the row number i determined in sub-step ① and the column number j determined in sub-step ② to form an integer tuple<i,j> .

[0017] Assuming that the number of elements contained in the two-dimensional probability distribution matrix Φ is n = u × v, the time complexity of the pre-step of the above algorithm is O(u × v) = O(n), and the time complexity of the value-taking step is O(log(u) + log(v)) = O(log(n)). It can be seen that the above algorithm has a time complexity comparable to that of the traditional roulette random value-taking method.

[0018] Compared with the prior art, the present invention can directly and efficiently complete the random value operation based on the two-dimensional probability distribution matrix. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a schematic diagram of the operation flow of the method in a specific implementation manner. DETAILED DESCRIPTION

[0020] The following are specific embodiments of the present invention and the accompanying drawings to further describe the technical solution of the present invention, but the present invention is not limited to the following embodiments.

[0021] like Figure 1As shown in (a), the method in this embodiment randomly selects an integer tuple consisting of row number i and column number j according to a two-dimensional probability distribution matrix Φ with 4 rows and 4 columns.<i,j> The process includes the following steps 1 and 2:

[0022] Step 1 is a pre-step, which includes the following sub-steps 1.1 to 1.4:

[0023] Step 1.1: Create a 4-row 5-column matrix Θ, and for the case 1≤x≤4 and 1≤y≤4, make Θ x,y =Φ x,y .

[0024] Step 1.2: Traverse each row of Θ. During each row traversal, traverse from the second element of the current traversal row to the fourth element one by one: let the row number of the current traversal element be x and the column number be y, so that Θ x,y =Θ x,y-1 +Θ x,y .

[0025] Step 1.3: Make θ 1,5 =Θ 1,4 .

[0026] Step 1.4: Traverse from the second element of the fifth column of Θ to the fourth element one by one: Let the row number of the current traversal element be x, so that Θ x,5 =Θ x-1,5 +Θ x,4 .

[0027] After the previous steps, the matrix Θ is obtained as Figure 1 (b) As shown in sub-figure.

[0028] Step 2 is the value-taking step, which includes the following sub-steps 2.1 to 2.3:

[0029] Step 2.1: Generate a real number δ1 in the interval (0.0, 1.0] randomly according to uniform distribution, and use binary search to determine the row number i of the first element in the 5th column of Θ that is greater than or equal to δ1 from top to bottom.

[0030] Assume that the randomly generated δ1 is 0.65, then Figure 1 As shown in subfigure (c), the determined row number i is 3.

[0031] Step 2.2: Generate a random number between (0.0, Θ) according to uniform distribution. 3,5 =0.2], and determine the column number j of the first element from left to right in the third row of Θ that is greater than or equal to δ2 by binary search.

[0032] Assume that the randomly generated δ1 is 0.09, then Figure 1As shown in subfigure (d), the determined column number j is 2.

[0033] Step 2.3: Use the row number i=3 determined in step 2.1 and the column number j=2 determined in step 2.2 to form an integer tuple <3,2>.

[0034] The specific embodiments described herein are merely examples of the spirit of the present invention. Those skilled in the art may make various modifications or additions to the specific embodiments described or replace them in similar ways, but they will not deviate from the spirit of the present invention or exceed the scope defined by the appended claims.

Claims

1. A random value selection method for a two-dimensional probability distribution matrix, the two-dimensional probability distribution matrix is ​​an OD demand probability distribution matrix, the OD demand probability distribution matrix is ​​used to describe the passenger travel demand ratio between each station in a certain period of time in an urban bus network, the matrix can be established based on the statistics of historical passenger travel records, and the element of the i-th row and j-th column is defined as the ratio of the passenger travel volume with the i-th station as the departure station and the j-th station as the destination station in the corresponding period to the total passenger travel volume of the entire network ; In the passenger flow simulation for the urban public transportation network, each time a passenger travel simulation case is generated, its starting station and destination station can be randomly assigned according to the OD demand probability distribution matrix; the characteristics are: It randomly selects an integer tuple consisting of row number i and column number j based on a two-dimensional probability distribution matrix Φ with u rows and v columns.<i,j> The process includes the following steps in sequence: Step 1 is the pre-step: ①, create a matrix Θ with u rows and v + 1 columns, and for the case where 1≤x≤u and 1≤y≤v, let Θ x,y =Φ x,y ; ②, traverse each row of Θ, and in the process of traversing each row, traverse from the second element of the current traversal row to the vth element one by one: let the row number of the current traversal element be x and the column number be y, so that Θ x,y =Θ x,y-1 +Θ x,y ; ③、Use it 1,v+1 =Θ 1,v ; ④、Traverse from the second element of the v+1th column of Θ to the uth element one by one: let the row number of the current traversal element be x, so that Θ x,v+1 =Θ x-1,v+1 +Θ x,v ; Step 2 is the value selection step: ①, randomly generate a real number δ in the interval (0.0,1.0] according to uniform distribution 1 , use binary search to find the first value in the v+1th column of Θ that is greater than or equal to δ from top to bottom. 1 The row number i of the element; ②, randomly generate a uniform distribution at (0.0, Θ i,v ] real number δ in the interval 2 , use binary search to find the first value in the i-th row of Θ that is greater than or equal to δ from left to right. 2 The column number j of the element; ③、Use the row number i determined in step 2① and the column number j determined in step 2② to form an integer tuple<i,j> .