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.
 A: The two lines can be parameterized as $y=ax+b$ and $y=ax-b$. The distance between the lines is given by $2|b| / \sqrt{a^2+1}$. You are therefore interested in solving
\begin{align}
\min_{a,b} \quad & \frac{2b}{\sqrt{a^2+1}} \\
\text{s.t.} \quad & ax_i+b \geq y_i \quad i=1,\ldots,n \\
& ax_i-b \leq y_i \quad i=1,\ldots,n
\end{align}
The constraints ensure that the lines $y=ax+b$ and $y=ax-b$ are above and below the datapoints $(y_i,x_i)_{i=1}^n$, respectively (so you know $|b|=b$). The objective function is not convex in $a$ (and the constraints make it difficult to do a nonlinear reparameterization to make it convex). The only thing working in your favor is that the problem only has three variables. BARON will have no problem solving this to optimality. You could do some preprocessing and for each constraint only include the extreme datapoints (for each $x$ only include the highest point for the first constraint, and the lowest point for the second constraint).
A: 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}
A: One thing is to find the minimum band between two parallel lines that encompasses all the points,
as you state at the beginning.
In this case, as you said, only the extremal points will be of importance and all others are not considered.
In this case your algorithm is quite good, considering that the values are anti-symmetric.
and I do not see that there might be a much better one.
Another thing is what you say at the end, that you would like to consider the contribution of all the points
by establishing which linear tendency they have, and how much they depart (or obey) to that.
That is exactly the subject of Linear regression.
Since your data are anti-symmetric, the barycenter (average $x$, average $y$) of the cloud of points will be at the origin
and the linear tendency will reduce to a $y = mx$. The problem then is  to determine $m$  and relevant confidence interval for it and for the intercept
$b$ around $b=0$.
But for a statiscally significant approach you shall first establish some Assumptions, based
on the knowledge of the "physical" system that generates the data.
Prior to fixing the most appropriate assumptions it is not possible to answer to your question.
In the simplest case you will be led to adopt the Least Squares method,
