Is there a way to generate uniformly distributed points on a sphere from a fixed amount of random real numbers per point? [duplicate] 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
Why didn't Eitri join the fight?
Is safe to use va_start macro with this as parameter?
Can anything be seen from the center of the Boötes void? How dark would it be?
Do jazz musicians improvise on the parent scale in addition to the chord-scales?
What is this building called? (It was built in 2002)
Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?
What's the meaning of "fortified infraction restraint"?
Fantasy story; one type of magic grows in power with use, but the more powerful they are, they more they are drawn to travel to their source
Do I really need to have a message in a novel to appeal to readers?
What is homebrew?
Amount of permutations on an NxNxN Rubik's Cube
Closed form of recurrent arithmetic series summation
How to tell that you are a giant?
For a new assistant professor in CS, how to build/manage a publication pipeline
When coming out of haste, do attackers have advantage on you?
Why are both D and D# fitting into my E minor key?
Does classifying an integer as a discrete log require it be part of a multiplicative group?
Crossing US/Canada Border for less than 24 hours
How could we fake a moon landing now?
What is the meaning of the simile “quick as silk”?
Using audio cues to encourage good posture
Most bit efficient text communication method?
Is it common practice to audition new musicians 1-2-1 before rehearsing with the entire band?
How to down pick a chord with skipped strings?
Is there a way to generate uniformly distributed points on a sphere from a fixed amount of random real numbers per point? [duplicate]
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 unit 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 Apr 13 at 18:43
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 5 more comments
$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 unit 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 Apr 13 at 18:43
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♦
Apr 12 at 0:30
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♦
Apr 12 at 0:32
$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
Apr 12 at 2:50
$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
Apr 12 at 7:54
$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♦
Apr 12 at 14:43
|
show 5 more comments
$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 unit 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 unit 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
Jam
5,02721432
5,02721432
asked Apr 12 at 0:22
The Zach ManThe Zach Man
1709
1709
marked as duplicate by Eric Towers, Lord Shark the Unknown, blub, José Carlos Santos, mrtaurho Apr 13 at 18:43
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 Apr 13 at 18:43
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♦
Apr 12 at 0:30
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♦
Apr 12 at 0:32
$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
Apr 12 at 2:50
$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
Apr 12 at 7:54
$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♦
Apr 12 at 14:43
|
show 5 more comments
$begingroup$
So what you want is a uniform distribution. It would be helpful to state this explicitly.
$endgroup$
– robjohn♦
Apr 12 at 0:30
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♦
Apr 12 at 0:32
$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
Apr 12 at 2:50
$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
Apr 12 at 7:54
$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♦
Apr 12 at 14:43
$begingroup$
So what you want is a uniform distribution. It would be helpful to state this explicitly.
$endgroup$
– robjohn♦
Apr 12 at 0:30
$begingroup$
So what you want is a uniform distribution. It would be helpful to state this explicitly.
$endgroup$
– robjohn♦
Apr 12 at 0:30
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♦
Apr 12 at 0:32
$begingroup$
Distribute longitude uniformly and the sine of the latitude uniformly. Then the distribution of points on the sphere will be uniform.
$endgroup$
– robjohn♦
Apr 12 at 0:32
$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
Apr 12 at 2:50
$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
Apr 12 at 2:50
$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
Apr 12 at 7:54
$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
Apr 12 at 7:54
$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♦
Apr 12 at 14:43
$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♦
Apr 12 at 14:43
|
show 5 more comments
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
user79126 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$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
EvilSnack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$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 Apr 12 at 2:34
robjohn♦robjohn
271k27316643
271k27316643
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 Apr 12 at 0:31
Misha LavrovMisha Lavrov
49.7k759109
49.7k759109
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 Apr 13 at 1:59
answered Apr 13 at 1:30
uhohuhoh
6671718
6671718
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
user79126 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$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
user79126 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$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
user79126 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$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
user79126 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user79126 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered Apr 12 at 9:59
user79126user79126
511
511
New contributor
user79126 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user79126 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
user79126 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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
EvilSnack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$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
EvilSnack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$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
EvilSnack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$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
EvilSnack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
EvilSnack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered Apr 13 at 3:19
EvilSnackEvilSnack
1012
1012
New contributor
EvilSnack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
EvilSnack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
EvilSnack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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♦
Apr 12 at 0:30
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♦
Apr 12 at 0:32
$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
Apr 12 at 2:50
$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
Apr 12 at 7:54
$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♦
Apr 12 at 14:43