当前位置:网站首页>Data analysis series 3 σ Rule / eliminate outliers according to laida criterion
Data analysis series 3 σ Rule / eliminate outliers according to laida criterion
2022-07-07 23:45:00 【Lang Xiaolin】
1 Related principles
3σ The principle is
The values are distributed in (μ-σ,μ+σ) The probability of 0.6827
The values are distributed in (μ-2σ,μ+2σ) The probability of 0.9545
The values are distributed in (μ-3σ,μ+3σ) The probability of 0.9973
It can be said that ,Y The values of are almost all concentrated in (μ-3σ,μ+3σ) Within the interval , There is no possibility of going beyond that 0.3%.
2 Code implementation
public class Pauta{
// Create the laida class
private double arr[]; // Accept raw array
public Pauta(double temp[]) {
// The original array obtained by the construction method
this.arr=temp;
System.out.print(" The original array :");
for(double x:arr) {
System.out.print(x+"、");
}
System.out.println();
}
public double average() {
// The arithmetic average method of the original array
double sum=0;
for(int x=0;x<arr.length;x++)
sum+=arr[x];
}
return sum/arr.length;
}
public double[] residualError() {
// Residual error method of the original array
double rE[]=new double[] {
};
for(int x=0;x<arr.length;x++) {
rE[x]=arr[x]-average();
}
return rE;
}
public double standardVariance() {
// How to calculate the standard variance value of the original array
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() {
// How to judge outliers , If abnormal , The output
for(int int x=0;x<arr.length;x++) {
if(Math.abs(arr[x]-average())>(3*standardVariance())) {
System.out.println(" The... Th in the array "+(x+1)+" Elements belong to outliers ");
}
}
}
}
public class client{
public static void main(String args[]) {
double data[]=new double[] {
1,2,8,10,8,5,2,4,6,11,15};// The original array
Pauta pau=new Pauta(data);// The original array is output after encapsulation
System.out.println(" Count the average :"+pau.average());// Count the average
/* The residual error output here is slightly */
System.out.println(" Standard deviation :"+pau.standardVariance());// Standard deviation
pau.judge();// How to judge outliers
}
}
Reference material :
https://wenku.baidu.com/view/cce8bacc142ded630b1c59eef8c75fbfc77d9407.html JAVA Use :3σ The rules 、 The procedure of eliminating outliers according to the laida criterion
边栏推荐
猜你喜欢
SAP HR labor contract information 0016
0-1背包问题
MySQL架构
C number of words, plus ¥, longest word, average value
Chisel tutorial - 05 Sequential logic in chisel (including explicit multi clock, explicit synchronous reset and explicit asynchronous reset)
MySQL Architecture
快速回复二极管整流特性
SAP HR 家庭成员信息
二叉排序树【BST】——创建、查找、删除、输出
HB 5469民用飞机机舱内部非金属材料燃烧试验方法
随机推荐
Stringutils tool class
【路径规划】使用垂距限值法与贝塞尔优化A星路径
【7.5】15. Sum of three numbers
The file format and extension of XLS do not match
Ora-01741 and ora-01704
MySQL Architecture
SAP HR 劳动合同信息 0016
Anxin vb01 offline voice module access intelligent curtain guidance
Restricted linear table
Right click the idea file to create new. There is no solution to create new servlet
C语言学习
【LeetCode】20、有效的括号
How did a fake offer steal $540million from "axie infinity"?
【7.4】25. K 个一组翻转链表
Svn relocation
一份假Offer如何盗走了「Axie infinity」5.4亿美元?
Take you hand in hand to build Eureka client with idea
Pycharm essential plug-in, change the background (self use, continuous update) | CSDN creation punch in
SAP HR social work experience 0023
C method question 2