当前位置:网站首页>数据分析系列 之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σ规则、依据拉依达准则来剔除异常值程序
边栏推荐
- USB (XV) 2022-04-14
- KeePass realizes automatic input of web pages
- ASP. Net open web page
- 高效的S2B2C电商系统,是这样帮助电子材料企业提升应变能力的
- B_ QuRT_ User_ Guide(38)
- Ora-01741 and ora-01704
- Oracle string sorting
- Unity3d learning notes 5 - create sub mesh
- The efficient s2b2c e-commerce system helps electronic material enterprises improve their adaptability in this way
- The 19th Zhejiang Provincial College Programming Contest VP record + supplementary questions
猜你喜欢

C simple question one

电子设备行业智能供应链协同平台解决方案:解决低效, 赋能产业数字化升级

Map operation execution process

B_QuRT_User_Guide(36)

MySQL Index Optimization Practice II
![[stm32+esp8266 connects to Tencent cloud IOT development platform 3] stm32+esp8266-01s dynamically registers devices on Tencent cloud (at instruction mode) -- with source code](/img/55/ab50ead2564498cb214d98ac5b9c3d.jpg)
[stm32+esp8266 connects to Tencent cloud IOT development platform 3] stm32+esp8266-01s dynamically registers devices on Tencent cloud (at instruction mode) -- with source code

0-1 knapsack problem

Get started with mongodb

C # exchange number, judge to pass the exam

KeePass realizes automatic input of web pages
随机推荐
Interface
【7.4】25. Turn over the linked list in groups of K
Map operation execution process
Extended tree (I) - graphic analysis and C language implementation
Fibonacci number of dynamic programming
Summary of common methods of object class (September 14, 2020)
建筑建材行业SRM供应商云协同管理平台解决方案,实现业务应用可扩展可配置
KeePass realizes automatic input of web pages
C number of words, plus ¥, longest word, average value
Oracle database backup and recovery
B_ QuRT_ User_ Guide(40)
Matlab SEIR infectious disease model prediction
IDEA 2021.3. X cracking
[untitled]
UE4_ Ue5 panoramic camera
S2b2b mall solution of intelligent supply chain in packaging industry: opening up a new ecosystem of e-commerce consumption
Summary of SQL single table query 2020.7.27
Right click the idea file to create new. There is no solution to create new servlet
The file format and extension of XLS do not match
[summary] some panels and videos seen