Hey list,
This might be a more general question and not that R-specific. Sorry for
that.
I'm trying to draw a random vector of 4 numbers that sum up to 1.
My first approach was something like
a - runif(1)
b - runif(1, max=1-a)
c - runif(1, max=1-a-b)
d - 1-a-b-c
but this kind of
You probably want to generate data from a Dirichlet distribution. There are
some functions in packages that will do this and give you more background, or
you can just generate 4 numbers from an exponential (or gamma) distribution and
divide them by their sum.
--
Gregory (Greg) L. Snow Ph.D.
On 10.10.2011 18:10, Alexander Engelhardt wrote:
Hey list,
This might be a more general question and not that R-specific. Sorry for
that.
I'm trying to draw a random vector of 4 numbers that sum up to 1.
My first approach was something like
a - runif(1)
b - runif(1, max=1-a)
c - runif(1,
On Oct 10, 2011, at 12:44 PM, Uwe Ligges wrote:
On 10.10.2011 18:10, Alexander Engelhardt wrote:
Hey list,
This might be a more general question and not that R-specific.
Sorry for
that.
I'm trying to draw a random vector of 4 numbers that sum up to 1.
My first approach was something
As an interesting extension to David's post, try:
M4.e - matrix(rexp(4,1), ncol=4)
Instead of the uniform and rerun the rest of the code (note the limits on the
x-axis).
With 3 dimensions and the restriction we can plot in 2 dimensions to compare:
library(TeachingDemos)
m3.unif -
5 matches
Mail list logo