1

Does anybody know a function custom or not, to generate random integers following (as a whole set) a predefined mean and standard deviation?

For example I'd like to be able to generate a set of 5 integer that will have a mean of 2.8 and standard deviation of 2.4 and consist of values from a 0 to 6 range:

function(N=5, M=2.8, SD=2.4, range=0:6)
> 0 1 3 6 4

I found posts that relate to random integers summing to a given value: Generate N random integers that sum to M in R but I couldn't figure out how to reuse it for my case scenario

blazej
  • 1,678
  • 3
  • 19
  • 41
  • 3
    Your problem isn't sufficiently defined. I'm also having trouble imagining a sensible application for this. – Roland Apr 07 '21 at 18:04
  • What did I miss? Given a 1) number (N) of elements, 2) possible values range 3) mean (M), 4) standard deviation (SD) - generate a set of N integers from a specified range that will follow a normal distribution with M and SD. Now that I think about it - Im looking for a `rnorm` function for integers with specified range (min / max) only – blazej Apr 07 '21 at 20:13
  • 1
    So, you are looking for the truncated normal distribution? That's confusing because you seem to describe a discrete distribution in your question. – Roland Apr 08 '21 at 07:36
  • Forgive my lack of clarity - after looking into both distributions I'd say that I'm looking for a mix o both - truncated normal in the sense that I want to be able to bound both min and max values; and discrete in the sense that I want only integers (positive, but can be negative as well) – blazej Apr 08 '21 at 11:09
  • OK, so you want a truncated discrete distribution? Which distribution family? – Roland Apr 08 '21 at 14:26
  • 1
    I really don't know how to answer. Is there a one, that fits best to how I described the result? – blazej May 05 '21 at 18:13
  • You need to consult a statistician. They can help you defining your problem. Once you have a clear problem definition, solving this should become easy. – Roland May 06 '21 at 06:01
  • If Gaussian makes sense, than that's it – blazej May 07 '21 at 09:11
  • 1
    But it doesn't make sense. You claim to want a discrete distribution and Gaussian is continuous. – Roland May 07 '21 at 09:15
  • I'm reading about this and I'm still confused by the complexity here. I want to generate a set of integers from a defined range of minimum and maximum that will have a specified mean and standard deviation. When I think "mean and SD" i think of a normal distribution, that in this case can take only whole numbers. – blazej May 07 '21 at 11:10

0 Answers0