[R] generate random numbers subject to constraints
Giovanni Petris
GPetris at uark.edu
Wed Mar 26 21:39:43 CET 2008
You have 4 random variables that satisfy 2 linear constraints, so you
are trying to generate a point in a (4-2) = 2 dimensional linear
(affine, in fact) subspace of R^4.
If you don't have any further requirement for the distribution of the
random points you want to generate, there are infinitely many ways of
doing it.
It would be a good idea if you could explain in some more detail what
you want to do, so that we can give you relevant suggestions.
Best,
Giovanni
> Date: Wed, 26 Mar 2008 11:28:28 -0700
> From: "Ala' Jaouni" <ajaouni at gmail.com>
> Sender: r-help-bounces at r-project.org
> Precedence: list
>
> I am trying to generate a set of random numbers that fulfill the
> following constraints:
>
> X1 + X2 + X3 + X4 = 1
>
> aX1 + bX2 + cX3 + dX4 = n
>
> where a, b, c, d, and n are known.
>
> Any function to do this?
>
> Thanks,
> -Ala'
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
--
Giovanni Petris <GPetris @ uark.edu>
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/
More information about the R-help
mailing list