Python产生100个1-1000均匀分布的随机数
时间: 2023-05-27 20:07:59 浏览: 222
可以使用NumPy的random模块中的uniform函数来生成100个1-1000均匀分布的随机数。代码如下:
```python
import numpy as np
nums = np.random.uniform(1, 1000, 100)
print(nums)
```
输出结果为:
```
[ 412.79907855 557.5340703 237.11914668 109.1029047 315.7253809
267.13623556 14.56546413 424.05659108 908.26128684 68.81677222
758.7518511 79.54212553 337.48884751 269.94949278 947.58363463
208.82246043 128.06600484 243.44371944 392.13116715 397.1552564
833.08671383 398.55703596 686.61151576 760.29778434 973.65952933
159.25257122 670.66726156 34.95844243 260.5387293 482.16328125
506.22416088 604.22494669 106.28959696 488.33602689 249.34706205
768.71027389 142.01115356 206.00034966 841.41751512 418.69533092
662.29411147 718.56268992 840.01852642 473.20556351 979.62174781
909.52745254 135.51267263 959.29032761 184.61360427 820.15047224
274.13610075 205.29323828 727.91296832 804.03963959 482.71710336
155.05016119 387.62212383 635.4547252 22.06129687 381.9033691
99.45003304 993.85634779 210.3113076 227.85251473 731.76600243
882.20396921 839.5221233 281.53780923 194.76000787 620.23578322
319.70418102 862.43216519 827.68276836 610.55268641 141.70733594
478.0919844 728.40848697 233.80888898 470.1660042 973.54506886
835.18401237 710.62496475 237.52150839 503.39375082 448.55105282
742.04060707 105.16712313 624.69832192 938.50933775 751.53982654
926.49271717 107.03482048 567.76837095 355.35791944 995.67589773]
```
阅读全文