官术网_书友最值得收藏!

Calculating median using the NumPy package

Alright, so computing the median is just as simple as computing the mean. Just like we had NumPy mean, we have a NumPy median function as well.

We can just use the median function on incomes, which is our list of data, and that will give us the median. In this case, that came up to $26,911, which isn't very different from the mean of $26988. Again, the initial data was random, so your values will be slightly different.

np.median(incomes) 

The following is the output of the preceding code:

Out[4]: 26911.948365056276 

We don't expect to see a lot of outliers because this is a nice normal distribution. Median and mean will be comparable when you don't have a lot of weird outliers.

主站蜘蛛池模板: 丘北县| 绿春县| 仙居县| 衡南县| 五指山市| 兴宁市| 宿迁市| 玛纳斯县| 电白县| 潢川县| 四平市| 永年县| 白银市| 威远县| 色达县| 吉安县| 台北县| 曲周县| 上栗县| 喀喇沁旗| 姜堰市| 峨眉山市| 拉萨市| 荔浦县| 忻州市| 汝城县| 隆子县| 桑植县| 泌阳县| 隆昌县| 凌云县| 嘉义县| 澜沧| 崇阳县| 威宁| 元阳县| 钟山县| 钦州市| 会宁县| 三穗县| 宁陕县|