Is there a way to generate uniformly distributed points on a sphere from a fixed amount of random real numbers per point? [duplicate] The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How to generate random points on a sphere?Is the Fibonacci lattice the very best way to evenly distribute N points on a sphere? So far it seems that it is the best?How to find a random axis or unit vector in 3D?Picking random points in the volume of sphere with uniform probabilityIs a sphere a closed set?Algorithm to generate random points in n-Sphere?Sampling on Axis-Aligned Spherical QuadRandom 3D points uniformly distributed on an ellipse shaped window of a sphereCompensating for distortion when projecting a 2D texture onto a sphereGenerate Uniformly Random Points on a Transformed SphereFind the relative radial position of a point within an ellipsoidGenerate uniformly distributed points in n-dimensional sphere
Wall plug outlet change
Do working physicists consider Newtonian mechanics to be "falsified"?
How does ice melt when immersed in water?
What do you call a plan that's an alternative plan in case your initial plan fails?
Segmentation fault output is suppressed when piping stdin into a function. Why?
He got a vote 80% that of Emmanuel Macron’s
When did F become S in typeography, and why?
how can a perfect fourth interval be considered either consonant or dissonant?
How can I define good in a religion that claims no moral authority?
Single author papers against my advisor's will?
Why is superheterodyning better than direct conversion?
Windows 10: How to Lock (not sleep) laptop on lid close?
Is there a writing software that you can sort scenes like slides in PowerPoint?
Why does the Event Horizon Telescope (EHT) not include telescopes from Africa, Asia or Australia?
Is every episode of "Where are my Pants?" identical?
Why did all the guest students take carriages to the Yule Ball?
Why is the object placed in the middle of the sentence here?
Can smartphones with the same camera sensor have different image quality?
Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?
How to test the equality of two Pearson correlation coefficients computed from the same sample?
What's the point in a preamp?
does high air pressure throw off wheel balance?
Was credit for the black hole image misattributed?
The variadic template constructor of my class cannot modify my class members, why is that so?
Is there a way to generate uniformly distributed points on a sphere from a fixed amount of random real numbers per point? [duplicate]
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How to generate random points on a sphere?Is the Fibonacci lattice the very best way to evenly distribute N points on a sphere? So far it seems that it is the best?How to find a random axis or unit vector in 3D?Picking random points in the volume of sphere with uniform probabilityIs a sphere a closed set?Algorithm to generate random points in n-Sphere?Sampling on Axis-Aligned Spherical QuadRandom 3D points uniformly distributed on an ellipse shaped window of a sphereCompensating for distortion when projecting a 2D texture onto a sphereGenerate Uniformly Random Points on a Transformed SphereFind the relative radial position of a point within an ellipsoidGenerate uniformly distributed points in n-dimensional sphere
$begingroup$
This question already has an answer here:
How to generate random points on a sphere?
6 answers
The obvious solution of Lattitude & Longitude doesn't work because it generates points more densely near the poles, and the other thing I came up with (Pick a random point in the unit cube, if it's in the sphere map it to the surface, and restart if it's outside) doesn't always find a point within a fixed number of tries.
geometry
$endgroup$
marked as duplicate by Eric Towers, Lord Shark the Unknown, blub, José Carlos Santos, mrtaurho 9 hours ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
|
show 1 more comment
$begingroup$
This question already has an answer here:
How to generate random points on a sphere?
6 answers
The obvious solution of Lattitude & Longitude doesn't work because it generates points more densely near the poles, and the other thing I came up with (Pick a random point in the unit cube, if it's in the sphere map it to the surface, and restart if it's outside) doesn't always find a point within a fixed number of tries.
geometry
$endgroup$
marked as duplicate by Eric Towers, Lord Shark the Unknown, blub, José Carlos Santos, mrtaurho 9 hours ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
$begingroup$
So what you want is a uniform distribution. It would be helpful to state this explicitly.
$endgroup$
– robjohn♦
2 days ago
6
$begingroup$
Distribute longitude uniformly and the sine of the latitude uniformly. Then the distribution of points on the sphere will be uniform.
$endgroup$
– robjohn♦
2 days ago
$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
2 days ago
$begingroup$
"A uniformly distributed point" is an oxymoron, is it not? If not, then I suggest (r,theta,phi) = (1,0,0), which was drawn from my secret uniform distribution :P
$endgroup$
– Marius Ladegård Meyer
yesterday
$begingroup$
@MariusLadegårdMeyer: okay, I've adjusted the title further. I had tried to make as small a change that would make the uniform distribution clear. Of course, now the idea of a fixed number of random numbers per point is muddied.
$endgroup$
– robjohn♦
yesterday
|
show 1 more comment
$begingroup$
This question already has an answer here:
How to generate random points on a sphere?
6 answers
The obvious solution of Lattitude & Longitude doesn't work because it generates points more densely near the poles, and the other thing I came up with (Pick a random point in the unit cube, if it's in the sphere map it to the surface, and restart if it's outside) doesn't always find a point within a fixed number of tries.
geometry
$endgroup$
This question already has an answer here:
How to generate random points on a sphere?
6 answers
The obvious solution of Lattitude & Longitude doesn't work because it generates points more densely near the poles, and the other thing I came up with (Pick a random point in the unit cube, if it's in the sphere map it to the surface, and restart if it's outside) doesn't always find a point within a fixed number of tries.
This question already has an answer here:
How to generate random points on a sphere?
6 answers
geometry
geometry
edited yesterday
robjohn♦
271k27314643
271k27314643
asked 2 days ago
The Zach ManThe Zach Man
1709
1709
marked as duplicate by Eric Towers, Lord Shark the Unknown, blub, José Carlos Santos, mrtaurho 9 hours ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Eric Towers, Lord Shark the Unknown, blub, José Carlos Santos, mrtaurho 9 hours ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
$begingroup$
So what you want is a uniform distribution. It would be helpful to state this explicitly.
$endgroup$
– robjohn♦
2 days ago
6
$begingroup$
Distribute longitude uniformly and the sine of the latitude uniformly. Then the distribution of points on the sphere will be uniform.
$endgroup$
– robjohn♦
2 days ago
$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
2 days ago
$begingroup$
"A uniformly distributed point" is an oxymoron, is it not? If not, then I suggest (r,theta,phi) = (1,0,0), which was drawn from my secret uniform distribution :P
$endgroup$
– Marius Ladegård Meyer
yesterday
$begingroup$
@MariusLadegårdMeyer: okay, I've adjusted the title further. I had tried to make as small a change that would make the uniform distribution clear. Of course, now the idea of a fixed number of random numbers per point is muddied.
$endgroup$
– robjohn♦
yesterday
|
show 1 more comment
$begingroup$
So what you want is a uniform distribution. It would be helpful to state this explicitly.
$endgroup$
– robjohn♦
2 days ago
6
$begingroup$
Distribute longitude uniformly and the sine of the latitude uniformly. Then the distribution of points on the sphere will be uniform.
$endgroup$
– robjohn♦
2 days ago
$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
2 days ago
$begingroup$
"A uniformly distributed point" is an oxymoron, is it not? If not, then I suggest (r,theta,phi) = (1,0,0), which was drawn from my secret uniform distribution :P
$endgroup$
– Marius Ladegård Meyer
yesterday
$begingroup$
@MariusLadegårdMeyer: okay, I've adjusted the title further. I had tried to make as small a change that would make the uniform distribution clear. Of course, now the idea of a fixed number of random numbers per point is muddied.
$endgroup$
– robjohn♦
yesterday
$begingroup$
So what you want is a uniform distribution. It would be helpful to state this explicitly.
$endgroup$
– robjohn♦
2 days ago
$begingroup$
So what you want is a uniform distribution. It would be helpful to state this explicitly.
$endgroup$
– robjohn♦
2 days ago
6
6
$begingroup$
Distribute longitude uniformly and the sine of the latitude uniformly. Then the distribution of points on the sphere will be uniform.
$endgroup$
– robjohn♦
2 days ago
$begingroup$
Distribute longitude uniformly and the sine of the latitude uniformly. Then the distribution of points on the sphere will be uniform.
$endgroup$
– robjohn♦
2 days ago
$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
2 days ago
$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
2 days ago
$begingroup$
"A uniformly distributed point" is an oxymoron, is it not? If not, then I suggest (r,theta,phi) = (1,0,0), which was drawn from my secret uniform distribution :P
$endgroup$
– Marius Ladegård Meyer
yesterday
$begingroup$
"A uniformly distributed point" is an oxymoron, is it not? If not, then I suggest (r,theta,phi) = (1,0,0), which was drawn from my secret uniform distribution :P
$endgroup$
– Marius Ladegård Meyer
yesterday
$begingroup$
@MariusLadegårdMeyer: okay, I've adjusted the title further. I had tried to make as small a change that would make the uniform distribution clear. Of course, now the idea of a fixed number of random numbers per point is muddied.
$endgroup$
– robjohn♦
yesterday
$begingroup$
@MariusLadegårdMeyer: okay, I've adjusted the title further. I had tried to make as small a change that would make the uniform distribution clear. Of course, now the idea of a fixed number of random numbers per point is muddied.
$endgroup$
– robjohn♦
yesterday
|
show 1 more comment
5 Answers
5
active
oldest
votes
$begingroup$
The Lambert cylindrical equal area projection maps the sphere to a cylinder, area to equal area. It is easy to generate a uniform distribution on a cylinder. Simply map it back to the sphere.
For $(u_1,u_2)$ uniform on $[0,1]^2$, either
$mathrmlat=arcsin(2u_1-1),mathrmlon=2pi u_2$
or
$z=2u_1-1,x=sqrt1-z^2cos(2pi u_2),y=sqrt1-z^2sin(2pi u_2)$
$endgroup$
add a comment |
$begingroup$
Your method, even though it doesn't finish in a fixed number of times, is a reasonable way to do it. Each trial succeeds with probability $fracpi6$, which is better than $frac12$: the average number of trials is less than $2$.
Another standard method is to use the normal distribution. Generate $x, y, z$ independently from a standard normal distribution, then take the point $(x,y,z)$ and divide it by $sqrtx^2+y^2+z^2$ as you did for points inside the cube. The multivariate normal distribution is rotationally symmetric, so this will get you evenly distributed points on the sphere.
(The Box–Muller transform is one way to generate normally distributed random numbers, and some versions of it do not use rejection sampling, so they can be done with a "fixed amount" of randomness.)
$endgroup$
add a comment |
$begingroup$
Is there a way to generate uniformly distributed points on a sphere from a fixed amount of random real numbers per point?
This Stack Overflow answer mentions the Fibonacci sphere algorithm, and the currently unanswered Math SE question Is the Fibonacci lattice the very best way to evenly distribute N points on a sphere? So far it seems that it is the best? contains several excellent links in the question and in comments.
The method is deterministic, using either zero or one random number, no matter the number of points generated.
Florida State University's John Burkardt's web page Fibonacci Spiral Grid on a Sphere provides some references and examples of code implementations.
Edward Saff, Arno Kuijlaars,
Distributing Many Points on a Sphere,
The Mathematical Intelligencer,
Volume 19, Number 1, 1997, pages 5-11.
Richard Swinbank, James Purser,
Fibonacci grids: A novel approach to global modelling,
Quarterly Journal of the Royal Meteorological Society,
Volume 132, Number 619, July 2006 Part B, pages 1769-1793.
Extreme Learning's Evenly distributing points on a sphere addresses several criteria for judging the level of uniformity provided by different solutions, and describes the process of first generating a Fibonacci grid and then transforming it to a sphere.
An example of these Fibonacci Grids is shown below. These points sets can be transformed to a well-known Fibonacci spirals via the transformation
I can't be sure it will be sufficiently uniform for you, but it certainly looks nice!
Source
$endgroup$
add a comment |
$begingroup$
You can still use the longitude/latitude method. You just need to transform the latitude such that the probability of falling in any given latitude band is proportional to its surface area.
The length of the circumference at a latitude, l, is proportional to cos(l). (0 at -90 degrees, max at the equator, 0 at +90 degrees). Therefore, by integrating we know that the total surface area between any two latitudes, l1 and l2, is proportional to sin(l2) - sin(l1).
By inverting that, we arrive at a formula for transforming a [0, 1] uniform random variable (X) into a latitude such that any point on the sphere is equally likely to be selected:
latitude = arcsin(2X - 1)
New contributor
$endgroup$
add a comment |
$begingroup$
Your second method can be improved in this way: Select the three coordinates (x, y, z) in a linear distribution from -1 to 1.
If (y * y + z * z) > 1, select replacements for these two only. (You will only have to re-roll them 4-pi/4 (roughly 21.4%) of the time; average random numbers used is 1 + 8/pi = ~ 3.546.
Keep x as it is, scale both y and z by sqrt((1 - x * x)/(y * y + z * z)).
New contributor
$endgroup$
add a comment |
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
The Lambert cylindrical equal area projection maps the sphere to a cylinder, area to equal area. It is easy to generate a uniform distribution on a cylinder. Simply map it back to the sphere.
For $(u_1,u_2)$ uniform on $[0,1]^2$, either
$mathrmlat=arcsin(2u_1-1),mathrmlon=2pi u_2$
or
$z=2u_1-1,x=sqrt1-z^2cos(2pi u_2),y=sqrt1-z^2sin(2pi u_2)$
$endgroup$
add a comment |
$begingroup$
The Lambert cylindrical equal area projection maps the sphere to a cylinder, area to equal area. It is easy to generate a uniform distribution on a cylinder. Simply map it back to the sphere.
For $(u_1,u_2)$ uniform on $[0,1]^2$, either
$mathrmlat=arcsin(2u_1-1),mathrmlon=2pi u_2$
or
$z=2u_1-1,x=sqrt1-z^2cos(2pi u_2),y=sqrt1-z^2sin(2pi u_2)$
$endgroup$
add a comment |
$begingroup$
The Lambert cylindrical equal area projection maps the sphere to a cylinder, area to equal area. It is easy to generate a uniform distribution on a cylinder. Simply map it back to the sphere.
For $(u_1,u_2)$ uniform on $[0,1]^2$, either
$mathrmlat=arcsin(2u_1-1),mathrmlon=2pi u_2$
or
$z=2u_1-1,x=sqrt1-z^2cos(2pi u_2),y=sqrt1-z^2sin(2pi u_2)$
$endgroup$
The Lambert cylindrical equal area projection maps the sphere to a cylinder, area to equal area. It is easy to generate a uniform distribution on a cylinder. Simply map it back to the sphere.
For $(u_1,u_2)$ uniform on $[0,1]^2$, either
$mathrmlat=arcsin(2u_1-1),mathrmlon=2pi u_2$
or
$z=2u_1-1,x=sqrt1-z^2cos(2pi u_2),y=sqrt1-z^2sin(2pi u_2)$
answered 2 days ago
robjohn♦robjohn
271k27314643
271k27314643
add a comment |
add a comment |
$begingroup$
Your method, even though it doesn't finish in a fixed number of times, is a reasonable way to do it. Each trial succeeds with probability $fracpi6$, which is better than $frac12$: the average number of trials is less than $2$.
Another standard method is to use the normal distribution. Generate $x, y, z$ independently from a standard normal distribution, then take the point $(x,y,z)$ and divide it by $sqrtx^2+y^2+z^2$ as you did for points inside the cube. The multivariate normal distribution is rotationally symmetric, so this will get you evenly distributed points on the sphere.
(The Box–Muller transform is one way to generate normally distributed random numbers, and some versions of it do not use rejection sampling, so they can be done with a "fixed amount" of randomness.)
$endgroup$
add a comment |
$begingroup$
Your method, even though it doesn't finish in a fixed number of times, is a reasonable way to do it. Each trial succeeds with probability $fracpi6$, which is better than $frac12$: the average number of trials is less than $2$.
Another standard method is to use the normal distribution. Generate $x, y, z$ independently from a standard normal distribution, then take the point $(x,y,z)$ and divide it by $sqrtx^2+y^2+z^2$ as you did for points inside the cube. The multivariate normal distribution is rotationally symmetric, so this will get you evenly distributed points on the sphere.
(The Box–Muller transform is one way to generate normally distributed random numbers, and some versions of it do not use rejection sampling, so they can be done with a "fixed amount" of randomness.)
$endgroup$
add a comment |
$begingroup$
Your method, even though it doesn't finish in a fixed number of times, is a reasonable way to do it. Each trial succeeds with probability $fracpi6$, which is better than $frac12$: the average number of trials is less than $2$.
Another standard method is to use the normal distribution. Generate $x, y, z$ independently from a standard normal distribution, then take the point $(x,y,z)$ and divide it by $sqrtx^2+y^2+z^2$ as you did for points inside the cube. The multivariate normal distribution is rotationally symmetric, so this will get you evenly distributed points on the sphere.
(The Box–Muller transform is one way to generate normally distributed random numbers, and some versions of it do not use rejection sampling, so they can be done with a "fixed amount" of randomness.)
$endgroup$
Your method, even though it doesn't finish in a fixed number of times, is a reasonable way to do it. Each trial succeeds with probability $fracpi6$, which is better than $frac12$: the average number of trials is less than $2$.
Another standard method is to use the normal distribution. Generate $x, y, z$ independently from a standard normal distribution, then take the point $(x,y,z)$ and divide it by $sqrtx^2+y^2+z^2$ as you did for points inside the cube. The multivariate normal distribution is rotationally symmetric, so this will get you evenly distributed points on the sphere.
(The Box–Muller transform is one way to generate normally distributed random numbers, and some versions of it do not use rejection sampling, so they can be done with a "fixed amount" of randomness.)
answered 2 days ago
Misha LavrovMisha Lavrov
49.3k757108
49.3k757108
add a comment |
add a comment |
$begingroup$
Is there a way to generate uniformly distributed points on a sphere from a fixed amount of random real numbers per point?
This Stack Overflow answer mentions the Fibonacci sphere algorithm, and the currently unanswered Math SE question Is the Fibonacci lattice the very best way to evenly distribute N points on a sphere? So far it seems that it is the best? contains several excellent links in the question and in comments.
The method is deterministic, using either zero or one random number, no matter the number of points generated.
Florida State University's John Burkardt's web page Fibonacci Spiral Grid on a Sphere provides some references and examples of code implementations.
Edward Saff, Arno Kuijlaars,
Distributing Many Points on a Sphere,
The Mathematical Intelligencer,
Volume 19, Number 1, 1997, pages 5-11.
Richard Swinbank, James Purser,
Fibonacci grids: A novel approach to global modelling,
Quarterly Journal of the Royal Meteorological Society,
Volume 132, Number 619, July 2006 Part B, pages 1769-1793.
Extreme Learning's Evenly distributing points on a sphere addresses several criteria for judging the level of uniformity provided by different solutions, and describes the process of first generating a Fibonacci grid and then transforming it to a sphere.
An example of these Fibonacci Grids is shown below. These points sets can be transformed to a well-known Fibonacci spirals via the transformation
I can't be sure it will be sufficiently uniform for you, but it certainly looks nice!
Source
$endgroup$
add a comment |
$begingroup$
Is there a way to generate uniformly distributed points on a sphere from a fixed amount of random real numbers per point?
This Stack Overflow answer mentions the Fibonacci sphere algorithm, and the currently unanswered Math SE question Is the Fibonacci lattice the very best way to evenly distribute N points on a sphere? So far it seems that it is the best? contains several excellent links in the question and in comments.
The method is deterministic, using either zero or one random number, no matter the number of points generated.
Florida State University's John Burkardt's web page Fibonacci Spiral Grid on a Sphere provides some references and examples of code implementations.
Edward Saff, Arno Kuijlaars,
Distributing Many Points on a Sphere,
The Mathematical Intelligencer,
Volume 19, Number 1, 1997, pages 5-11.
Richard Swinbank, James Purser,
Fibonacci grids: A novel approach to global modelling,
Quarterly Journal of the Royal Meteorological Society,
Volume 132, Number 619, July 2006 Part B, pages 1769-1793.
Extreme Learning's Evenly distributing points on a sphere addresses several criteria for judging the level of uniformity provided by different solutions, and describes the process of first generating a Fibonacci grid and then transforming it to a sphere.
An example of these Fibonacci Grids is shown below. These points sets can be transformed to a well-known Fibonacci spirals via the transformation
I can't be sure it will be sufficiently uniform for you, but it certainly looks nice!
Source
$endgroup$
add a comment |
$begingroup$
Is there a way to generate uniformly distributed points on a sphere from a fixed amount of random real numbers per point?
This Stack Overflow answer mentions the Fibonacci sphere algorithm, and the currently unanswered Math SE question Is the Fibonacci lattice the very best way to evenly distribute N points on a sphere? So far it seems that it is the best? contains several excellent links in the question and in comments.
The method is deterministic, using either zero or one random number, no matter the number of points generated.
Florida State University's John Burkardt's web page Fibonacci Spiral Grid on a Sphere provides some references and examples of code implementations.
Edward Saff, Arno Kuijlaars,
Distributing Many Points on a Sphere,
The Mathematical Intelligencer,
Volume 19, Number 1, 1997, pages 5-11.
Richard Swinbank, James Purser,
Fibonacci grids: A novel approach to global modelling,
Quarterly Journal of the Royal Meteorological Society,
Volume 132, Number 619, July 2006 Part B, pages 1769-1793.
Extreme Learning's Evenly distributing points on a sphere addresses several criteria for judging the level of uniformity provided by different solutions, and describes the process of first generating a Fibonacci grid and then transforming it to a sphere.
An example of these Fibonacci Grids is shown below. These points sets can be transformed to a well-known Fibonacci spirals via the transformation
I can't be sure it will be sufficiently uniform for you, but it certainly looks nice!
Source
$endgroup$
Is there a way to generate uniformly distributed points on a sphere from a fixed amount of random real numbers per point?
This Stack Overflow answer mentions the Fibonacci sphere algorithm, and the currently unanswered Math SE question Is the Fibonacci lattice the very best way to evenly distribute N points on a sphere? So far it seems that it is the best? contains several excellent links in the question and in comments.
The method is deterministic, using either zero or one random number, no matter the number of points generated.
Florida State University's John Burkardt's web page Fibonacci Spiral Grid on a Sphere provides some references and examples of code implementations.
Edward Saff, Arno Kuijlaars,
Distributing Many Points on a Sphere,
The Mathematical Intelligencer,
Volume 19, Number 1, 1997, pages 5-11.
Richard Swinbank, James Purser,
Fibonacci grids: A novel approach to global modelling,
Quarterly Journal of the Royal Meteorological Society,
Volume 132, Number 619, July 2006 Part B, pages 1769-1793.
Extreme Learning's Evenly distributing points on a sphere addresses several criteria for judging the level of uniformity provided by different solutions, and describes the process of first generating a Fibonacci grid and then transforming it to a sphere.
An example of these Fibonacci Grids is shown below. These points sets can be transformed to a well-known Fibonacci spirals via the transformation
I can't be sure it will be sufficiently uniform for you, but it certainly looks nice!
Source
edited yesterday
answered yesterday
uhohuhoh
6571718
6571718
add a comment |
add a comment |
$begingroup$
You can still use the longitude/latitude method. You just need to transform the latitude such that the probability of falling in any given latitude band is proportional to its surface area.
The length of the circumference at a latitude, l, is proportional to cos(l). (0 at -90 degrees, max at the equator, 0 at +90 degrees). Therefore, by integrating we know that the total surface area between any two latitudes, l1 and l2, is proportional to sin(l2) - sin(l1).
By inverting that, we arrive at a formula for transforming a [0, 1] uniform random variable (X) into a latitude such that any point on the sphere is equally likely to be selected:
latitude = arcsin(2X - 1)
New contributor
$endgroup$
add a comment |
$begingroup$
You can still use the longitude/latitude method. You just need to transform the latitude such that the probability of falling in any given latitude band is proportional to its surface area.
The length of the circumference at a latitude, l, is proportional to cos(l). (0 at -90 degrees, max at the equator, 0 at +90 degrees). Therefore, by integrating we know that the total surface area between any two latitudes, l1 and l2, is proportional to sin(l2) - sin(l1).
By inverting that, we arrive at a formula for transforming a [0, 1] uniform random variable (X) into a latitude such that any point on the sphere is equally likely to be selected:
latitude = arcsin(2X - 1)
New contributor
$endgroup$
add a comment |
$begingroup$
You can still use the longitude/latitude method. You just need to transform the latitude such that the probability of falling in any given latitude band is proportional to its surface area.
The length of the circumference at a latitude, l, is proportional to cos(l). (0 at -90 degrees, max at the equator, 0 at +90 degrees). Therefore, by integrating we know that the total surface area between any two latitudes, l1 and l2, is proportional to sin(l2) - sin(l1).
By inverting that, we arrive at a formula for transforming a [0, 1] uniform random variable (X) into a latitude such that any point on the sphere is equally likely to be selected:
latitude = arcsin(2X - 1)
New contributor
$endgroup$
You can still use the longitude/latitude method. You just need to transform the latitude such that the probability of falling in any given latitude band is proportional to its surface area.
The length of the circumference at a latitude, l, is proportional to cos(l). (0 at -90 degrees, max at the equator, 0 at +90 degrees). Therefore, by integrating we know that the total surface area between any two latitudes, l1 and l2, is proportional to sin(l2) - sin(l1).
By inverting that, we arrive at a formula for transforming a [0, 1] uniform random variable (X) into a latitude such that any point on the sphere is equally likely to be selected:
latitude = arcsin(2X - 1)
New contributor
New contributor
answered yesterday
user79126user79126
411
411
New contributor
New contributor
add a comment |
add a comment |
$begingroup$
Your second method can be improved in this way: Select the three coordinates (x, y, z) in a linear distribution from -1 to 1.
If (y * y + z * z) > 1, select replacements for these two only. (You will only have to re-roll them 4-pi/4 (roughly 21.4%) of the time; average random numbers used is 1 + 8/pi = ~ 3.546.
Keep x as it is, scale both y and z by sqrt((1 - x * x)/(y * y + z * z)).
New contributor
$endgroup$
add a comment |
$begingroup$
Your second method can be improved in this way: Select the three coordinates (x, y, z) in a linear distribution from -1 to 1.
If (y * y + z * z) > 1, select replacements for these two only. (You will only have to re-roll them 4-pi/4 (roughly 21.4%) of the time; average random numbers used is 1 + 8/pi = ~ 3.546.
Keep x as it is, scale both y and z by sqrt((1 - x * x)/(y * y + z * z)).
New contributor
$endgroup$
add a comment |
$begingroup$
Your second method can be improved in this way: Select the three coordinates (x, y, z) in a linear distribution from -1 to 1.
If (y * y + z * z) > 1, select replacements for these two only. (You will only have to re-roll them 4-pi/4 (roughly 21.4%) of the time; average random numbers used is 1 + 8/pi = ~ 3.546.
Keep x as it is, scale both y and z by sqrt((1 - x * x)/(y * y + z * z)).
New contributor
$endgroup$
Your second method can be improved in this way: Select the three coordinates (x, y, z) in a linear distribution from -1 to 1.
If (y * y + z * z) > 1, select replacements for these two only. (You will only have to re-roll them 4-pi/4 (roughly 21.4%) of the time; average random numbers used is 1 + 8/pi = ~ 3.546.
Keep x as it is, scale both y and z by sqrt((1 - x * x)/(y * y + z * z)).
New contributor
New contributor
answered yesterday
EvilSnackEvilSnack
1012
1012
New contributor
New contributor
add a comment |
add a comment |
$begingroup$
So what you want is a uniform distribution. It would be helpful to state this explicitly.
$endgroup$
– robjohn♦
2 days ago
6
$begingroup$
Distribute longitude uniformly and the sine of the latitude uniformly. Then the distribution of points on the sphere will be uniform.
$endgroup$
– robjohn♦
2 days ago
$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
2 days ago
$begingroup$
"A uniformly distributed point" is an oxymoron, is it not? If not, then I suggest (r,theta,phi) = (1,0,0), which was drawn from my secret uniform distribution :P
$endgroup$
– Marius Ladegård Meyer
yesterday
$begingroup$
@MariusLadegårdMeyer: okay, I've adjusted the title further. I had tried to make as small a change that would make the uniform distribution clear. Of course, now the idea of a fixed number of random numbers per point is muddied.
$endgroup$
– robjohn♦
yesterday