如何找到中位数 [英] How to find Median

查看:126
本文介绍了如何找到中位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的数据.

Ram,500
Sam,400
Test,100
Ram,800
Sam,700
Test,300
Ram,900
Sam,800
Test,400

从上述数据中细化中位数"的最短方法是什么. 我的结果应该是...

What is the shortest way to fine the "median" from above data. My result should be something like...

中位数= 1/2(n + 1),其中n是样本中数据值的数量.

Median = 1/2(n+1), where n is the number of data values in the sample.

Test 500
Sam 700
Ram 800

推荐答案

Python 3.4包括统计信息 -in,因此您可以使用方法 statistics.median :

Python 3.4 includes statistics built-in, so you can use the method statistics.median:

>>> from statistics import median
>>> median([1, 3, 5])
 3

这篇关于如何找到中位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆