当前位置:网站首页>数据分析系列 之3σ规则/依据拉依达准则来剔除异常值
数据分析系列 之3σ规则/依据拉依达准则来剔除异常值
2022-07-07 21:52:00 【琅晓琳】
1 相关原理
3σ原则为
数值分布在(μ-σ,μ+σ)中的概率为0.6827
数值分布在(μ-2σ,μ+2σ)中的概率为0.9545
数值分布在(μ-3σ,μ+3σ)中的概率为0.9973
可以认为,Y 的取值几乎全部集中在(μ-3σ,μ+3σ)区间内,超出这个范围的可能性仅占不到0.3%.
2 代码实现
public class Pauta{
//创建拉依达类
private double arr[]; //接受原始数组
public Pauta(double temp[]) {
//利用构造方法来得的原始数组
this.arr=temp;
System.out.print("原始数组:");
for(double x:arr) {
System.out.print(x+"、");
}
System.out.println();
}
public double average() {
//原始数组的算数平均值方法
double sum=0;
for(int x=0;x<arr.length;x++)
sum+=arr[x];
}
return sum/arr.length;
}
public double[] residualError() {
//原始数组的剩余误差方法
double rE[]=new double[] {
};
for(int x=0;x<arr.length;x++) {
rE[x]=arr[x]-average();
}
return rE;
}
public double standardVariance() {
//原始数组的标准方差值计算方法
double sum=0;
for(int int x=0;x<arr.length;x++) {
sum+=Math.pow(arr[x]-average(),2);
}
return Math.sqrt(sum/(arr.length-1));
}
public void judge() {
//判断异常值方法,若异常,则输出
for(int int x=0;x<arr.length;x++) {
if(Math.abs(arr[x]-average())>(3*standardVariance())) {
System.out.println("该数组中的第"+(x+1)+"个元素属于异常值");
}
}
}
}
public class client{
public static void main(String args[]) {
double data[]=new double[] {
1,2,8,10,8,5,2,4,6,11,15};//原始数组
Pauta pau=new Pauta(data);//原始数组封装后输出
System.out.println("算数平均值:"+pau.average());//算数平均值
/*此处的剩余误差输出略*/
System.out.println("标准方差:"+pau.standardVariance());//标准方差
pau.judge();//判断异常值方法
}
}
参考资料:
https://wenku.baidu.com/view/cce8bacc142ded630b1c59eef8c75fbfc77d9407.html JAVA使用:3σ规则、依据拉依达准则来剔除异常值程序
边栏推荐
- SAP HR family member information
- windows设置redis开启自动启动
- Anxinco esp32-a1s development board is adapted to Baidu dueros routine to realize online voice function
- [STM32 + esp-12s connect Tencent cloud IOT development platform 1] creation of cloud platform and burning of at firmware
- Senior programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization, and recommends collecting
- MySQL架构
- HDU 4747 mex "recommended collection"
- 0-1背包问题
- Oracle statistics by time
- Unity3d Learning Notes 6 - GPU instantiation (1)
猜你喜欢
Anxinco esp32-a1s development board is adapted to Baidu dueros routine to realize online voice function
SAP 内存参数调优过程
USB (XV) 2022-04-14
SAP HR family member information
SAP HR 家庭成员信息
Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f
Unity3d learning notes 5 - create sub mesh
移动端异构运算技术 - GPU OpenCL 编程(基础篇)
The efficient s2b2c e-commerce system helps electronic material enterprises improve their adaptability in this way
Oracle database backup and recovery
随机推荐
Windows set redis to start automatically
Flash encryption process and implementation of esp32
Digital procurement management system for fresh food industry: help fresh food enterprises solve procurement problems and implement online procurement throughout the process
【7.5】15. Sum of three numbers
MySQL架构
Force deduction solution summary 648 word replacement
The 19th Zhejiang Provincial College Programming Contest 2022 f.easyfix chairman tree
Caip2021 preliminary VP
LM12丨Rolling Heikin Ashi二重K线滤波器
Right click the idea file to create new. There is no solution to create new servlet
B_QuRT_User_Guide(36)
The 19th Zhejiang Provincial College Programming Contest VP record + supplementary questions
Extended tree (I) - graphic analysis and C language implementation
【实验分享】通过Console口登录到Cisco设备
C method question 1
Illegal behavior analysis 1
Summary of common methods of object class (September 14, 2020)
B_ QuRT_ User_ Guide(37)
Sequence of entity layer, Dao layer, service layer and controller layer
C simple question 2