[R] [FORGED] Re: Generate N random numbers with a given probability and condition

Rolf Turner r@turner @end|ng |rom @uck|@nd@@c@nz
Wed Jul 11 12:23:35 CEST 2018

On 11/07/18 12:46, Jim Lemon wrote:
> Hi Nell,
> I may not have the right idea about this, but I think you need to do
> this in two steps if it can be done. Let's say you want a sequence of
> 20 (N) numbers between 0 and 10 that sums to 10 (M). You can enumerate
> the monotonically increasing sequences like this:
> c(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1)
> c(0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2)
> ...
> c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10)


Jim:  You should *not* do people's homework for them!



Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

More information about the R-help mailing list