# Uniformly distribute a population in a given search space

I am trying to uniformly distribute a finite number of particles into a 2D search space to get me started with an optimization problem, but I am having a hard time doing it. I am thinking that it might have something to do with convex sets, but I might as well be totally off, so I am asking you guys of a proper way to do it .

Edit: Ok, so I have to implement the Particle Swarm Optimization algorithm in order to get the polynomial input for Baker's algorithm and to get started with PSO, I have to uniformly distribute the particles in the search space (the initial example I got was of the distribution of particles inside of a cube, but that's kind of vague for me). What does it mean to uniformly distribute in the search space?

-
What's wrong with choosing one coordinate uniformly and then another? – Qiaochu Yuan Jan 13 '10 at 18:15
If your space is irregularly shaped, use rejection sampling (en.wikipedia.org/wiki/Rejection_sampling). See also mathoverflow.net/questions/9854/… – Steve Huntsman Jan 13 '10 at 18:19
Well, what if the search space is a rectangle, say with a 2^16 size ? I guess your solution will still work. – user984 Jan 13 '10 at 20:30
@Leonid: yes you are right ... I am not talking about the probability density function, but rather how to uniformly distribute those points in the space. – user984 Jan 14 '10 at 17:57
@Hyperboreean -- you should try to indicate what you mean by "uniformly distribute", perhaps with an example of the sort of thing you're looking for. I suspect you're not getting any answers because no one is sure what you want. You should also explicitly ask a question --- our experience is generally that the effort of putting a problem into the explicit form of a question really pays off! – Scott Morrison Jan 15 '10 at 21:14