0

I want to use the RAND() function in Excel to generate a random number between 0 and 1.

However, I would like 80% of the values to fall between 0 and 0.2, 90% of the values to fall between 0 and 0.3, 95% of the values to fall between 0 and 0.5, etc.

This reminds me that I took an applied statistics course once upon a time, but not of what was actually in the course...

How is the best way to go about achieving this result using an Excel formula. Alternatively, what is this kind of statistical calculation called / any other pointers that I can Google around for.

=================

Use case:

I have a single column of meter readings, which I would like to duplicate 7 times (each column for a new month). each column has 55 000 rows. While the meter readings need to vary for each month, when taken as a time series, each meter number should have 7 realistic readings.

The aim is to produce realistic data to turn into heat maps (i.e. flag outlying meter readings)

1
  • Have a look here:
    – MGP
    Nov 25, 2015 at 11:28

1 Answer 1

1

I don't think that there is a formula which would fit exactly to your requirements. I would use a very straightforward solution:

  • Generate 80% of data using =RANDBETWEEN(0,20)/100
  • Generate 10% of data using =RANDBETWEEN(20,30)/100
  • Generate 5% of data using =RANDBETWEEN(30,50)/100
  • and so on

You can easily change the precision of generated data by modifying the parameters, for example: =RANDBETWEEN(0,2000)/10000 will generate data with up to 4 digits after decimal point.

UPDATE

Use a normal distribution for the use case, for example:

=NORMINV(RAND(), 20, 5)

where 20 is a mean value and 5 is a standard deviation.

3
  • thank you. ideally I would like a formula however, I've added the use case in the original question
    – Zach Smith
    Nov 25, 2015 at 11:55
  • In response to your first suggestion I came up with a formula: =CHOOSE(RANDBETWEEN(1,10), RANDBETWEEN(0,10), RANDBETWEEN(0,10), RANDBETWEEN(0,10), RANDBETWEEN(0,10), RANDBETWEEN(0,10), RANDBETWEEN(0,20), RANDBETWEEN(0,20), RANDBETWEEN(0,50), RANDBETWEEN(0,50), RANDBETWEEN(0,99)). is there a reason this wouldn't work?
    – Zach Smith
    Nov 25, 2015 at 12:22
  • 1
    All RANDBETWEEN after the last RANDBETWEEN(0,10) should not start from 0, because the results will overlap and the expected percentage will not be correct. Try this one: =CHOOSE(RANDBETWEEN(1,10), RANDBETWEEN(0,10), RANDBETWEEN(0,10), RANDBETWEEN(0,10), RANDBETWEEN(0,10), RANDBETWEEN(0,10), RANDBETWEEN(11,20), RANDBETWEEN(11,20), RANDBETWEEN(21,50), RANDBETWEEN(21,50), RANDBETWEEN(51,99)) Nov 25, 2015 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.