[R] Generate N random numbers with a given probability and condition
Nelly Reduan
nell@redu @ending from hotm@il@fr
Thu Jul 5 00:21:34 CEST 2018
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, replace=TRUE, prob=rep(0.28, times=length(seq(0, 10, 1))))
But I don�t know how to put the condition sum(x) <= max(seq(0, 10, 1)).
Many thanks for your time
Nell
[[alternative HTML version deleted]]
More information about the R-help
mailing list