Computer Science & Philosophy

What are Random Numbers?

By Devesh March 16, 2024 5 min read
Computer Random Number Generation

Since I was a child, one question always fascinated me: How does a computer know how to generate a "random" number?🤔

The Mystery Behind Random Numbers

We've all used random number generators while coding—import a function, and that's it, there's your number! But have you ever thought how a human-written program actually creates randomness? Let's break it down:

The Seeds of Randomness

When you ask a program for a random number, it doesn't just magically pull a number. Instead, it looks at several unpredictable factors in your system, like:

These are basic examples. In more secure or complex scenarios, the program might look at your CPU's state, electrical noise, thermal energy, or even the flow of network traffic. All these unpredictable elements combine to create what we call "entropy" (second name of randomness).

How It Actually Works

For example, if a program needs a random number between 1 and 10, it might generate a 7 based on the exact time your request was made.

If you think this deeply you will be able to figure out that the random numbers aren't truly random—they are generated based on some algorithm working behind the scenes.

The Philosophical Twist

Now, here's a fun twist: if you could crack the algorithm, you could predict what number the computer will generate before it does! In the same way, if you can understand how a person thinks, based on all their experiences and "inputs," you might predict their choices, too.

The Social Impact

And if you could influence those inputs? Well, then you might just shape the outcome! (Example: Social media platforms influencing voting, or even religious beliefs of the people) Fascinating, isn't it?