1597068000

“Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin.” — John von Neumann (1949)

Random numbers are widely used for sampling, simulation and find their applications in games and cryptography. The simplest way to generate a set of random numbers is to roll a die. In fact, Dice are the oldest (used since before recorded history circa 2800–2500 BC) and still in use Random Number Generators. However, generating a sequence of random numbers using dice is both time-consuming and limited by the number of faces on dice in-use. A Roulette Wheel is another example of a physical method that can also generate a sequence of statistically independent random numbers.

With the advent of machines with computing power in the 1940s, random numbers were found useful for a diversity of applications including the ones that employed the Monte Carlo method. Some of the scientific applications and projects like the Manhattan Project for nuclear weapons required a large number of random digits of high quality to be made available for simulations. Motivated by such requirements of having a large set of random numbers, RAND Corporation designed an electronic roulette wheel to generate a sequence for random numbers and published it in a random number book titled A Million Random Digits with 100,000 Normal Deviates. For the first time, researchers, mathematicians, and scientists got access to a long sequence of high-quality random numbers through this book. It was also possible to order the digits on a series of punched cards.

#java #computer-science #random-numbers #random-number-generator #clojure

1625013180

There are two types of random number generators: pseudo-random number generator and true random number generator.

**Pseudorandom numbers** depend on computer algorithms. The computer uses algorithms to generate random numbers. These random numbers are not truly random because they are predictable like the generated numbers using NumPy random seed.

Whereas, **truly random numbers** are generated by measuring truly physical random parameters so we can ensure that the generated numbers are truly random.

The pseudo-random numbers are not safe to use in cryptography because they can be guessed by attackers.

In Python, the built-in **random** module generates pseudo-random numbers. In this tutorial, we will discuss both types. So let’s get started.

Table of Contents

- Random number between 0 and 100
- Random number with a step size
- Random floating/double number in a range
- Random number from Iterable
- Using random.choice()
- Using randint()
- Using randrange()
- Excluding certain numbers from a range (Conditional choice)
- Random number of length N
- Random numbers in a two-dimensional array
- Random number probability
- Mean and standard deviation
- Negative random number
- Generate with duplicates
- Using randrange()
- Using choice()
- Generate without duplicates (Unique random numbers)
- Random number on circle
- Shuffle Numbers
- Generate true random number

#python #random #generate random numbers #random numbers #generate random numbers in python

1597068000

“Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin.” — John von Neumann (1949)

Random numbers are widely used for sampling, simulation and find their applications in games and cryptography. The simplest way to generate a set of random numbers is to roll a die. In fact, Dice are the oldest (used since before recorded history circa 2800–2500 BC) and still in use Random Number Generators. However, generating a sequence of random numbers using dice is both time-consuming and limited by the number of faces on dice in-use. A Roulette Wheel is another example of a physical method that can also generate a sequence of statistically independent random numbers.

With the advent of machines with computing power in the 1940s, random numbers were found useful for a diversity of applications including the ones that employed the Monte Carlo method. Some of the scientific applications and projects like the Manhattan Project for nuclear weapons required a large number of random digits of high quality to be made available for simulations. Motivated by such requirements of having a large set of random numbers, RAND Corporation designed an electronic roulette wheel to generate a sequence for random numbers and published it in a random number book titled A Million Random Digits with 100,000 Normal Deviates. For the first time, researchers, mathematicians, and scientists got access to a long sequence of high-quality random numbers through this book. It was also possible to order the digits on a series of punched cards.

#java #computer-science #random-numbers #random-number-generator #clojure

1619607900

Introduction

A number is said to be the perfect number if the sum of its proper divisors (not including the number itself) is equal to the number.

To get a better idea let’s consider an example, proper divisors of 6 are 1, 2, 3. Now the sum of these divisors is equal to 6 (1+2+3=6), so 6 is said to be a perfect number. Whereas if we consider another number like 12, proper divisors of 12 are 1, 2, 3, 4, 6. Now the sum of these divisors is not equal to 12, so 12 is not a perfect number.

Programming in Python is relatively simpler and more fun when compared to other languages because of its simpler syntax, good readability. Now that we are clear with the concept of perfect number let’s write a python program to check if a number is a perfect number or not. Let’s build a python code for checking if the given user input is a perfect number or not and explore the fun in coding with python.

#data science #how to check if a number is perfect #perfect number #perfect number in python #perfect number program in python #python

1620418260

Introduction

A number is said to be the perfect number if the sum of its proper divisors (not including the number itself) is equal to the number.

To get a better idea let’s consider an example, proper divisors of 6 are 1, 2, 3. Now the sum of these divisors is equal to 6 (1+2+3=6), so 6 is said to be a perfect number. Whereas if we consider another number like 12, proper divisors of 12 are 1, 2, 3, 4, 6. Now the sum of these divisors is not equal to 12, so 12 is not a perfect number.

Programming in Python is relatively simpler and more fun when compared to other languages because of its simpler syntax, good readability. Now that we are clear with the concept of perfect number let’s write a python program to check if a number is a perfect number or not. Let’s build a python code for checking if the given user input is a perfect number or not and explore the fun in coding with python.

#data science #how to check if a number is perfect #perfect number #perfect number in python #perfect number program in python #python

1601952916

The random() function in Python is used to generate the pseudo-random numbers. It generates numbers for some values called **seed** value.

The seed function is used to store a random method to generate the same random numbers on multiple executions of the code on the same machine or different machines.

The seed value is precious in computer security to pseudo-randomly produce a secure secret encryption key. So using the custom seed value, you can initialize the secure pseudo-random number generator the extent you need.

The random.seed() function in Python is used to **initialize** the random numbers. By default, the random number generator uses the **current system time**. If you use the same seed value twice, you get the same output means random number twice.

```
random.seed(svalue, version)
```

#python #python random #pseudo-random