Spatial Digger
Spatial Digger

Reputation: 1993

Sampling from a point pattern

I have a 3D point distribution in a numpy array formed of 1,000,000 points, lets call it points. I would like to take a 10% uniform sample so that the points are evenly distributed (e.g. every 10th point)

I think this is what I'm looking for but this generates data, how do I sample existing data?

numpy.random.uniform(low=0.0, high=1.0, size=None) 

Upvotes: 0

Views: 45

Answers (2)

markuscosinus
markuscosinus

Reputation: 2267

In case I understood the problem right you would just need to do this:

points[::10]

to get every 10th element of points.

If that is not what you wanted, please clarify.

Upvotes: 1

Yasin Yousif
Yasin Yousif

Reputation: 967

simple indexing will do it:

# data
x = numpy.random.uniform(low=0.0, high=1.0, size=(300,3))

#sampled result
sample_step = 10
y = x[:-1:sample_step]

Upvotes: 0

Related Questions