How to find an optimum distance between 2 lines? In the below graph there are 4 series of points. These points are symmetric respect to $OX$ axis and also with the $OY$ axis.

I have to create/to draw two parallel lines in order to include all these points in between. Then, the distance between these two lines will be the error which I need to compute.
My idea:

*

*Find out the highest point for each position on $OX$ axis.


*Find out the highest point from step 1.


*Compute the slope from the point found at step 2 to the points from step 1.


*Find out the minimum slope


*We have 2 points: $A1(x_{1}, y_{1})$ and $B1(x_{2}, y_{2})$ marked with blue circle on my picture. Having these 2 points and knowing that the points are symmetric we can conclude also that the second line, parallel with the first one will pass through $A2(-x_{1}, -y_{1})$ and $B2(-x_{2},-y_{2})$ marked with red.


*Now, it can be computed the distance between these 2 lines
BUT there is also another idea better than mine, I suppose.
I compute this error using only 4 points, but every point on the graph has its own weight and importance.
So, I am thinking somehow to take into consideration all these points. Maybe it is an optimization/minimization problem.

You have two decision variables: $a$ represents the common slope, and $b$ represents the $y$-intercept of the upper line.
Instead of minimizing the distance between the lines $y=ax+b$ and $y=ax-b$, you can minimize the sum of weighted distances (weight $w_i$) from each point $i$ to the closer line.  The problem is to minimize
$$\sum_i w_i \left(\min(a x_i + b - y_i, y_i - (a x_i - b))\right)^2$$
subject to linear constraints
\begin{align}
a x_i + b &\ge y_i &\text{for all $i$}\\
a x_i - b &\le y_i &\text{for all $i$}
\end{align}
