0
0
NumPydata~5 mins

Uniform random with random() in NumPy - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does numpy.random.random() do?
It generates a random float number between 0.0 (inclusive) and 1.0 (exclusive), following a uniform distribution.
Click to reveal answer
beginner
How to generate 5 random numbers between 0 and 1 using numpy?
Use numpy.random.random(5) to get an array of 5 random floats between 0 and 1.
Click to reveal answer
intermediate
How can you get random numbers between 10 and 20 using numpy.random.random()?
Multiply the output by 10 and add 10: 10 + 10 * numpy.random.random().
Click to reveal answer
intermediate
What is the difference between numpy.random.random() and numpy.random.uniform()?
random() generates numbers between 0 and 1 only, while uniform(low, high) lets you specify any range.
Click to reveal answer
beginner
Why is uniform random useful in data science?
It helps create random samples, simulate data, and test models with evenly spread values.
Click to reveal answer
What range of values does numpy.random.random() generate?
A0.0 (inclusive) to 1.0 (exclusive)
B0 to 1 inclusive
C-1 to 1
DAny float number
How do you generate an array of 3 random numbers between 0 and 1?
Anumpy.random.uniform(0,3)
Bnumpy.random.random() * 3
Cnumpy.random.random(3)
Dnumpy.random.randint(0,3)
How to get a random number between 5 and 15 using numpy.random.random()?
Anumpy.random.uniform(5, 15)
B5 + 10 * numpy.random.random()
Cnumpy.random.random() * 15
Dnumpy.random.random() + 5
Which function allows specifying any range for uniform random numbers?
Anumpy.random.normal()
Bnumpy.random.random()
Cnumpy.random.randint()
Dnumpy.random.uniform()
Why use uniform random numbers in simulations?
ATo get evenly spread random values
BTo get only integers
CTo get normal distribution
DTo get fixed values
Explain how to generate random numbers between any two values using numpy.random.random().
Think about multiplying and shifting the 0 to 1 output.
You got /3 concepts.
    Describe the difference between numpy.random.random() and numpy.random.uniform().
    One is fixed range, the other is flexible.
    You got /3 concepts.