Re: [R] Creating 3 vectors that sum to 1

2011-03-30 Thread Greg Snow
i Varadhan [mailto:rvarad...@jhmi.edu] > Sent: Tuesday, March 29, 2011 4:41 PM > To: Greg Snow > Cc: r-help@r-project.org > Subject: Re: RE: [R] Creating 3 vectors that sum to 1 > > Hi Greg, > > Thanks. > > Here is one approach to speeding up the 1st method that I had > s

Re: [R] Creating 3 vectors that sum to 1

2011-03-30 Thread Petr Savicky
On Tue, Mar 29, 2011 at 01:42:18PM -0600, Greg Snow wrote: > Or we could expand a bit more: > > require(TeachingDemos) > require(gtools) > > n <- 1000 > rtrg <- matrix(NA, n, 3) > for (i in 1:n) rtrg[i,] <- diff(c(0, sort(runif(2)), 1)) > > rtrg2 <- matrix(NA, n, 3) > for (i in 1:n) { > tmp <- r

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Ravi Varadhan
stant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Greg Snow Date: Tuesday, March 29, 2011 3:42 pm Subject: RE: [R] Creating 3 vectors that sum to 1 To: Ravi V

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Christopher Desjardins
# Corners are sparsely populated > > > > Ravi. > > ____________________ > > > > Ravi Varadhan, Ph.D. > > Assistant Professor, > > Division of Geriatric Medicine and Gerontology > > School of Medicine

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Greg Snow
From: Ravi Varadhan [mailto:rvarad...@jhmi.edu] > Sent: Tuesday, March 29, 2011 12:59 PM > To: Ravi Varadhan > Cc: Greg Snow; r-help@r-project.org > Subject: Re: [R] Creating 3 vectors that sum to 1 > > > Here is an exploration of two different 3-tuple generators (that s

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter > Sent: Tuesday, March 29, 2011 10:07 AM > To: Petr Savicky; cddesjard...@gmail.com > Cc: r-help@r-project.org > Subject: Re: [R] Creating 3

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Ravi Varadhan
Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Ravi Varadhan Date: Tuesday, March 29, 2011 2:33 pm Subject: Re: [R] Creating 3 vectors that sum to 1 To: Greg Snow Cc: "r-help@r-pro

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Ravi Varadhan
Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Greg Snow Date: Tuesday, March 29, 2011 1:02 pm Subject: Re: [R] Creating 3 vectors that sum

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Bert Gunter
So you want to generate random multinomials ? ... Just generate random uniforms and divide by their sum! z <- runif(3); z/sum(z) ## This can easily be modified to generate lots of random multinomial 3 vectors, e.g. z <- matrix( runif(3*100), ncol=3) z/rowSums(z) ## each row is a random multino

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Peter Ehlers
On 2011-03-29 09:20, Christopher Desjardins wrote: I have 3 vectors: p1, p2, and p3. I would like each vector to be any possible value between 0 and 1 and p1 + p2 + p3 = 1. I want to graph these and I've thought about using scatterplot3d(). Here's what I have so far. library(scatterplot3d) p1<-

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Greg Snow
Do a search for Dirichlet, that may give you the tools you need. Also for plotting 3 vectors that sum to 1, instead of a 3d scatter plot you should look into a triangle or trilinear plot, see ?triplot in the TeachingDemos package (the see also for that help page lists several other implementati

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Richard M. Heiberger
Please look at the triplot function in the klaR package. The keyword is RSiteSearch("barycentric") Rich On Tue, Mar 29, 2011 at 12:20 PM, Christopher Desjardins < cddesjard...@gmail.com> wrote: > I have 3 vectors: p1, p2, and p3. I would like each vector to be any > possible value between 0 an

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Petr Savicky
On Tue, Mar 29, 2011 at 11:20:13AM -0500, Christopher Desjardins wrote: > I have 3 vectors: p1, p2, and p3. I would like each vector to be any > possible value between 0 and 1 and p1 + p2 + p3 = 1. I want to graph these > and I've thought about using scatterplot3d(). Here's what I have so far. > >