Tôi đã không thể tìm thấy chức năng này trong bất kỳ gói tiêu chuẩn nào, vì vậy tôi đã viết phần dưới đây. Trước khi ném nó về phía Cheeseshop, tuy nhiên, có ai biết về một phiên bản đã được xuất bản không? Ngoài ra, vui lòng đề xuất bất kỳ cải tiến nào. Cảm ơn.Tukey tổng số năm bản tóm tắt bằng Python
def fivenum(v):
"""Returns Tukey's five number summary (minimum, lower-hinge, median, upper-hinge, maximum) for the input vector, a list or array of numbers based on 1.5 times the interquartile distance"""
import numpy as np
from scipy.stats import scoreatpercentile
try:
np.sum(v)
except TypeError:
print('Error: you must provide a list or array of only numbers')
q1 = scoreatpercentile(v,25)
q3 = scoreatpercentile(v,75)
iqd = q3-q1
md = np.median(v)
whisker = 1.5*iqd
return np.min(v), md-whisker, md, md+whisker, np.max(v),
Đối với bất cứ điều gì nó có giá trị, matplotlib của 'boxplot' http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.boxplot hiệu quả thực hiện điều này, mặc dù gọi đó là chỉ để tính toán các thông số sẽ là clunky, để nói rằng ít nhất ... –
ô của Matlab không tính toán một bản tóm tắt số 5. Q1 và bản lề thấp thường giống nhau, nhưng không phải lúc nào cũng vậy! Ô lô tính toán Q1 sử dụng một phương pháp nhất định (có quá nhiều lựa chọn từ), nhưng nó không đảm bảo để sản xuất bản lề thấp hơn của Tukey. – russellpierce
Cf. http: //stats.stackexchange.com/questions/51801/interpreting-weird-box-plot/51806? noredirect = 1 # comment101742_51806 – russellpierce