I want to find a specific algorithm to choose either 2 or 3 out of 3 given values. Like if I have a set of values 10,11,12 all three are close enough so I will calculate the mean of the value and return the mean. For another example if the values are 6,10,12. then I will choose 10 and 12 and calculate the mean and return the mean. Though these value can not necessarily be of of this range , they can go in thousands as well . But there will only be three number of values . I hope I am clear enough. I am not sure how to proceed over this and I need some help . Thank you
Use statistical analysis.
You're looking to reject a value that is outside some "normal" range for the 3. There are several ways to interpret what the normal range is and what outliers are, so you'll have to pick one that meets your needs, in particular with such a small sample size.
From the wikipedia article on outliers and their detection:
There is no rigid mathematical definition of what constitutes an outlier; determining whether or not an observation is an outlier is ultimately a subjective exercise. There are various methods of outlier detection...