← Back to NumPy Course | Chapter 9: Random Module | Lesson 6 of 6

np.random.normal/uniform का इस्तेमाल

normal किसी भी mean और spread के साथ bell-curve numbers draw करता है; uniform किसी भी range से evenly spread numbers draw करता है।

In this page:

  1. np.random.normal/uniform
Syntax
python
np.random.normal(loc, scale, size)
np.random.uniform(low, high, size)

np.random.normal/uniform

np.random.normal(loc, scale, size) mean loc और standard deviation scale वाली एक normal distribution से draw करता है। np.random.uniform(low, high, size) दो values के बीच evenly floats draw करता है। ये सबसे flexible everyday distributions हैं।

Note: एक बड़े sample के साथ, normal values का mean loc के करीब आता है।

उदाहरण: np.random.normal/uniform

python
import numpy as np

np.random.seed(10)
heights = np.random.normal(170, 8, size=1000)
print(round(heights.mean(), 1), round(heights.std(), 1))
u = np.random.uniform(5, 10, size=5)
print(u.round(2))

# Output:
# 169.9 7.5
# [7.37 8.9  9.25 7.29 8.28]
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. standard deviation की बजाय scale की तरह variance pass करना
  2. uniform में low और high mix up करना
  3. छोटे samples का expected values से match न होना
चैप्टर सारांश
  • normal mean और std लेता है
  • uniform low और high लेता है
  • scale standard deviation है
  • बड़े samples true values के करीब आते हैं
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.