Programmatically determine the convergence and divergence of two lines

Given two datasets at the same interval, I can plot them on the same XY plot and visually check if the two lines converge, diverge, or remain “disconnected” or “disconnected” during the interval. The sketches below give some idea of ​​what I mean by each scenario. The first is convergence, the second is divergence, and the last is trip. As you can see, the data is non-linear.

convergedivergedetached

Given a large set of such dataset pairs (the intervals are always the same), what would be a reliable and efficient way to programmatically decide which scenario the datapair belongs to?

A possible (but likely buggy) method is as follows: 1. Divide the interval in half; 2. compare the number of intersections between two lines in each half; 3. if the number of crossings in the first half is much less than in the second half, then the two lines converge; on the contrary, the two lines diverge; if there is no intersection in the first and second halves, then the two lines remain disconnected.

Any suggestion for a better alternative?

+3


source to share


2 answers


Just a few suggestions based on previous comments:

A general method would be to do some regression on the curve X [i], Y [i], where 0 <= i <= n (for some well-chosen n - see below), X [i] = X_min + (i / n) * (X_max - X_min) (where your X-interval was X [max], X [min]) and Y [i] is the difference btw value, blue and green curve for abscisse X = X [i ].

If your data is noisy, you can clean up this noise a bit first by specifying Y [i] as the average of the abscissas in the range X [i] -delta, X [i] + delta.

Then you want to tweak the X [i], Y [i] curve. Here's a really important step. I would like to point out that it is recommended to set a straight line as this seems to be the exact opposite of convergence.



You can try the exponential function A * Exp [lambda * x] and then you say that for lambda <lambda_1 converges, lambda_1 <lambda <lambda_2 curves remain off and lambda curve> lambda_2 diverges. In a perfect word with no noise and with infinite N, you would just take lambda_1 = lambda_2 = 0, but here you will need to sag a bit, I would think at least lambda_1 <= -1 / n and lambda_2> = 1 / n. The best solution here is to play around with your algorithm a bit and set lambda_1, lambda_2 as it works best.

The nice thing with the previous fit is that it follows the linear approach for the curve X [i], log (| Y [i] |), so you can compute it easily.

However, this exponential matching is only one possibility. You can also try something like a polynomial like y = a * x ^ b. However, the fitting may be more active.

+2


source


Subtract values ​​from one of the strings from one of the other. Now shape slices of equal size along the X axis (maybe 3-5 of them) and add all the values ​​in each slice. If the slices tend to get smaller, they converge. If the slices tend to get bigger, they diverge. You can also check the intersections first to distinguish between conversion and breakaway.



+1


source







All Articles