当前位置:网站首页>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
边栏推荐
- 4. Multi table query
- 使用flask时代码无报错自动结束,无法保持连接,访问不了url。
- SAP SALV14 后台输出SALV数据可直接保存文件,发送Email(带排序、超链接、筛选格式)
- C reads the registry
- SAP pi / PO rfc2restful publishing RFC interface is a restful example (proxy indirect method)
- NodeJS(四) 字符读取
- Game assisted script development journey
- One of event management
- MySQL isolation level
- 对js中argumens的简单理解
猜你喜欢

Super classic & Programming Guide (red and blue book) - Reading Notes

Dropping Pixels for Adversarial Robustness

Page dynamic display time (upgraded version)

Implementation of MySQL persistence

Understanding the Role of Individual Units in a Deep Neural Networks(了解各个卷积核在神经网络中的作用)

FUEL: Fast UAV Exploration using Incremental Frontier Structure and Hierarchical Planning

Teach-Repeat-Replan: A Complete and Robust System for Aggressive Flight in Complex Environments

SQL sorts string numbers

平面定义-平面方程

SAP pi / PO rfc2soap publishes RFC interface as WS example
随机推荐
Preliminary configuration of OpenGL super Dictionary (freeglut, glew, gltools, GLUT)
SAP 03-AMDP CDS Table Function using ‘WITH‘ Clause(Join子查询内容)
Install and configure Taobao image NPM (cnpm)
利用网页表格导出EXCEL表格加线框及表格内部间距的问题
大学学习路线规划建议贴
FSM finite state machine
Understanding of STL container
Judge whether the beginning and end of the string contain target parameters: startswith() and endswith() methods
King glory - unity learning journey
反转链表练习
promise all的实现
平面定义-平面方程
斐波拉去动态规划
Thorough inquiry -- understanding and analysis of cocos2d source code
定位、修饰样式
Robust and Efficient Quadrotor Trajectory Generation for Fast Autonomous Flight
保研准备经验贴——18届(2021年)中南计科推免到浙大工院
ES6 uses recursion to implement deep copy
事件管理之一
系统与软件安全研究(四)