Simulating rnorm() using runif()Simulating responses from a factorial experiment for power analysisHow to do simulation of Probit link?Modelling diminishing returns of investments using regression modelsWhat to do if time series data remains autocorrelated?Raw data outperforms Z-score transformed data in SVM classificationSimulating probability of choosing the right answerSimulate AR(1) process in R with specified nonzero mean and AR coefficientNon-Linear Regression using nls() for Double Slit DiffractionPredicting / conditional sampling with Vine CopulaCreating sample data set of quiz with n number of questions and set number of students using R

RegionDifference for Cylinder and Cuboid

Where is the 1/8 CR apprentice in Volo's Guide to Monsters?

Humanity loses the vast majority of its technology, information, and population in the year 2122. How long does it take to rebuild itself?

Implicit nil checks in algorithms

Citation at the bottom for subfigures in beamer frame

Happy pi day, everyone!

Provisioning profile doesn't include the application-identifier and keychain-access-groups entitlements

How could a scammer know the apps on my phone / iTunes account?

Sword in the Stone story where the sword was held in place by electromagnets

Is a lawful good "antagonist" effective?

Welcoming 2019 Pi day: How to draw the letter π?

Is Mortgage interest accrued after a December payment tax deductible?

Can hydraulic brake levers get hot when brakes overheat?

The use of "touch" and "touch on" in context

Why would a flight no longer considered airworthy be redirected like this?

Life insurance that covers only simultaneous/dual deaths

What do these Greek words say? Possibly 2nd century

What is IP squat space

Co-worker team leader wants to inject his friend's awful software into our development. What should I say to our common boss?

Is it true that real estate prices mainly go up?

Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?

Counting certain elements in lists

Why did it take so long to abandon sail after steamships were demonstrated?

My adviser wants to be the first author



Simulating rnorm() using runif()


Simulating responses from a factorial experiment for power analysisHow to do simulation of Probit link?Modelling diminishing returns of investments using regression modelsWhat to do if time series data remains autocorrelated?Raw data outperforms Z-score transformed data in SVM classificationSimulating probability of choosing the right answerSimulate AR(1) process in R with specified nonzero mean and AR coefficientNon-Linear Regression using nls() for Double Slit DiffractionPredicting / conditional sampling with Vine CopulaCreating sample data set of quiz with n number of questions and set number of students using R













3












$begingroup$


I am trying to 'simulate' rnorm() using only runif().



I don't know if I should do:



sqrt(-2*log(U1))*cos(U2)


or



sqrt(-2*log(U1))*sin(U2)


Where U1 is a runif(0,1) and U2 runif(0,6.28)



I do not know if I should do it using cos or sin, or is it that I need to sample from one and the other consecutively? What is the mathematical logic behind it?










share|cite|improve this question









New contributor




Chicago1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$











  • $begingroup$
    You will want to investigate the Probability Integral Transform.
    $endgroup$
    – StatsStudent
    6 hours ago










  • $begingroup$
    Because $cos(U_2)$ is the horizontal coordinate of a point uniformly distributed on the unit circle and $sin(U_2)$ is its vertical coordinate, notice that the symmetry of the circle under a switch of coordinates implies $cos(U_2)$ and $sin(U_2)$ are identically distributed. Thus, your two methods are equivalent (assuming, anyway, that you replace "6.28" by $2pi$).
    $endgroup$
    – whuber
    3 hours ago















3












$begingroup$


I am trying to 'simulate' rnorm() using only runif().



I don't know if I should do:



sqrt(-2*log(U1))*cos(U2)


or



sqrt(-2*log(U1))*sin(U2)


Where U1 is a runif(0,1) and U2 runif(0,6.28)



I do not know if I should do it using cos or sin, or is it that I need to sample from one and the other consecutively? What is the mathematical logic behind it?










share|cite|improve this question









New contributor




Chicago1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$











  • $begingroup$
    You will want to investigate the Probability Integral Transform.
    $endgroup$
    – StatsStudent
    6 hours ago










  • $begingroup$
    Because $cos(U_2)$ is the horizontal coordinate of a point uniformly distributed on the unit circle and $sin(U_2)$ is its vertical coordinate, notice that the symmetry of the circle under a switch of coordinates implies $cos(U_2)$ and $sin(U_2)$ are identically distributed. Thus, your two methods are equivalent (assuming, anyway, that you replace "6.28" by $2pi$).
    $endgroup$
    – whuber
    3 hours ago













3












3








3





$begingroup$


I am trying to 'simulate' rnorm() using only runif().



I don't know if I should do:



sqrt(-2*log(U1))*cos(U2)


or



sqrt(-2*log(U1))*sin(U2)


Where U1 is a runif(0,1) and U2 runif(0,6.28)



I do not know if I should do it using cos or sin, or is it that I need to sample from one and the other consecutively? What is the mathematical logic behind it?










share|cite|improve this question









New contributor




Chicago1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




I am trying to 'simulate' rnorm() using only runif().



I don't know if I should do:



sqrt(-2*log(U1))*cos(U2)


or



sqrt(-2*log(U1))*sin(U2)


Where U1 is a runif(0,1) and U2 runif(0,6.28)



I do not know if I should do it using cos or sin, or is it that I need to sample from one and the other consecutively? What is the mathematical logic behind it?







r normalization






share|cite|improve this question









New contributor




Chicago1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|cite|improve this question









New contributor




Chicago1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|cite|improve this question




share|cite|improve this question








edited 4 hours ago









masoud

74




74






New contributor




Chicago1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 7 hours ago









Chicago1988Chicago1988

162




162




New contributor




Chicago1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Chicago1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Chicago1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • $begingroup$
    You will want to investigate the Probability Integral Transform.
    $endgroup$
    – StatsStudent
    6 hours ago










  • $begingroup$
    Because $cos(U_2)$ is the horizontal coordinate of a point uniformly distributed on the unit circle and $sin(U_2)$ is its vertical coordinate, notice that the symmetry of the circle under a switch of coordinates implies $cos(U_2)$ and $sin(U_2)$ are identically distributed. Thus, your two methods are equivalent (assuming, anyway, that you replace "6.28" by $2pi$).
    $endgroup$
    – whuber
    3 hours ago
















  • $begingroup$
    You will want to investigate the Probability Integral Transform.
    $endgroup$
    – StatsStudent
    6 hours ago










  • $begingroup$
    Because $cos(U_2)$ is the horizontal coordinate of a point uniformly distributed on the unit circle and $sin(U_2)$ is its vertical coordinate, notice that the symmetry of the circle under a switch of coordinates implies $cos(U_2)$ and $sin(U_2)$ are identically distributed. Thus, your two methods are equivalent (assuming, anyway, that you replace "6.28" by $2pi$).
    $endgroup$
    – whuber
    3 hours ago















$begingroup$
You will want to investigate the Probability Integral Transform.
$endgroup$
– StatsStudent
6 hours ago




$begingroup$
You will want to investigate the Probability Integral Transform.
$endgroup$
– StatsStudent
6 hours ago












$begingroup$
Because $cos(U_2)$ is the horizontal coordinate of a point uniformly distributed on the unit circle and $sin(U_2)$ is its vertical coordinate, notice that the symmetry of the circle under a switch of coordinates implies $cos(U_2)$ and $sin(U_2)$ are identically distributed. Thus, your two methods are equivalent (assuming, anyway, that you replace "6.28" by $2pi$).
$endgroup$
– whuber
3 hours ago




$begingroup$
Because $cos(U_2)$ is the horizontal coordinate of a point uniformly distributed on the unit circle and $sin(U_2)$ is its vertical coordinate, notice that the symmetry of the circle under a switch of coordinates implies $cos(U_2)$ and $sin(U_2)$ are identically distributed. Thus, your two methods are equivalent (assuming, anyway, that you replace "6.28" by $2pi$).
$endgroup$
– whuber
3 hours ago










2 Answers
2






active

oldest

votes


















5












$begingroup$

It looks like you are trying to use the Box-Muller transform.



The method is to use $U_1, U_2$ which are independently distribution Uniform(0,1). Then



$Z_0 = sqrt-2 ln(U_1)cos(2 pi U_2) $



and



$Z_1 = sqrt-2 ln(U_1) sin(2 pi U_2) $



are a pair of independent $N(0,1)$.



The derivation comes from using polar coordinates, but to be honest the exact steps escape me at the moment (see link if you are interested).






share|cite|improve this answer











$endgroup$




















    2












    $begingroup$

    Let $N_1,N_2$ be independent $N(0,1)$ random variates. $(N_1,N_2)$ defines a point in Cartesian coordinates. We transform to polar by



    $$ N_1 = R cos theta$$
    $$ N_2 = R sin theta$$



    This transformation is one to one and has continuous derivatives. So we can derive the joint distribution $f_R,theta(r,theta)$ by using



    $$f_R,theta(r,theta) = f_N_1,N_2(n_1,n_2)|J^-1|$$



    where $J$ is the Jacobian of the transformation and



    $$ J^-1(r,theta )=
    beginbmatrixdfrac partial n_1partial rdfrac partial n_1partial theta \dfrac partial n_2partial rdfrac partial n_2partial theta endbmatrix
    = beginbmatrixcos theta & -rsin theta \sin theta & rcos theta endbmatrix$$



    Hence $$ |J^-1| = r cos^2 theta + r sin^2 theta = r $$



    and



    $$ f_R,theta(r,theta) = r frac12pi e^-frac12(n_1^2+n_2^2) = boxedfracr2 pie^-frac12(r^2) qquad 0 leq theta leq 2 pi, 0 leq r leq infty $$



    And we see $theta sim unif[0,2pi]$ (since $f_Theta(theta) = frac12pi$ ) and $R^2 sim exp(1/2)$



    Hence, to simulate $Theta$ we simply take $2 pi U_2$ where $$U_2 sim unif[0,1]$$ and to simulate $R$ we can take $$-2ln U_1$$ where $U_1 sim unif[0,1]$. ( to see why find the density of $X=-ln U, U sim unif[0,1]$).



    So, Box and Muller simply inverted $N_1= R cos theta$, $N_2= R sin theta$ and moved from $(R,Theta)$ to $(N_1,N_2)$ by simulating $Theta$ from $2 pi U_2$, and an independent $R$ from $ sqrt- 2 ln U_1$



    explicitly



    $$Z_0 = sqrt-2 ln(U_1)cos(2 pi U_2)$$



    $$Z_1 = sqrt-2 ln(U_1) sin(2 pi U_2)$$



    And that is that is the mathematical logic behind it.




    p.s. As I don't know whether it is clear through the mathematical justification (I believe it is, but you may have been lost in details), note you need a pair of drawings from the uniform to get a pair of normals






    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: "65"
      ;
      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: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      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
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );






      Chicago1988 is a new contributor. Be nice, and check out our Code of Conduct.









      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f397505%2fsimulating-rnorm-using-runif%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









      5












      $begingroup$

      It looks like you are trying to use the Box-Muller transform.



      The method is to use $U_1, U_2$ which are independently distribution Uniform(0,1). Then



      $Z_0 = sqrt-2 ln(U_1)cos(2 pi U_2) $



      and



      $Z_1 = sqrt-2 ln(U_1) sin(2 pi U_2) $



      are a pair of independent $N(0,1)$.



      The derivation comes from using polar coordinates, but to be honest the exact steps escape me at the moment (see link if you are interested).






      share|cite|improve this answer











      $endgroup$

















        5












        $begingroup$

        It looks like you are trying to use the Box-Muller transform.



        The method is to use $U_1, U_2$ which are independently distribution Uniform(0,1). Then



        $Z_0 = sqrt-2 ln(U_1)cos(2 pi U_2) $



        and



        $Z_1 = sqrt-2 ln(U_1) sin(2 pi U_2) $



        are a pair of independent $N(0,1)$.



        The derivation comes from using polar coordinates, but to be honest the exact steps escape me at the moment (see link if you are interested).






        share|cite|improve this answer











        $endgroup$















          5












          5








          5





          $begingroup$

          It looks like you are trying to use the Box-Muller transform.



          The method is to use $U_1, U_2$ which are independently distribution Uniform(0,1). Then



          $Z_0 = sqrt-2 ln(U_1)cos(2 pi U_2) $



          and



          $Z_1 = sqrt-2 ln(U_1) sin(2 pi U_2) $



          are a pair of independent $N(0,1)$.



          The derivation comes from using polar coordinates, but to be honest the exact steps escape me at the moment (see link if you are interested).






          share|cite|improve this answer











          $endgroup$



          It looks like you are trying to use the Box-Muller transform.



          The method is to use $U_1, U_2$ which are independently distribution Uniform(0,1). Then



          $Z_0 = sqrt-2 ln(U_1)cos(2 pi U_2) $



          and



          $Z_1 = sqrt-2 ln(U_1) sin(2 pi U_2) $



          are a pair of independent $N(0,1)$.



          The derivation comes from using polar coordinates, but to be honest the exact steps escape me at the moment (see link if you are interested).







          share|cite|improve this answer














          share|cite|improve this answer



          share|cite|improve this answer








          edited 3 hours ago

























          answered 6 hours ago









          Cliff ABCliff AB

          13.4k12567




          13.4k12567























              2












              $begingroup$

              Let $N_1,N_2$ be independent $N(0,1)$ random variates. $(N_1,N_2)$ defines a point in Cartesian coordinates. We transform to polar by



              $$ N_1 = R cos theta$$
              $$ N_2 = R sin theta$$



              This transformation is one to one and has continuous derivatives. So we can derive the joint distribution $f_R,theta(r,theta)$ by using



              $$f_R,theta(r,theta) = f_N_1,N_2(n_1,n_2)|J^-1|$$



              where $J$ is the Jacobian of the transformation and



              $$ J^-1(r,theta )=
              beginbmatrixdfrac partial n_1partial rdfrac partial n_1partial theta \dfrac partial n_2partial rdfrac partial n_2partial theta endbmatrix
              = beginbmatrixcos theta & -rsin theta \sin theta & rcos theta endbmatrix$$



              Hence $$ |J^-1| = r cos^2 theta + r sin^2 theta = r $$



              and



              $$ f_R,theta(r,theta) = r frac12pi e^-frac12(n_1^2+n_2^2) = boxedfracr2 pie^-frac12(r^2) qquad 0 leq theta leq 2 pi, 0 leq r leq infty $$



              And we see $theta sim unif[0,2pi]$ (since $f_Theta(theta) = frac12pi$ ) and $R^2 sim exp(1/2)$



              Hence, to simulate $Theta$ we simply take $2 pi U_2$ where $$U_2 sim unif[0,1]$$ and to simulate $R$ we can take $$-2ln U_1$$ where $U_1 sim unif[0,1]$. ( to see why find the density of $X=-ln U, U sim unif[0,1]$).



              So, Box and Muller simply inverted $N_1= R cos theta$, $N_2= R sin theta$ and moved from $(R,Theta)$ to $(N_1,N_2)$ by simulating $Theta$ from $2 pi U_2$, and an independent $R$ from $ sqrt- 2 ln U_1$



              explicitly



              $$Z_0 = sqrt-2 ln(U_1)cos(2 pi U_2)$$



              $$Z_1 = sqrt-2 ln(U_1) sin(2 pi U_2)$$



              And that is that is the mathematical logic behind it.




              p.s. As I don't know whether it is clear through the mathematical justification (I believe it is, but you may have been lost in details), note you need a pair of drawings from the uniform to get a pair of normals






              share|cite|improve this answer











              $endgroup$

















                2












                $begingroup$

                Let $N_1,N_2$ be independent $N(0,1)$ random variates. $(N_1,N_2)$ defines a point in Cartesian coordinates. We transform to polar by



                $$ N_1 = R cos theta$$
                $$ N_2 = R sin theta$$



                This transformation is one to one and has continuous derivatives. So we can derive the joint distribution $f_R,theta(r,theta)$ by using



                $$f_R,theta(r,theta) = f_N_1,N_2(n_1,n_2)|J^-1|$$



                where $J$ is the Jacobian of the transformation and



                $$ J^-1(r,theta )=
                beginbmatrixdfrac partial n_1partial rdfrac partial n_1partial theta \dfrac partial n_2partial rdfrac partial n_2partial theta endbmatrix
                = beginbmatrixcos theta & -rsin theta \sin theta & rcos theta endbmatrix$$



                Hence $$ |J^-1| = r cos^2 theta + r sin^2 theta = r $$



                and



                $$ f_R,theta(r,theta) = r frac12pi e^-frac12(n_1^2+n_2^2) = boxedfracr2 pie^-frac12(r^2) qquad 0 leq theta leq 2 pi, 0 leq r leq infty $$



                And we see $theta sim unif[0,2pi]$ (since $f_Theta(theta) = frac12pi$ ) and $R^2 sim exp(1/2)$



                Hence, to simulate $Theta$ we simply take $2 pi U_2$ where $$U_2 sim unif[0,1]$$ and to simulate $R$ we can take $$-2ln U_1$$ where $U_1 sim unif[0,1]$. ( to see why find the density of $X=-ln U, U sim unif[0,1]$).



                So, Box and Muller simply inverted $N_1= R cos theta$, $N_2= R sin theta$ and moved from $(R,Theta)$ to $(N_1,N_2)$ by simulating $Theta$ from $2 pi U_2$, and an independent $R$ from $ sqrt- 2 ln U_1$



                explicitly



                $$Z_0 = sqrt-2 ln(U_1)cos(2 pi U_2)$$



                $$Z_1 = sqrt-2 ln(U_1) sin(2 pi U_2)$$



                And that is that is the mathematical logic behind it.




                p.s. As I don't know whether it is clear through the mathematical justification (I believe it is, but you may have been lost in details), note you need a pair of drawings from the uniform to get a pair of normals






                share|cite|improve this answer











                $endgroup$















                  2












                  2








                  2





                  $begingroup$

                  Let $N_1,N_2$ be independent $N(0,1)$ random variates. $(N_1,N_2)$ defines a point in Cartesian coordinates. We transform to polar by



                  $$ N_1 = R cos theta$$
                  $$ N_2 = R sin theta$$



                  This transformation is one to one and has continuous derivatives. So we can derive the joint distribution $f_R,theta(r,theta)$ by using



                  $$f_R,theta(r,theta) = f_N_1,N_2(n_1,n_2)|J^-1|$$



                  where $J$ is the Jacobian of the transformation and



                  $$ J^-1(r,theta )=
                  beginbmatrixdfrac partial n_1partial rdfrac partial n_1partial theta \dfrac partial n_2partial rdfrac partial n_2partial theta endbmatrix
                  = beginbmatrixcos theta & -rsin theta \sin theta & rcos theta endbmatrix$$



                  Hence $$ |J^-1| = r cos^2 theta + r sin^2 theta = r $$



                  and



                  $$ f_R,theta(r,theta) = r frac12pi e^-frac12(n_1^2+n_2^2) = boxedfracr2 pie^-frac12(r^2) qquad 0 leq theta leq 2 pi, 0 leq r leq infty $$



                  And we see $theta sim unif[0,2pi]$ (since $f_Theta(theta) = frac12pi$ ) and $R^2 sim exp(1/2)$



                  Hence, to simulate $Theta$ we simply take $2 pi U_2$ where $$U_2 sim unif[0,1]$$ and to simulate $R$ we can take $$-2ln U_1$$ where $U_1 sim unif[0,1]$. ( to see why find the density of $X=-ln U, U sim unif[0,1]$).



                  So, Box and Muller simply inverted $N_1= R cos theta$, $N_2= R sin theta$ and moved from $(R,Theta)$ to $(N_1,N_2)$ by simulating $Theta$ from $2 pi U_2$, and an independent $R$ from $ sqrt- 2 ln U_1$



                  explicitly



                  $$Z_0 = sqrt-2 ln(U_1)cos(2 pi U_2)$$



                  $$Z_1 = sqrt-2 ln(U_1) sin(2 pi U_2)$$



                  And that is that is the mathematical logic behind it.




                  p.s. As I don't know whether it is clear through the mathematical justification (I believe it is, but you may have been lost in details), note you need a pair of drawings from the uniform to get a pair of normals






                  share|cite|improve this answer











                  $endgroup$



                  Let $N_1,N_2$ be independent $N(0,1)$ random variates. $(N_1,N_2)$ defines a point in Cartesian coordinates. We transform to polar by



                  $$ N_1 = R cos theta$$
                  $$ N_2 = R sin theta$$



                  This transformation is one to one and has continuous derivatives. So we can derive the joint distribution $f_R,theta(r,theta)$ by using



                  $$f_R,theta(r,theta) = f_N_1,N_2(n_1,n_2)|J^-1|$$



                  where $J$ is the Jacobian of the transformation and



                  $$ J^-1(r,theta )=
                  beginbmatrixdfrac partial n_1partial rdfrac partial n_1partial theta \dfrac partial n_2partial rdfrac partial n_2partial theta endbmatrix
                  = beginbmatrixcos theta & -rsin theta \sin theta & rcos theta endbmatrix$$



                  Hence $$ |J^-1| = r cos^2 theta + r sin^2 theta = r $$



                  and



                  $$ f_R,theta(r,theta) = r frac12pi e^-frac12(n_1^2+n_2^2) = boxedfracr2 pie^-frac12(r^2) qquad 0 leq theta leq 2 pi, 0 leq r leq infty $$



                  And we see $theta sim unif[0,2pi]$ (since $f_Theta(theta) = frac12pi$ ) and $R^2 sim exp(1/2)$



                  Hence, to simulate $Theta$ we simply take $2 pi U_2$ where $$U_2 sim unif[0,1]$$ and to simulate $R$ we can take $$-2ln U_1$$ where $U_1 sim unif[0,1]$. ( to see why find the density of $X=-ln U, U sim unif[0,1]$).



                  So, Box and Muller simply inverted $N_1= R cos theta$, $N_2= R sin theta$ and moved from $(R,Theta)$ to $(N_1,N_2)$ by simulating $Theta$ from $2 pi U_2$, and an independent $R$ from $ sqrt- 2 ln U_1$



                  explicitly



                  $$Z_0 = sqrt-2 ln(U_1)cos(2 pi U_2)$$



                  $$Z_1 = sqrt-2 ln(U_1) sin(2 pi U_2)$$



                  And that is that is the mathematical logic behind it.




                  p.s. As I don't know whether it is clear through the mathematical justification (I believe it is, but you may have been lost in details), note you need a pair of drawings from the uniform to get a pair of normals







                  share|cite|improve this answer














                  share|cite|improve this answer



                  share|cite|improve this answer








                  edited 36 mins ago

























                  answered 5 hours ago









                  StatsStats

                  49618




                  49618




















                      Chicago1988 is a new contributor. Be nice, and check out our Code of Conduct.









                      draft saved

                      draft discarded


















                      Chicago1988 is a new contributor. Be nice, and check out our Code of Conduct.












                      Chicago1988 is a new contributor. Be nice, and check out our Code of Conduct.











                      Chicago1988 is a new contributor. Be nice, and check out our Code of Conduct.














                      Thanks for contributing an answer to Cross Validated!


                      • 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%2fstats.stackexchange.com%2fquestions%2f397505%2fsimulating-rnorm-using-runif%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

                      Masuk log Menu navigasi

                      Identifying “long and narrow” polygons in with PostGISlength and width of polygonWhy postgis st_overlaps reports Qgis' “avoid intersections” generated polygon as overlapping with others?Adjusting polygons to boundary and filling holesDrawing polygons with fixed area?How to remove spikes in Polygons with PostGISDeleting sliver polygons after difference operation in QGIS?Snapping boundaries in PostGISSplit polygon into parts adding attributes based on underlying polygon in QGISSplitting overlap between polygons and assign to nearest polygon using PostGIS?Expanding polygons and clipping at midpoint?Removing Intersection of Buffers in Same Layers

                      Старые Смолеговицы Содержание История | География | Демография | Достопримечательности | Примечания | НавигацияHGЯOLHGЯOL41 206 832 01641 606 406 141Административно-территориальное деление Ленинградской области«Переписная оброчная книга Водской пятины 1500 года», С. 793«Карта Ингерманландии: Ивангорода, Яма, Копорья, Нотеборга», по материалам 1676 г.«Генеральная карта провинции Ингерманландии» Э. Белинга и А. Андерсина, 1704 г., составлена по материалам 1678 г.«Географический чертёж над Ижорскою землей со своими городами» Адриана Шонбека 1705 г.Новая и достоверная всей Ингерманландии ланткарта. Грав. А. Ростовцев. СПб., 1727 г.Топографическая карта Санкт-Петербургской губернии. 5-и верстка. Шуберт. 1834 г.Описание Санкт-Петербургской губернии по уездам и станамСпецкарта западной части России Ф. Ф. Шуберта. 1844 г.Алфавитный список селений по уездам и станам С.-Петербургской губернииСписки населённых мест Российской Империи, составленные и издаваемые центральным статистическим комитетом министерства внутренних дел. XXXVII. Санкт-Петербургская губерния. По состоянию на 1862 год. СПб. 1864. С. 203Материалы по статистике народного хозяйства в С.-Петербургской губернии. Вып. IX. Частновладельческое хозяйство в Ямбургском уезде. СПб, 1888, С. 146, С. 2, 7, 54Положение о гербе муниципального образования Курское сельское поселениеСправочник истории административно-территориального деления Ленинградской области.Топографическая карта Ленинградской области, квадрат О-35-23-В (Хотыницы), 1930 г.АрхивированоАдминистративно-территориальное деление Ленинградской области. — Л., 1933, С. 27, 198АрхивированоАдминистративно-экономический справочник по Ленинградской области. — Л., 1936, с. 219АрхивированоАдминистративно-территориальное деление Ленинградской области. — Л., 1966, с. 175АрхивированоАдминистративно-территориальное деление Ленинградской области. — Лениздат, 1973, С. 180АрхивированоАдминистративно-территориальное деление Ленинградской области. — Лениздат, 1990, ISBN 5-289-00612-5, С. 38АрхивированоАдминистративно-территориальное деление Ленинградской области. — СПб., 2007, с. 60АрхивированоКоряков Юрий База данных «Этно-языковой состав населённых пунктов России». Ленинградская область.Административно-территориальное деление Ленинградской области. — СПб, 1997, ISBN 5-86153-055-6, С. 41АрхивированоКультовый комплекс Старые Смолеговицы // Электронная энциклопедия ЭрмитажаПроблемы выявления, изучения и сохранения культовых комплексов с каменными крестами: по материалам работ 2016-2017 гг. в Ленинградской области