C # uses the Raida guidelines (3σ Guidelines) to remove exception data (. NET excludes singular values from a set of data)

Source: Internet
Author: User

1, the question of the proposed:

In the production of batteries, the results of a batch of battery measurements are encountered:

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 them, a part of the battery voltage appears too low and too high, does not conform to normal distribution.

Now you need to remove these anomalies from the battery data.

2, the principle of the method:

3σ guidelines, also known as Raida Guidelines, it is assumed that a set of detection data contains only random error, the calculation of the standard deviation, according to a certain probability to determine an interval, that any error exceeding this interval is not a random error but gross error, the data containing this error should be eliminated.
In normal distribution, Σ represents the standard deviation, and μ represents the mean value. X=μ is the symmetrical axis of the image
3σ principle:
The probability of a numerical distribution in (μ-σ,μ+σ) is 0.6827
The probability of a numerical distribution in (μ-2σ,μ+2σ) is 0.9544
The probability of a numerical distribution in (μ-3σ,μ+3σ) is 0.9974
It can be assumed that the value of Y is almost entirely concentrated within the (μ-3σ,μ+3σ) range, and that the likelihood of being out of this range is less than 0.3%.


3, C # specific implementation:

class that defines a voltage-quantity 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 Raida Guidelines (3σ Guidelines) to remove data exceptions

Using System;
Using System.Collections;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;

Namespace Photo.QQAA.Net.Helper
{
<summary>
Eliminate data exceptions using the Raida guidelines (3σ Guidelines)
</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>
Get 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.aw

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.