A.I, Data and Software Engineering

Random seed

R

In this post, I have listed several methods to generate a random number. However, sometimes you can see people using a random seed to generate one.

Why need a seed to create a random number?

Quick answer: if you want to have control of the random sequence or let other people generate the same sequence of random numbers, take a seed.

We should know that a random number generated by the computer is based on some algorithm written by programmers. It means that it is not 100% random like the random process that you find in nature. In other words, we call it pseudo-random.

The random generator is somehow complicated, but for demo purposes, I assume that:

$$aRan_{i} = seed + X_{i}.$$

So if you select the same seed, then you can have the same sequence.

seed in Python.

if you run the code, you will always have the same sequence as mine:

seed in C#

And similarly, we have the same sequence :

Add comment

A.I, Data and Software Engineering

PetaMinds focuses on developing the coolest topics in data science, A.I, and programming, and make them so digestible for everyone to learn and create amazing applications in a short time.

Pin It on Pinterest

Newsletters

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

Petaminds will use the information you provide on this form to be in touch with you and to provide updates.