← Back to NumPy Course | Chapter 8: Statistics | Lesson 4 of 6

np.histogram() से Histogram बनाना

एक histogram कुछ भी draw किए बिना count करता है कि कितनी values हर range (bin) में आती हैं।

In this page:

  1. np.histogram()
Syntax
python
counts, bin_edges = np.histogram(arr, bins=number_of_bins)

np.histogram()

np.histogram(a, bins) दो arrays return करता है: प्रति bin counts और bin edges, जो counts से एक ज़्यादा लंबी है। bins एक integer या explicit edges हो सकती है। यह एक histogram plot के पीछे के numbers provide करता है।

Note: counts की बजाय probabilities पाने के लिए density=True set करें।

उदाहरण: np.histogram()

python
import numpy as np

a = np.array([1, 2, 2, 3, 3, 3, 4, 4, 5, 9])
counts, edges = np.histogram(a, bins=[0, 3, 6, 10])
print(counts)
print(edges)

# Output:
# [3 6 1]
# [ 0  3  6 10]
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. यह भूल जाना कि edges में counts से एक ज़्यादा item है
  2. एक plot appear होने की उम्मीद करना
  3. बहुत कम या बहुत ज़्यादा bins इस्तेमाल करना
चैप्टर सारांश
  • Counts और edges return करता है
  • Edges counts से एक लंबी हैं
  • bins एक number या list हो सकती है
  • density normalise करता है
🔒

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.