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

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.

主站蜘蛛池模板: 沾化县| 靖安县| 绍兴县| 云南省| 新龙县| 驻马店市| 五河县| 道真| 浏阳市| 枣强县| 临颍县| 武强县| 含山县| 白银市| 长阳| 祥云县| 奉新县| 云阳县| 岗巴县| 清水河县| 灵宝市| 富民县| 桐城市| 安阳县| 崇文区| 宣化县| 霸州市| 古浪县| 崇义县| 二连浩特市| 义乌市| 兴海县| 孟州市| 五台县| 车险| 齐河县| 江达县| 浦江县| 临夏县| 大城县| 揭东县|