# How to simulate random numbers in Python

A gentle introduction

Random numbers are used in a lot of applications. They are more predominantly used in areas like statistics, probability theory, data science, signal processing, statistical physics, machine learning, actuarial science, quantitative finance, and more. Yet they can be a bit challenging to understand due to their… well, random nature.

First, we need to come clean about something. Random numbers generated in computers are not truly random, in fact they are referred to as “pseudo-random” numbers. The reason for this is that they are basically constructed from a huge number of digit sequences which are then converted into a set of integers within a certain range. These sequences are pre-defined and are simply permuted in certain ways so as to give the illusion of “drawing a random number” each time. Modern programs like Matlab can often expand on this a bit by looking at things like the time-stamp in the computer’s CPU or RAM, from which a specific digit sequence is drawn. So technically you should get a different “random number” every time you press Enter because the time stamp changes. However, since there is a finite number of unique digit sequences that can be stored in the computer, you could easily draw the same random number after a while. There are of course other more sophisticated methods for generating random numbers…