It's actually very easy to suddenly find the problem today
X = rand (1, N) to generate [0, 1] Even random books...
Y = x/sum (x )...
Today, I encountered a problem when I wrote a random simulation program;
X1, x2,..., xn random number evenly distributed, xi> = 0;
X1 + X2 +... xn = 1;
For how to generate such a random number, assume n = 5;
In addition, X1,... and X5 are equally valid !!!
At the beginning, everyone will come up with a method,
X1 is random from [0, 1;
X2 is random from [-X1;
......
X5 from [0, 1-X1-..-X5].
I tried 20
0.3410 0.2842 0.0677 0.1643 0.0444
0.0097 0.3013 0.6653 0.0018 0.0135
0.2369 0.1436 0.3208 0.0177 0.2600
0.9462 0.0409 0.0027 0.0086 0.0012
0.4977 0.2503 0.2106 0.0100 0.0303
0.8153 0.1132 0.0377 0.0184 0.0097
0.8425 0.1087 0.0155 0.0201 0.0047
0.1197 0.2955 0.0655 0.4742 0.0046
0.7358 0.0235 0.0929 0.1437 0.0014
0.8553 0.1155 0.0127 0.0145 0.0016
0.0921 0.2226 0.2571 0.0888 0.2629
0.5569 0.1414 0.0450 0.0263 0.0640
0.3176 0.1832 0.4823 0.0063 0.0002
0.1323 0.7798 0.0608 0.0202 0.0032
0.1931 0.2242 0.1681 0.4143 0.0001
0.2613 0.5561 0.0190 0.1222 0.0039
0.1805 0.2741 0.0925 0.0702 0.0770
0.5199 0.4443 0.0165 0.0056 0.0119
0.6232 0.2762 0.0797 0.0141 0.0062
0.0348 0.8789 0.0478 0.0056 0.0113
And 8.3120 5.6574 2.7602 1.6471 0.8122
Average 0.4156 0.2829 0.1380 0.0824 0.0406
This is problematic, and the expectation for X5 is almost 10 times that of X1.
I switched to the most conservative method. X1,... X5 are all random numbers on,
If X1 + X2 +... xn = 1; I accept it. If not, I give up.
I tried programming 0.995 <X1 + X2 +... XN <1.005
0.2172 0.4497 0.1591 0.0043 0.1728
0.1483 0.0999 0.1171 0.0322 0.6034
0.1638 0.2952 0.2006 0.3195 0.0179
0.1100 0.4344 0.1518 0.2466 0.0524
0.2527 0.3003 0.0051 0.3336 0.1055
After 11176 times, we found 5 suitable 0.00044739 (probability)
If it turns into six X1,... X5, X6
0.2980 0.0646 0.0746 0.0876 0.2419 0.2306
0.2805 0.0510 0.0425 0.3594 0.2662 0.0014
0.1765 0.0013 0.1578 0.4213 0.1302 0.1088
0.0405 0.4552 0.1629 0.1624 0.0277 0.1496
0.1266 0.0423 0.2186 0.1275 0.2813 0.1987
44661 0.00011195
These are just approximate statistics...
There should be a better way to learn the cause of probability statistics. Let me know!
I don't know what other good methods do you have? Ariszheng@gmail.com (Zheng Zhiyong)