0

What are some good ways for generating pseudorandom numbers according to an empirical, discrete distribution? I have a probability histogram $P(x)$, corresponding to all possible (integer) values of $x$.

user2561523
  • 121
  • 5
  • Do you just know all the possible integer values or do also know the probability for integer value? – num_39 Feb 25 '22 at 04:31
  • `sample(data,n,rep=TRUE)` or `sample(1:max(data),n,rep=TRUE,prob=p(1:max(data)))` – Xi'an Feb 25 '22 at 05:44

0 Answers0