Random Number in MS-Excel | How to Use

Random number in Excel
Computer Softwares Excel Tutorial StatisticsLeave a Comment on Random Number in MS-Excel | How to Use

Random Number in MS-Excel | How to Use

Random number in Excel
Random numbers in computer data simulation and statistical distributions play an important role. Although we know that the numbers generated by computer algorithms are pseudo-random (No real Random), but in most cases we use these techniques to create random numbers in the range [a,b] (from a to b). In this article of Arman Computer magazine, we want to generate a random number RAND and RANDBETWEEN functions in MS-Excel. statistics.

Random number in Excel with RAND function

At first part, maybe the RAND function can generate the random number you want. But note that this function has no parameters, and the generated random number will be in the range of zero to one. The syntax of this function is as follows.

RAND()

For example, if you enter this function in a cell as follows, a random number will be generated between two values 0 and 1, which will be, for example, 0.5321489765. Note: This number has 16 decimal digits. Therefore, if it is necessary that the desired random number be in the range from a to b, you can create a formula based on the RAND function as follows. Example: suppose we need a random number between 12 and 19. So a = 12, b = 19, as a result, the formula will be as follows. In this way, if the random number generated by the RAND function is, for example, 0.65, the result can be calculated as follows.

$$12 + 7* (0.65) = 12 + 4.55 = 16.55 $$

Note: Of course, since the generated random numbers are generated with the precision of 16 decimal digits, there is no control over the number of decimal digits. But using the round function can round the resulting number to the appropriate number of digits, for example, to find a random number with a decimal digit in the range of 12 to 19, we write the formula as follows.

$$ROUND(12 + 7* RAND(),1) = 12 + 4.5 = 16.5 $$

 Random number in the range from a to b in Excel RAND FUNCTION IN EXCEL
Random number in the range from a to b in Excel RAND FUNCTION IN EXCEL

Random number between a and b with RANDBETWEEN function

This time, we want to use the RANDBETWEEN function in Excel to control the number of decimal digits generated by the random number. The RANDBETWEEN function has two parameters, BOTTOM and TOP, with the help of which a random number is generated between these two numbers. In fact, BOTTOM defines the lower bound and TOP the upper bound for the random number. Just note that this number will be an integer (no decimal). First, we solve the main problem, which is the generation of random numbers in the range of 12 to 19. It is enough to use the function as follows.

$$= RANDBETWEEN(12 , 19) $$

The result of this calculation in a worksheet may be the number 14. But maybe our goal is to generate a random number in the range of 12 to 19 with a decimal digit. It is enough to generate a random number between 120 and 190 and divide the result by 10. A random number in the range of 12 to 19 with a decimal digit is obtained in this simple way.

$$= RANDBETWEEN(120 , 190)/10 $$

 Random number in the range from a to b in Excel RANDBETWEEN FUNCTION IN EXCEL
Random number in the range from a to b in Excel RANDBETWEEN FUNCTION IN EXCEL
Also, if we need a random number in this range with two decimal places, it is sufficient to use the following formula.

$$= RANDBETWEEN(1200 , 1900)/100 $$

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top