Functions > Data Analysis > Outliers and NaN > Example: Outlier Removal
  
Example: Outlier Removal
Use the trim function to remove outliers from a data set before processing the data set.
1. Define a dataset that describes the heatflow.
Click to copy this expression
2. Detect outliers using the Grubbs function.
Click to copy this expression
3. Create a vector containing the indices of the outliers.
Click to copy this expression
Click to copy this expression
Click to copy this expression
4. Assign a number to each row of the y data set.
Click to copy this expression
Click to copy this expression
Click to copy this expression
5. Remove the outliers.
Click to copy this expression
The datanew array has fewer rows than the original data sets:
Click to copy this expression
Click to copy this expression
6. Plot the original and the trimmed data sets.
Click to copy this expression
When outliers are expected to skew the results, they can be removed to improve the results. For the heatflow data:
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
The mean remains almost the same with or without outliers in the data, but the standard deviation decreases. This change strongly affects models of the data.