Hello: Can you tell me if there's a simple way to generate in R random vectors on the unit sphere in R^{n}? Additionally, are there references for this question? Thanks in advance. Tom -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> "tom" == Tom Richards <Richards> writes:tom> Hello: Can you tell me if there's a simple way to generate in tom> R random vectors on the unit sphere in R^{n}? Additionally, tom> are there references for this question? Thanks in advance. I suspect that you can generate them in R^n and then scale? (i.e. use (x/|x|) ). best, -tony -- A.J. Rossini Rsrch. Asst. Prof. of Biostatistics U. of Washington Biostatistics rossini at u.washington.edu FHCRC/SCHARP/HIV Vaccine Trials Net rossini at scharp.org -------------- http://software.biostat.washington.edu/ ---------------- FHCRC: M: 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email UW: Th: 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX (my tuesday/wednesday/friday locations are completely unpredictable.) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
There is a note by George Marsaglia in Annals of mathematical statistics (1972) (p. 645-646), which talks about faster ways of picking points uniformly from the surface of a unit sphere. However, his algorithms are limited to 3 and 4 dimensions. I am not sure if there are similar algorithms for any general "n". For larger "n", it seems that the method suggested by Tom Lumley, using "n" N(0,1) deviates, is the best approach. Ravi. -----Original Message----- From: Richards, Tom <richards at upci.pitt.edu> To: R-Help (E-mail) <r-help at stat.math.ethz.ch> Date: Monday, August 26, 2002 8:31 PM Subject: [R] Random unit vectors in R^{n}>Hello: > > Can you tell me if there's a simple way to generate in R random >vectors on the unit sphere in R^{n}? Additionally, are there referencesfor>this question? Thanks in advance. > >Tom >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.->r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html >Send "info", "help", or "[un]subscribe" >(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Richards, Tom wrote:> Hello: > > Can you tell me if there's a simple way to generate in R random > vectors on the unit sphere in R^{n}? Additionally, are there references for > this question? Thanks in advance. > > TomThere's some references in the documentation of the gsl library (GNU scientific library). See http://sources.redhat.com/gsl/ref/gsl-ref_19.html#SEC303 -- Cyril -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._