Let's say we have the following set of data. 2.33, 2.19, 4.7, 2.69, 2.8, 2.12, 3.01, 2.5, 1.98, 2.34
How do I pick the consistent data from the above sample by eliminating the outliers using JavaScript or any other mathematical method which can be implemented in JavaScript?
I approached the following way of calculating: Average value, Standard deviation, Min value (avg - std dev), Max value (avg + std dev). And considered the data which falls in the range between Min and Max values.
Are there are any better approaches we can follow to obtain accuracy?
I don't think your approach is sufficient, you need to make sure a number is really extremely high or extremely low before deciding whether its an outlier . to achieve this we need to find
Q1
andQ1
to calculate IQR whichQ3 – Q1
.Q3 && Q1
are Quartiles learn more :https://www.statisticshowto.com/what-are-quartiles/IQR
is (interquartile range) learn more : https://www.statisticshowto.com/probability-and-statistics/interquartile-range/will all of this we can check for outliers which are extremely low and high value :
extremely high value is any value that is greater than
Q3 + ( 1.5* IQR )
extremely low value is any value that is lower than
Q1 - ( 1.5* IQR )
so in code