Re: [R] generate random numbers subject to constraints

From: Robert A LaBudde <ral_at_lcfltd.com>
Date: Wed, 26 Mar 2008 15:13:50 -0500

At 01:13 PM 3/26/2008, Ala' Jaouni wrote:
>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?

  1. Generate random variates for X1, X2, based upon whatever unspecified distribution you wish.
  2. Solve the two equations for X3 and X4.

Robert A. LaBudde, PhD, PAS, Dpl. ACAFS e-mail: ral_at_lcfltd.com
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"



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. Received on Wed 26 Mar 2008 - 19:19:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 27 Mar 2008 - 00:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive