Find two parallel lines containing a set of points in 2D

I have a set of discrete points (at most a single $y$ value for a given $x$) and I need to find two parallel lines which contain all of these points and minimize the distance between them. Note that the lines do not have to be parallel with the $x$ axis as in the picture, they can have arbitrary angle. Is there a well known way of solving this?

• I suggest plotting them on a graph and seeing which points belong to each set. Then fit straight lines to each set. Finally compute the distance between the lines. – herb steinberg Mar 17 '18 at 21:48
• There is only a single set of values (e.g., some physical quantity such as temperature sampled by a sensor in discrete time points) so this wouldn't work. Ideally, the process could be completely automated. – pseudomarvin Mar 18 '18 at 10:42
• In conjunction with a regression line, I have heard of 'prediction intervals' for Y-values given new x-values (i.e, x-values not used to find the line.) If the original x-values are relatively widely spread, then the resulting 'prediction bands' are nearly linear. There is a clearly stated purpose of wanting such prediction bands. // By contrast, you do not give a motivation for wanting to find the parallel lines you request. Knowing your purpose might help someone make sense of your Question. Perhaps more to the point might lead to something that better serves your purpose than parallel lines – BruceET Mar 18 '18 at 16:36

Prediction Interval Bands in Simple Linear Regression.

Following from my Comment, here is a plot of $n = 20$ pairs $(x, Y)$ with a regression line of $Y$ on $x,$ showing 95% 'prediction interval bands'. For a new $x_p$ (not used to make the regression line), the corresponding predicted $Y$-value is between the two curves (nearly linear here) just above $x_p$ (with 95% confidence).

Depending on the data, it is possible for a few points to lie outside the bands. If this is undesirable, one can use a higher level of confidence for the predictions interval (perhaps 99% instead of 95%).

If you will look at the plot very closely, you will see that the 'bands' are curves. They are a little closer to each other at $\bar X = 10.5$ than anywhere else.

This is a standard procedure. Formulas for the prediction interval are given in almost any basic statistics text containing a treatment of simple linear regression.

Notes: (1) The data were simulated according to the model $Y_i = 10 + 2x_i + e_i,$ where $e_i \stackrel{indep}{\sim} \mathsf{Norm}(\mu=0,\sigma=2).$ (2) The plot is from Minitab 17 software.

Choose a pair of parallel lines as a second degree degenerate conic

$$( y-cx- a) (y-cx-b) =0$$

in which three constants $(a,b,c)$ can be found out by least square methods... like fitting data to a parabola $$y -(ax^2+bx+c)=0$$