Is there a way to generate a point on a sphere from a fixed amount of random real numbers? The...

Why can't devices on different VLANs, but on the same subnet, communicate?

Will it cause any balance problems to have PCs level up and gain the benefits of a long rest mid-fight?

Why couldn't they take pictures of a closer black hole?

How much of the clove should I use when using big garlic heads?

Why isn't the circumferential light around the M87 black hole's event horizon symmetric?

Time travel alters history but people keep saying nothing's changed

Cooking pasta in a water boiler

Why is the maximum length of OpenWrt’s root password 8 characters?

What does Linus Torvalds mean when he says that Git "never ever" tracks a file?

What is the motivation for a law requiring 2 parties to consent for recording a conversation

Kerning for subscripts of sigma?

Did any laptop computers have a built-in 5 1/4 inch floppy drive?

A word that means fill it to the required quantity

Correct punctuation for showing a character's confusion

What is the meaning of Triage in Cybersec world?

Is it safe to harvest rainwater that fell on solar panels?

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

Does adding complexity mean a more secure cipher?

Dropping list elements from nested list after evaluation

Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?

Does HR tell a hiring manager about salary negotiations?

Is an up-to-date browser secure on an out-of-date OS?

Why not take a picture of a closer black hole?

Are there any other methods to apply to solving simultaneous equations?



Is there a way to generate a point on a sphere from a fixed amount of random real numbers?



The 2019 Stack Overflow Developer Survey Results Are InHow 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?Random Point Sampling From a Set with Certain GeometryHow to Create a Plane Inside A CubeAlgorithm 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 sphereFind the relative radial position of a point within an ellipsoid












2












$begingroup$


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.










share|cite|improve this question









$endgroup$












  • $begingroup$
    So what you want is a uniform distribution. It would be helpful to state this explicitly.
    $endgroup$
    – robjohn
    2 hours ago






  • 1




    $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 hours ago










  • $begingroup$
    @robjohn thank you, you're right that I forgot to specify that.
    $endgroup$
    – The Zach Man
    18 mins ago
















2












$begingroup$


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.










share|cite|improve this question









$endgroup$












  • $begingroup$
    So what you want is a uniform distribution. It would be helpful to state this explicitly.
    $endgroup$
    – robjohn
    2 hours ago






  • 1




    $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 hours ago










  • $begingroup$
    @robjohn thank you, you're right that I forgot to specify that.
    $endgroup$
    – The Zach Man
    18 mins ago














2












2








2


1



$begingroup$


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.










share|cite|improve this question









$endgroup$




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






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked 2 hours ago









The Zach ManThe Zach Man

1007




1007












  • $begingroup$
    So what you want is a uniform distribution. It would be helpful to state this explicitly.
    $endgroup$
    – robjohn
    2 hours ago






  • 1




    $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 hours ago










  • $begingroup$
    @robjohn thank you, you're right that I forgot to specify that.
    $endgroup$
    – The Zach Man
    18 mins ago


















  • $begingroup$
    So what you want is a uniform distribution. It would be helpful to state this explicitly.
    $endgroup$
    – robjohn
    2 hours ago






  • 1




    $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 hours ago










  • $begingroup$
    @robjohn thank you, you're right that I forgot to specify that.
    $endgroup$
    – The Zach Man
    18 mins ago
















$begingroup$
So what you want is a uniform distribution. It would be helpful to state this explicitly.
$endgroup$
– robjohn
2 hours ago




$begingroup$
So what you want is a uniform distribution. It would be helpful to state this explicitly.
$endgroup$
– robjohn
2 hours ago




1




1




$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 hours 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 hours ago












$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
18 mins ago




$begingroup$
@robjohn thank you, you're right that I forgot to specify that.
$endgroup$
– The Zach Man
18 mins ago










2 Answers
2






active

oldest

votes


















2












$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



$mathrm{lat}=arcsin(2u_1-1),mathrm{lon}=2pi u_2$



or



$z=2u_1-1,x=sqrt{1-z^2}cos(2pi u_2),y=sqrt{1-z^2}sin(2pi u_2)$






share|cite|improve this answer









$endgroup$





















    2












    $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 $sqrt{x^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.)






    share|cite|improve this answer









    $endgroup$














      Your Answer





      StackExchange.ifUsing("editor", function () {
      return StackExchange.using("mathjaxEditing", function () {
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      });
      });
      }, "mathjax-editing");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "69"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      noCode: true, onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3184449%2fis-there-a-way-to-generate-a-point-on-a-sphere-from-a-fixed-amount-of-random-rea%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2












      $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



      $mathrm{lat}=arcsin(2u_1-1),mathrm{lon}=2pi u_2$



      or



      $z=2u_1-1,x=sqrt{1-z^2}cos(2pi u_2),y=sqrt{1-z^2}sin(2pi u_2)$






      share|cite|improve this answer









      $endgroup$


















        2












        $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



        $mathrm{lat}=arcsin(2u_1-1),mathrm{lon}=2pi u_2$



        or



        $z=2u_1-1,x=sqrt{1-z^2}cos(2pi u_2),y=sqrt{1-z^2}sin(2pi u_2)$






        share|cite|improve this answer









        $endgroup$
















          2












          2








          2





          $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



          $mathrm{lat}=arcsin(2u_1-1),mathrm{lon}=2pi u_2$



          or



          $z=2u_1-1,x=sqrt{1-z^2}cos(2pi u_2),y=sqrt{1-z^2}sin(2pi u_2)$






          share|cite|improve this answer









          $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



          $mathrm{lat}=arcsin(2u_1-1),mathrm{lon}=2pi u_2$



          or



          $z=2u_1-1,x=sqrt{1-z^2}cos(2pi u_2),y=sqrt{1-z^2}sin(2pi u_2)$







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered 33 mins ago









          robjohnrobjohn

          271k27313642




          271k27313642























              2












              $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 $sqrt{x^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.)






              share|cite|improve this answer









              $endgroup$


















                2












                $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 $sqrt{x^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.)






                share|cite|improve this answer









                $endgroup$
















                  2












                  2








                  2





                  $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 $sqrt{x^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.)






                  share|cite|improve this answer









                  $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 $sqrt{x^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.)







                  share|cite|improve this answer












                  share|cite|improve this answer



                  share|cite|improve this answer










                  answered 2 hours ago









                  Misha LavrovMisha Lavrov

                  49k757107




                  49k757107






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Mathematics Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      Use MathJax to format equations. MathJax reference.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3184449%2fis-there-a-way-to-generate-a-point-on-a-sphere-from-a-fixed-amount-of-random-rea%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      ORA-01691 (unable to extend lob segment) even though my tablespace has AUTOEXTEND onORA-01692: unable to...

                      Always On Availability groups resolving state after failover - Remote harden of transaction...

                      Circunscripción electoral de Guipúzcoa Referencias Menú de navegaciónLas claves del sistema electoral en...