python拉依达准则
时间: 2023-10-17 19:26:49 浏览: 202
拉依达准则(Pau'ta Criteron)是一种用于识别异常值的统计方法。该方法首先假设数据集中只包含随机误差,然后根据一定的准则计算标准偏差,并基于一定的概率确定一个区间。如果数据点不在这个区间内,就被认为是异常值。在Python中,可以使用统计库中的函数来实现拉依达准则。
一个实现拉依达准则的Python代码示例如下:
```python
import numpy as np
def outlier_detection(data):
mean = np.mean(data)
std = np.std(data)
lower_bound = mean - 3 * std
upper_bound = mean + 3 * std
outliers = [x for x in data if x < lower_bound or x > upper_bound]
return outliers
# 示例数据
data = [1222, 87, 77, 92, 68, 80, 78, 84, 77, 81, 80, 80, 77, 92, 86, 76, 80, 81, 75, 77, 72, 81, 72, 84, 86, 80, 68, 77, 87, 76, 77, 78, 92, 75, 80, 78, 123, 3, 1223, 1232]
outliers = outlier_detection(data)
print("拉依达准则检测到的异常值如下:")
print(outliers)
```
以上代码会输出拉依达准则检测到的异常值,即不在平均值-3标准差和平均值+3标准差之间的数据点。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [Python:使用拉依达准则(3σ准则)剔除excel表中异常数据](https://blog.csdn.net/weixin_43996337/article/details/120830794)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [【python 机器学习】正态分布检验以及异常值处理3σ原则](https://blog.csdn.net/u013421629/article/details/103870567)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文