Write a NumPy program to compute the histogram of nums against the bins
- برمجة بايثون
- 2021-09-13
- mhanasmh00489829403
الأجوبة
import numpy as np
import matplotlib.pyplot as plt
nums = np.array([0.5, 0.7, 1.0, 1.2, 1.3, 2.1])
bins = np.array([0, 1, 2, 3])
print("nums: ",nums)
print("bins: ",bins)
print("Result:", np.histogram(nums, bins))
plt.hist(nums, bins=bins)
plt.show()
Sample Output:
nums: [0.5 0.7 1. 1.2 1.3 2.1] bins: [0 1 2 3] Result: (array([2, 3, 1], dtype=int64), array([0, 1, 2, 3]))
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
