当前位置:网站首页>C # use laida criterion (3) σ Criteria) reject abnormal data (.Net reject singular values in a group of data)
C # use laida criterion (3) σ Criteria) reject abnormal data (.Net reject singular values in a group of data)
2022-04-23 07:48:00 【Dake mountain man】
1、 Problem presentation :
Battery production , The measurement result data of a batch of batteries :
Voltage value | Number of batteries | Voltage value | Number of batteries | Voltage value | Number of batteries | Voltage value | Number of batteries | |||
0.056 | 1 | 4.09 | 1 | 4.146 | 17 | 4.174 | 13434 | |||
0.321 | 1 | 4.094 | 1 | 4.147 | 17 | 4.175 | 13973 | |||
0.767 | 1 | 4.099 | 2 | 4.148 | 19 | 4.176 | 13339 | |||
0.972 | 1 | 4.112 | 1 | 4.149 | 23 | 4.177 | 12275 | |||
3.098 | 1 | 4.119 | 3 | 4.15 | 26 | 4.178 | 10309 | |||
3.187 | 1 | 4.12 | 1 | 4.151 | 40 | 4.179 | 8376 | |||
3.319 | 1 | 4.121 | 1 | 4.152 | 50 | 4.18 | 6324 | |||
3.526 | 1 | 4.122 | 3 | 4.153 | 75 | 4.181 | 4667 | |||
3.53 | 1 | 4.125 | 3 | 4.154 | 84 | 4.182 | 3340 | |||
3.532 | 1 | 4.126 | 2 | 4.155 | 100 | 4.183 | 2358 | |||
3.54 | 1 | 4.127 | 1 | 4.156 | 118 | 4.184 | 1719 | |||
3.541 | 1 | 4.128 | 2 | 4.157 | 153 | 4.185 | 1199 | |||
3.544 | 1 | 4.129 | 3 | 4.158 | 173 | 4.186 | 839 | |||
3.545 | 2 | 4.13 | 2 | 4.159 | 248 | 4.187 | 622 | |||
3.832 | 1 | 4.132 | 2 | 4.16 | 335 | 4.188 | 417 | |||
3.928 | 1 | 4.133 | 2 | 4.161 | 419 | 4.189 | 304 | |||
3.93 | 1 | 4.134 | 4 | 4.162 | 540 | 4.19 | 170 | |||
3.951 | 1 | 4.135 | 1 | 4.163 | 731 | 4.191 | 124 | |||
3.963 | 1 | 4.136 | 5 | 4.164 | 962 | 4.192 | 77 | |||
3.972 | 1 | 4.137 | 4 | 4.165 | 1359 | 4.193 | 43 | |||
3.973 | 2 | 4.138 | 6 | 4.166 | 1846 | 4.194 | 44 | |||
4.045 | 1 | 4.139 | 9 | 4.167 | 2621 | 4.195 | 25 | |||
4.046 | 1 | 4.14 | 2 | 4.168 | 3728 | 4.196 | 20 | |||
4.079 | 1 | 4.141 | 6 | 4.169 | 5086 | 4.197 | 8 | |||
4.085 | 1 | 4.142 | 4 | 4.17 | 6822 | 4.198 | 9 | |||
4.087 | 1 | 4.143 | 6 | 4.171 | 8649 | 4.199 | 5 | |||
4.088 | 1 | 4.144 | 13 | 4.172 | 10210 | 4.2 | 3 | |||
4.089 | 1 | 4.145 | 14 | 4.173 | 12072 |
among , The voltage of some batteries is too low and too high , Does not conform to the normal distribution .
Now we need to eliminate these abnormal battery data .
2、 Methods the principle :
3σ The criterion is also known as the laida criterion , It assumes that a set of test data contains only random errors , The standard deviation is calculated and processed , Determine an interval according to a certain probability , If the error exceeds this range , It's not a random error, it's a gross error , Data containing this error should be eliminated .
In the normal distribution σ Represents the standard deviation ,μ For mean .x=μ That is, the axis of symmetry of the image
3σ principle :
The values are distributed in (μ-σ,μ+σ) The probability of 0.6827
The values are distributed in (μ-2σ,μ+2σ) The probability of 0.9544
The values are distributed in (μ-3σ,μ+3σ) The probability of 0.9974
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%.
3、C# The concrete realization of :
// Define voltage - Class of quantitative relationship
public class VoltageCount
{
public Double Voltage { get; set; }
public int CountV { get; set; }
public VoltageCount()
{
}
public VoltageCount(Double voltage, int countV)
{
this.Voltage = voltage;
this.CountV = countV;
}
}
// Key classes use the laida criterion (3σ Rules ) Eliminate data exceptions
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Photo.QQAA.Net.Helper
{
/// <summary>
/// Use the laida rule (3σ Rules ) Eliminate data exceptions
/// </summary>
public class ExceptionVoltageHelper
{
List<VoltageCount> listVoltageCount;
double average = 0.0;
int _badDataCount = -1;// Number of singular values
/// <summary>
/// Get the number of singular values
/// </summary>
public int BadDataCount
{
get { return _badDataCount; }
}
public ExceptionVoltageHelper(List<VoltageCount> list)
{
this.listVoltageCount = list;
SetAverage();
}
/// <summary>
/// Obtain the average voltage value
/// </summary>
/// <returns></returns>
protected double GetAvgVoltage()
{
double avg = 0;
double total = 0;
int allCount = 0;
foreach (VoltageCount vc in listVoltageCount)
{
double v = vc.Voltage;
int c = vc.CountV;
total += v * c;
allCount += c;
}
avg = total / (allCount * 1.0);
return Math.Round(avg, 3, MidpointRounding.AwayFromZero);
}
/// <summary>
/// Average
/// </summary>
/// <returns></returns>
void SetAverage()
{
this.average = GetAvgVoltage();
}
/// <summary>
/// Standard deviation
/// </summary>
/// <returns></returns>
double StandardDeviation()
{
List<double> listDataV = new List<double>();
foreach (VoltageCount vc in this.listVoltageCount)
{
double v = vc.Voltage;
int countV = vc.CountV;
for (int i = 0; i < countV; i++ )
{
listDataV.Add((v - this.average) * (v - this.average));
}
}
double sumDataV = listDataV.Sum();
double std = Math.Sqrt(sumDataV / (listDataV.Count - 1));
return std;
}
public List<VoltageCount> GetGoodList()
{
_badDataCount = 0;
double sd3 = StandardDeviation() * 3;//3 Times the standard deviation
List<VoltageCount> listVC = new List<VoltageCount>();
foreach (VoltageCount vc in this.listVoltageCount)
{
if (Math.Abs(vc.Voltage - this.average) <= sd3)
{
listVC.Add(vc);
}
else
{
_badDataCount += vc.CountV;
}
}
return listVC;
}
}
}
4、 Limitations and precautions :
Ben 3σ The rule is limited to the processing of sample data with normal or approximate normal distribution , It is also applicable when there are many groups of data .
The principle and method of this discrimination processing are based on the premise that the number of measurements is sufficiently large , When the number of measurements is small, it is not reliable to eliminate gross errors with criteria . therefore , In the case of fewer measurements , It's best not to use the guidelines , And use other criteria .
版权声明
本文为[Dake mountain man]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230625378940.html
边栏推荐
- MySQL storage engine
- electron-builder打包报错:proxyconnect tcp: dial tcp :0: connectex
- 利用Lambda表达式解决c#文件名排序问题(是100大还是11大的问题)
- SAP Excel 已完成文件级验证和修复。此工作簿的某些部分可能已被修复或丢弃。
- Quick sort
- Custom time format (yyyy-mm-dd HH: mm: SS week x)
- Judge whether the beginning and end of the string contain target parameters: startswith() and endswith() methods
- NodeJS(二)同步读取文件和异步读取文件
- Game assisted script development journey
- FUEL: Fast UAV Exploration using Incremental Frontier Structure and Hierarchical Planning
猜你喜欢
js之DOM事件
利用Lambda表达式解决c#文件名排序问题(是100大还是11大的问题)
移动端布局(3D转换、动画)
js之预解析
King glory - unity learning journey
FSM finite state machine
ABAP 从CDS VIEW 发布OData Service示例
Understanding the Role of Individual Units in a Deep Neural Networks(了解各个卷积核在神经网络中的作用)
FUEL: Fast UAV Exploration using Incremental Frontier Structure and Hierarchical Planning
Redis connection error err auth < password > called without any password configured for the default user
随机推荐
Nodejs (four) character reading
C# SmoothProgressBar自定义进度条控件
C operation registry full introduction
MySQL in window10 version does not work after setting remote access permission
Solve the problem of deploying mysql8 in docker with correct password but unable to log in to MySQL
驼峰命名对像
js之预解析
读取修改resource文件夹下的json文件
Super classic & Programming Guide (red and blue book) - Reading Notes
SAP Excel 已完成文件级验证和修复。此工作簿的某些部分可能已被修复或丢弃。
事件系统(二)多播事件
SAP CR传输请求顺序、依赖检查
Window10版MySQL设置远程访问权限后不起效果
双面显示的shader
12. Constraints
SAP 03-AMDP CDS Table Function using ‘WITH‘ Clause(Join子查询内容)
Robust and Efficient Quadrotor Trajectory Generation for Fast Autonomous Flight
基于NLP的软件安全研究(一)
The page displays the current time in real time
Unity screen adaptation