Generate Four Random Numbers: How It Works

How-to basics · Updated November 23, 2026

The direct answer: there is no single set of four random numbers—randomness means any four numbers are equally possible, so the only meaningful answer is a method to generate them, such as using a random number generator, a physical die, or a true random service. Below, we explain what “random” really means, how to generate four numbers for different purposes, and what pitfalls to avoid.

What Does “Random” Actually Mean?

In everyday language, random means unpredictable or lacking a pattern. In mathematics and computing, randomness is defined by probability distributions. When you ask for four random numbers, you must first specify the range (e.g., 1 to 100) and the distribution (usually uniform, meaning every number in the range has an equal chance). Without those, the request is incomplete. For example, four random numbers between 1 and 10 could be 3, 7, 2, 9, but they could also be 1, 1, 1, 1—though that outcome is less likely.

True randomness is hard to achieve. Physical processes like radioactive decay or atmospheric noise are considered truly random, but computers use algorithms that generate pseudo-random numbers—sequences that appear random but are actually deterministic based on an initial seed.

How Computers Generate Random Numbers

Computer programs typically use a pseudo-random number generator (PRNG). The most common is the Mersenne Twister, used in many programming languages. It produces a long sequence of numbers that passes statistical tests for randomness, but if you know the seed, you can predict the entire sequence. For most purposes (games, simulations, sampling), PRNGs are sufficient.

For security-sensitive applications like cryptography, PRNGs are not enough. Instead, cryptographically secure PRNGs (CSPRNGs) use entropy from system events (mouse movements, keystroke timings, hardware noise) to generate seeds. In Python, random.randint() uses a PRNG, while secrets.randbelow() uses a CSPRNG. In Excel, RAND() uses a PRNG.

How to Generate Four Random Numbers

Depending on your context, here are practical methods:

  • Using a physical die: Roll a die four times to get numbers 1–6. For larger ranges, use multiple dice or a random number table.
  • Using a calculator or phone: Most scientific calculators have a RAN# function. On an iPhone, ask Siri to “roll a die” or use a random number app.
  • Using Python: import random; [random.randint(1,100) for _ in range(4)] gives four integers between 1 and 100.
  • Using Excel: Enter =RAND() in four cells to get decimals between 0 and 1. For integers between 1 and 100, use =RANDBETWEEN(1,100) in four cells.
  • Using a web service: Sites like random.org use atmospheric noise to generate true random numbers. You can specify four numbers in any range.

Always specify the range and whether you need integers or decimals. For example, “four random integers from 1 to 49” is a common lottery-style request.

Common Misconceptions and Pitfalls

One misconception is that random numbers must all be different. Unless you specify “without replacement,” repeats are allowed. In a uniform distribution, each draw is independent, so the same number can appear multiple times. For example, rolling a die four times could give 4, 4, 4, 4—though unlikely, it’s possible.

Another pitfall is using a poorly implemented generator. For instance, Excel’s RAND() recalculates each time the sheet changes, which can be annoying. To keep numbers fixed, copy and paste as values. Also, some programming languages’ default random functions are not suitable for cryptography—never use them for passwords or tokens.

A third issue is human-generated randomness. When people try to pick “random” numbers, they tend to avoid patterns and repeats, making their choices biased. For example, people rarely pick 1 or 100, and they avoid consecutive numbers. If you need unbiased randomness, always use a mechanical or algorithmic generator.

Choosing the Right Method for Your Need

Consider the purpose:

  • Games and entertainment: A simple PRNG or dice is fine. For a board game, use dice; for a video game, the built-in random function works.
  • Statistical sampling: Use a reliable PRNG like the Mersenne Twister in Python or R. Set a seed for reproducibility.
  • Cryptography (passwords, tokens): Use a CSPRNG like Python’s secrets module or /dev/urandom on Linux. Do not use random.randint().
  • Lottery or gambling: Use a true random source like random.org to avoid predictability. Note that even then, the odds are the same as any other numbers.

If you need the same set of four numbers later, save them or set a seed. For example, in Python, random.seed(42) ensures the same sequence each run.

Costs and Safety Considerations

Most methods are free. Physical dice cost a few dollars. Online services like random.org offer free usage for small requests, but they have premium plans for high-volume or commercial use. Excel and Python are already available to most users.

Safety is a concern when using random numbers for security. If you generate a password with a weak PRNG, an attacker could predict it. Always use a CSPRNG for passwords, API keys, or any authentication token. Also, be aware that some online random number generators may not be truly random or may log your requests—use reputable services for sensitive data.

Alternatives to Pure Randomness

Sometimes you don’t want pure randomness. If you need four numbers that are unique, use sampling without replacement: in Python, random.sample(range(1,101), 4) gives four distinct numbers. If you need numbers that follow a specific distribution (e.g., normal distribution), use random.gauss() in Python or the NORM.INV function in Excel. For a lottery, you might want to avoid consecutive numbers, but that’s a personal preference, not a requirement of randomness.

Another alternative is using a deterministic sequence like the digits of pi or a hash function, but those are not random—they are predictable. For most purposes, a good PRNG is the best trade-off between speed and quality.

Frequently Asked Questions

Can I generate four random numbers without repeats?

Yes, if you specify “without replacement.” In Python, use random.sample(). In Excel, you can use =RANDBETWEEN(1,100) and then check for duplicates, but it’s easier to use a helper column with =RAND() and rank them. For a physical method, draw from a hat without putting the numbers back.

Are random numbers from a computer truly random?

No, most are pseudo-random. They are generated by deterministic algorithms, so if you know the seed, you can reproduce the sequence. True randomness comes from physical processes, like atmospheric noise or radioactive decay, which are used by services like random.org. For most non-security uses, pseudo-random is fine.

What is the best way to generate four random numbers for a lottery?

For a lottery, any method is fine because all combinations are equally likely. However, to avoid bias, use a mechanical or algorithmic generator rather than picking numbers yourself. If you want to avoid sharing a jackpot, choose numbers that are less popular (e.g., above 31, since many people use birthdays). But that doesn’t change your odds of winning, only the expected payout if you win.

How do I generate four random numbers in Excel that don’t change?

Enter =RANDBETWEEN(1,100) in four cells, then copy them and paste as values (right-click > Paste Special > Values). This freezes the numbers. Alternatively, use a static random number table or a random number generator add-in.

Why do I keep getting the same four numbers in Python?

That happens if you don’t set a seed and your program restarts, or if you set a fixed seed. Python’s random module seeds itself from system entropy by default, so each run should be different. If you’re using random.seed(0), you’ll get the same sequence every time—that’s intentional for reproducibility.

Can I generate four random numbers from a normal distribution?

Yes. In Python, use random.gauss(mu, sigma) four times. In Excel, use =NORM.INV(RAND(), mu, sigma). This gives numbers that cluster around the mean (mu) with a spread determined by sigma. For example, with mu=0 and sigma=1, you’ll get values mostly between -3 and 3.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.