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

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.

主站蜘蛛池模板: 清新县| 江永县| 平塘县| 兰溪市| 江山市| 桃江县| 安福县| 兰西县| 贵州省| 榆社县| 西华县| 包头市| 岗巴县| 汨罗市| 澄城县| 维西| 宁武县| 莱州市| 香格里拉县| 阿坝| 砚山县| 芷江| 万载县| 汨罗市| 延川县| 犍为县| 都江堰市| 镶黄旗| 交口县| 靖远县| 林西县| 上犹县| 丹寨县| 乐都县| 枞阳县| 湘潭县| 英德市| 和政县| 缙云县| 当阳市| 临西县|