发现异常的值在一个阵列,列表 [英] Finding unusual value in an array, list

查看:178
本文介绍了发现异常的值在一个阵列,列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数组形式的销售统计数据calc下标准差,或平均从这些数据。

I have sales statistic data in array form to calc standard deviation or average from this data.

stats = [100, 98, 102, 100, 108, 23, 120] 

让说,正常情况下, 23 显然是一个特例+ -20%差是。

let said +-20% differential is normal situation, 23 is obviously a special case.

什么是最好的算法(在任何语言,伪或原则)找到这个不寻常的价值呢?

what's the best algorithm (in any language, pseudo or any principle) to find this unusual value?

推荐答案

您可以将它们转换为 Z分数并查找异常值。

You could convert them to Z-scores and look for outliers.

>>> import numpy as np
>>> stats = [100, 98, 102, 100, 108, 23, 120]
>>> mean = np.mean(stats)
>>> std = np.std(stats)
>>> stats_z = [(s - mean)/std for s in stats]
>>> np.abs(stats_z) > 2
array([False, False, False, False, False,  True, False], dtype=bool)

这篇关于发现异常的值在一个阵列,列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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