[PLUG] [OT] Ellipsoid uniform random distribution

Russell Senior russell at personaltelco.net
Tue Feb 20 17:27:58 UTC 2007


>>>>> "M" == M Edward (Ed) Borasky <znmeb at cesmail.net> writes:

Russell> Okay, this has nothing to do with Linux, per se, but I've
Russell> received some fortuitous assistance here from the
Russell> mathematically gifted, so I'll try again.  I want to randomly
Russell> select points with a uniform probability over the surface of
Russell> an an ellipsoid (the WGS84 ellipsoid representing the earth,
Russell> to be concrete about it).  I know how to do it for spheres,
Russell> but I have yet to find anything equally comprehensible for an
Russell> ellipsoid.

Russell> Any clues?  Pointers?

M> There might be something built into R for that -- there are quite a
M> few geospatial contributed packages. My recollection is that the
M> Earth is "close enough" to a sphere that your sphere technique
M> might work anyway. :)

It may be "close enough", but I don't want people to be able to
challenge the validity of a random sample, so I am trying to go the
extra mile.

M> How do you do it for a sphere? 

  double ra1 = drand48();
  double ra2 = drand48();
  double theta = ra1 * 2 * pi;

  double dz = (ra2 - 0.5) * 2;
  double dxy = sqrt(1 - dz * dz);

  double dx=dxy * cos(theta);
  double dy=dxy * sin(theta);


-- 
Russell Senior, Secretary
russell at personaltelco.net



More information about the PLUG mailing list