Write a NumPy program to calculate percentiles for a sequence or single-dimensional NumPy array

  • برمجة بايثون

Write a NumPy program to calculate percentiles for a sequence or single-dimensional NumPy array.

الأجوبة

import numpy as np
nums = np.array([1,2,3,4,5])
print("50th percentile (median):")
p = np.percentile(nums, 50)
print(p)
print("40th percentile:")
p = np.percentile(nums, 40)
print(p)
print("90th percentile:")
p = np.percentile(nums, 90)
print(p)
Sample Output:
50th percentile (median):
3.0
40th percentile:
2.6
90th percentile:
4.6
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...