Skip to main content
3 of 4
deleted 101 characters in body
yode
  • 27.2k
  • 4
  • 66
  • 174

How to drop some points that don't in a line

I have some data like:

data = Uncompress[FromCharacterCode[
  Flatten[ImageData[Import["https://i.sstatic.net/1E5DB.png"], "Byte"]]]]

If we use FindAnomalies then we can find a outlier:

abponts = FindAnomalies[data]

{{357., 436.5}}

But I don't want to use FindAnomalies to do this, because it too slow and I don't know how to use other languages to imitate such neural network function.

The current idea is to fit a line for all points, then calculate the distance from the point to the fitting line. But it seems this distance is hard to distinguish that outlier. The red line is the fitting line in follow:

Show[ListLinePlot[SortBy[data, Last], 
  PlotRange -> {{300, 1000}, {0, 2000}}], 
 Plot[Evaluate[Fit[data, {1, x}, x]], {x, 300, 1000}, 
  PlotStyle -> Red], ListPlot[data, PlotStyle -> Blue]]

enter image description here

Could anybody can give me some advice?

yode
  • 27.2k
  • 4
  • 66
  • 174