简体   繁体   中英

How to generate uniformly new 2-D data set in a given square in python

如果我们已经知道正方形的四个点的坐标,如何在python中在给定的正方形中生成统一的新二维数据集(维度(10000,2))。

You can use numpy.random.uniform and specify the min and max values of each dimension.

import numpy as np
data = np.random.uniform((min_d0, min_d1), (max_d0, max_d1), (10000, 2))

You can check the documentation here: https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.random.uniform.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM