当前位置:网站首页>数据分析系列 之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σ规则、依据拉依达准则来剔除异常值程序
边栏推荐
- 2022注册测绘师备考开始 还在不知所措?手把手教你怎么考?
- Oracle string sorting
- Unity3d Learning Notes 6 - GPU instantiation (1)
- SAP 内存参数调优过程
- MongoDB快速入门
- 欢聚时代一面
- Get started with mongodb
- 648. Word replacement
- The efficient s2b2c e-commerce system helps electronic material enterprises improve their adaptability in this way
- 包装行业智能供应链S2B2B商城解决方案:开辟电商消费新生态
猜你喜欢
UE4_ Use of ue5 blueprint command node (turn on / off screen response log publish full screen display)
B_QuRT_User_Guide(36)
C method question 1
UE4_ Ue5 panoramic camera
MySQL架构
Unity3d learning notes 5 - create sub mesh
Summary of SQL single table query 2020.7.27
Map operation execution process
2022 certified surveyors are still at a loss when preparing for the exam? Teach you how to take the exam hand in hand?
[compilation principle] lexical analysis design and Implementation
随机推荐
Home appliance industry channel business collaboration system solution: help home appliance enterprises quickly realize the Internet of channels
As a new force, chenglian premium products was initially injected, and the shares of relevant listed companies rose 150% in response
System design overview
Mobile heterogeneous computing technology - GPU OpenCL programming (basic)
C # exchange number, judge to pass the exam
B_QuRT_User_Guide(37)
Interface
MongoDB快速入门
[stm32+esp8266 connect Tencent cloud IOT development platform 2] stm32+esp8266-01s connect Tencent cloud
Deep understanding of MySQL lock and transaction isolation level
B_ QuRT_ User_ Guide(37)
[experiment sharing] log in to Cisco devices through the console port
Three questions TDM
B_ QuRT_ User_ Guide(38)
SAP HR奖罚信息导出
postgis学习
Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f
Force deduction solution summary 648 word replacement
进度播报|广州地铁七号线全线29台盾构机全部完成始发
SRM supplier cloud collaborative management platform solution for building materials industry to realize business application scalability and configuration