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

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.

主站蜘蛛池模板: 遵义县| 塘沽区| 林口县| 栖霞市| 锦州市| 界首市| 柏乡县| 图木舒克市| 寿光市| 巨鹿县| 和政县| 文登市| 阿克苏市| 丰顺县| 两当县| 沂源县| 临沂市| 从化市| 嘉祥县| 钟山县| 西青区| 仙居县| 茂名市| 昌图县| 烟台市| 怀化市| 库车县| 昆山市| 横峰县| 三台县| 中卫市| 时尚| 长治县| 砀山县| 南溪县| 澄迈县| 炉霍县| 师宗县| 玛沁县| 永靖县| 德昌县|