How do you remove some serious deviations from the average in a pile of numbers to make the average more accurate?

find the average of a set of numbers, assuming that most of the numbers are between 30 and 50, and how many numbers are invalid numbers such as 10p88 and 90, how about Filter?
just give the algorithm idea or reference.

< H2 > add: what I want is a way to filter out invalid numbers. The numbers in the title are just my examples and may be valid in the range of 50-60. Is there a screening method modified according to the law of the center of large numbers? < / H2 > < H2 > update: this kind of problem is called outlier. You can refer to the adopted answer or search for the solution of outlier. < / H2 >
Nov.15,2021

refer to this https://blog.csdn.net/yuxeaot., I wonder if it is correct

.
function filterOutliers(someArray) {  

    // Copy the values, rather than operating on references to existing values
    var values = someArray.concat();

    // Then sort
    values.sort( function(a, b) {
            return a - b;
         });

    /* Then find a generous IQR. This is generous because if (values.length / 4) 
     * is not an int, then really you should average the two elements on either 
     * side to find q1.
     */     
    var q1 = values[Math.floor((values.length / 4))];
    // Likewise for q3. 
    var q3 = values[Math.ceil((values.length * (3 / 4)))];
    var iqr = q3 - q1;

    // Then find min and max values
    var maxValue = q3 + iqr*1.5;
    var minValue = q1 - iqr*1.5;

    // Then filter anything beyond or beneath these values.
    var filteredValues = values.filter(function(x) {
        return (x <= maxValue) && (x >= minValue);
    });

    // Then return
    return filteredValues;
}

traverses, recording the sum and the number of significant numbers

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bd6a-2c2a8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bd6a-2c2a8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?