Timeline for Generating random locations nearby?
Current License: CC BY-SA 3.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 27, 2017 at 20:12 | comment | added | azizj | Mind blown @whuber, and it makes sense. Another way to look at it I guess is to imagine 55 random radii being generated for a radius of 20. Let's say each random radii is uniform and exactly equal to either 0 to 20, so 0, 2, 4, ..., 20. So there will be 5 points with a radii of, 5 of radii of 2, etc. The 5 points with a radii of 2 (around a circle of radius 2) will look MUCH closer to each other than the 5 points with a radii of 20. | |
Oct 27, 2017 at 16:51 | comment | added | whuber | @Aziz That's not how areas behave. A uniform distribution of the radius is not a uniform distribution of the area. "Uniform" in area means that the chance of a point lying within any specified region is proportional to the region's area. If you generate uniform radii between 0 and r then, for example (to illustrate this idea), the chance that the associated point will lie within the circle of radius r/2 is 1/2. However, that circle's area is only one quarter of the area of a circle of radius r. See for yourself--generate uniform radii and watch how the points cluster near the center. | |
Oct 27, 2017 at 15:00 | comment | added | azizj | But isn't random just a uniform distribution from 0 to 1? I.e., equally likely to be anywhere? Sqrt rooting I thought would weigh it more towards closer to the edge of the circle | |
Oct 27, 2017 at 14:15 | comment | added | whuber | @Aziz Without the square root, too many points would be too close to the origin. The square root ensures that these points have equal chances of being anywhere within the circle of radius r. | |
Oct 27, 2017 at 11:57 | comment | added | azizj |
Why is the random variable u square rooted before it is multiplied with the radius? Shouldn't it just be radiusInDegrees * u ?
|
|
Mar 26, 2016 at 2:49 | comment | added | whuber | @aaron Yes, provided y0 is in degrees and your implementation of cos assumes its arguments are in radians! | |
Mar 26, 2016 at 2:43 | comment | added | Aaron Stainback | for lat,long coordinates shouldn't you do x' = x / cos(y0*Pi/180) | |
Nov 27, 2015 at 15:02 | comment | added | whuber | @Alex To limit the random locations to a circle (the boundary of a disk), you needn't "correct" anything: just set u=1 rather than generating it randomly. | |
Nov 27, 2015 at 10:47 | comment | added | Alex Punnen | I understood , u and v are the random fractions that limit the point;Putting it as 1 , gives you a point on the circle. Thanks. However what I am interested more is creating a set of latitudes and longitudes which are approximately some given distance away from a known point; Corrected implementation below. Thanks | |
Nov 4, 2015 at 12:57 | comment | added | whuber | @Alex I don't understand what you mean by "expanding" u, v, w, or t. The factor that governs distance is the radius r. You shouldn't ever generate u or v within any interval other than [0, 1]. | |
May 7, 2014 at 13:58 | comment | added | whuber | @eklam Thank you. I apologize for forgetting there are different conventions. It's good to know that the earth is not just 40 kilometers around :-). | |
May 7, 2014 at 0:51 | comment | added | RMalke | "there are about 111,300 meters in a degree" just for note the comma is used as thousand separator. radiusInDegrees=radius/111300 | |
May 22, 2012 at 8:27 | comment | added | pindleskin | I edited the question to show some java implementation of the formula | |
May 22, 2012 at 7:06 | vote | accept | pindleskin | ||
May 22, 2012 at 7:06 | comment | added | pindleskin | Great explanation whuber, that is what i needed to know. Now i am going to implement it. Thanks | |
May 21, 2012 at 16:39 | history | answered | whuber | CC BY-SA 3.0 |