Random Number Generator
A random number generator is useful when you need a quick draw without writing code or preparing slips of paper. This tool creates one or many pseudo-random numbers between two endpoints, optionally rounded to a chosen number of decimal places. It also includes a no-duplicate mode for distinct whole-number draws, such as assigning presentation order or picking raffle tickets from an integer list.
How it works
The generator has two modes. In regular mode, it orders the endpoints, builds the integer index range representing the selected decimal precision, and chooses an index using the browser’s pseudo-random number function. Count must be a whole number from 1 to 1000, and decimal places must be a whole number from 0 to 10. Both representable endpoints are eligible.
In No duplicates mode, the calculator rounds the lower endpoint up and the upper endpoint down, then samples without replacement over safe-integer offsets. Memory use depends on the requested count, not the width of the range. If you request more values than the range contains, the result is capped at the number of available integers.
The displayed summary is calculated from the numbers actually shown: count, smallest, largest, sum, and average. If you want to analyze a generated sample further, the statistics calculator can help with mean, spread, and other descriptive measures.
Formula
For regular draws, define the variables this way:
- Minimum is the smaller of the two endpoint inputs.
- Maximum is the larger of the two endpoint inputs.
- Random is the pseudo-random browser value, greater than or equal to zero and less than one.
- Factor is 10 raised to the selected number of decimal places.
- Lowest index is the smallest integer not below minimum times factor.
- Range size is highest index minus lowest index plus one.
For no-duplicate draws, the eligible integer endpoints are:
Sampling without replacement makes every returned integer distinct without materializing every integer in a wide range.
Examples
Example one: set Minimum to 10, Maximum to 20, How many to 3, Decimal places to 2, and leave No duplicates off. The eligible grid runs from 10.00 through 20.00 in steps of 0.01. Both endpoints can be selected, and repeated values are possible.
Example two: set Minimum to 1, Maximum to 5, How many to 10, Decimal places to 0, and turn No duplicates on. The five eligible integers are returned once each, not ten values, because only five distinct whole numbers exist in the range.
Example three: set Minimum to 2.2, Maximum to 2.8, and turn No duplicates on. The lowest integer is 3 and the highest integer is 2, so the range contains no whole numbers. The calculator displays the error message rather than inventing a decimal unique draw.
Pseudo-randomness and appropriate uses
ECMAScript specifies that Math.random() returns a Number from 0 inclusive to 1 exclusive using an implementation-defined random or pseudo-random algorithm. MDN explicitly warns that it is not cryptographically secure.
That distinction is not a flaw for everyday use. A pseudo-random generator is appropriate for classroom demonstrations, choosing a game starting player, shuffling practice questions, assigning non-sensitive groups, or simulating a simple process. It is not appropriate for passwords, API keys, cryptographic salts, gambling systems, official drawings, or scientific work that requires a documented seed and reproducibility. For calculations built from random samples, use this tool to generate the sample and then open the statistics calculator for mean, minimum, maximum, and spread.
Applications and internal links
For a quick classroom exercise, generate 30 numbers from 1 through 6 and compare the distribution with the theoretical average of a die. For a decision list, generate one number from 1 through the number of options, then map that number to your list. For percentage-based targets, use a random draw and then summarize progress with the percentage calculator or percent-to-goal calculator. For shopping or scheduling examples that need one choice from a range, the generator is faster than building a spreadsheet.
Edge cases and common mistakes
Regular mode samples over the safe integer index grid represented by the selected decimal precision. Use No duplicates when each eligible integer may appear at most once, and use an independently audited system when fairness, regulation, or security matters.
Another mistake is assuming more digits mean more meaningful randomness. Ten decimal places may look precise, but it does not make the underlying source cryptographic or more appropriate for security. Finally, remember that every click is a new draw. If a result matters, copy or record it immediately, because the calculator does not store a seed that can reproduce the same sequence later.
Sources
- Ecma International, ECMAScript §21.3.2.27 Math.random — return interval and implementation-defined random or pseudo-random algorithm.
- MDN Web Docs, Math.random() — explicit warning that the function is not cryptographically secure.