Bird
0
0

Why does np.random.rand() always generate numbers between 0 and 1?

hard📝 Conceptual Q10 of 15
NumPy - Creating Arrays
Why does np.random.rand() always generate numbers between 0 and 1?
ABecause it generates random bytes converted to floats
BBecause it samples from a uniform distribution over [0, 1)
CBecause it uses a normal distribution centered at 0.5
DBecause it generates integers and divides by 1
Step-by-Step Solution
Solution:
  1. Step 1: Understand np.random.rand distribution

    np.random.rand samples from a uniform distribution between 0 (inclusive) and 1 (exclusive).
  2. Step 2: Eliminate incorrect options

    It does not generate integers, nor use normal distribution or bytes conversion.
  3. Final Answer:

    Because it samples from a uniform distribution over [0, 1) -> Option B
  4. Quick Check:

    Uniform distribution explains range [OK]
Quick Trick: np.random.rand uses uniform distribution [OK]
Common Mistakes:
  • Thinking it generates integers
  • Confusing with normal distribution
  • Assuming byte conversion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes