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

2018-07-11 Thread Duncan Murdoch
On 04/07/2018 6:21 PM, Nelly Reduan wrote: Dear all, I would like to generate N random numbers with a given probability and condition but I'm not sure how to do this. For example, I have N = 20 and the vector from which to choose is seq(0, 10, 1). I have tested: x <- sample(seq(0, 10, 1), 20,

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

2018-07-11 Thread Jim Lemon
Hi Nell, As I said, the number of permutations increases rapidly with the number of values to be permuted. Using the package "permute", which is much more sophisticated than the basic function in the crank package, a vector of length 20 has 2.432902e+18 possible permutations. While your problem can

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

2018-07-11 Thread Nelly Reduan
Many thanks Jim for your help. I am trying to apply the permutations with a sequence of 20 but I obtain the error message: Error in matrix(NA, nrow = nrows, ncol = lenx) : invalid 'nrow' value (too large or NA) In addition: Warning message: In matrix(NA, nrow = nrows, ncol = lenx) : NAs intr

Re: [R] (no subject)

2018-07-11 Thread MacQueen, Don via R-help
Maybe I missed it, but I didn't see anyone suggest a visit to the CRAN Spatial task view. This would be a good place to start learning how to work with spatial data in R. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 Lab cell

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

2018-07-11 Thread Boris Steipe
Wasn't there also the requirement that the numbers be drawn from a uniform distribution? These sequences are not. I wonder whether this can for all practical purposes be simplified to consider only the sequence with maximum entropy. B. > On 2018-07-11, at 06:23, Rolf Turner wrote: > > On

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

2018-07-11 Thread Rolf Turner
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 lik