1

I would like to simulate n numbers (all within the range between a and b, n being an even number) using R, and the mean (u) and median (m) is given.

If I use runif then the standard deviation is needed, and the data is not equidistantly spaced either.

Help is appreciated!

Glen_b
  • 257,508
  • 32
  • 553
  • 939
asdf
  • 11
  • 3
  • Related: [How to simulate data that satisfy specific constraints such as having specific mean and standard deviation?](http://stats.stackexchange.com/q/30303/7290) – gung - Reinstate Monica Apr 20 '15 at 01:57
  • 1
    Do you care if the generated data have a particular distribution? You list a minimum & a maximum, which connotes a uniform or a beta distribution, but it isn't clear if that is what you have in mind. In addition, the `runif()` function *does not* require a standard deviation (`rnorm()` does). Do you need the data to be equidistantly spaced? – gung - Reinstate Monica Apr 20 '15 at 02:00
  • Sorry, I meant rnorm()! Also, I would not want the data to be equidistantly spaced, the reason why I mentioned it is because I found a formula online stating that the sample variance can be calculated by [(a-2m+b)^2/4 + (b-a)^2]/12, but that's for equidistantly spaced data only. – asdf Apr 20 '15 at 02:08
  • Where it's possible at all (i.e. if there's a distribution satsifying a specific set of conditions), there are typically an infinite number of possible solutions. Do you have some additional restrictions or preferences? Unimodality, continuity, ... differentiability? or something else? – Glen_b Apr 20 '15 at 03:08
  • http://stackoverflow.com/questions/18919091/r-generate-random-numbers-with-fixed-mean-and-sd?lq=1 – Khashaa Apr 20 '15 at 05:01

0 Answers0