3d Random sampling [duplicate]

一笑奈何 提交于 2019-12-24 03:06:23

问题


I have a set of points xyz8,

I want to randomly get 10% of points.

Then I want to randomly get 10% of the remaining 90%

Then I want to randomly get 10% of the remaining 70%

etc until all points done

How can I go about doing this?

Any advice is hugely appreciated


回答1:


something like:

import random

l = [1,2,3,4]
random.shuffle(l)
while len(l) > 0:
    choice = l[:len(l) / 10]
    l = l[len(l) / 10:]



回答2:


I interpret this as you want to split the points into 10 equal-sized segments. You can simply do this by shuffling them and reshaping the list:

np.random.shuffle(points)
points.shape = (10,-1) + points.shape[1:]

Then you can access the first 10% as points[0], the second as points[1], etc.

This still works for a multidimensional array since shuffle will only shuffle along the first axis.



来源:https://stackoverflow.com/questions/18796191/3d-random-sampling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!