[Math] Automatic calculation of the intersection of discrete curves

interpolationmathematicaMATLABpolynomials

first of all, let me apologize for a poor math-english translation, I'll try my very best.

I have the following situation:
I have over 16.000 data files which I generated from a biometric verification system.
Those files contain Error Rates for False-negative and False-positive at a specific threshold.
So every data file becomes one Plot to detect an equal error rate (intersection of both rates). Special is in this case, that it may also contain more than one intersection, which is not typical but possible in this case.

I used to use gnuplot before to generate plots, but now the amount is a new level.

I can't watch every plot by myself which would take days. And it's for sure that lots of the files may not contain any intersection in the result.

Therefore I wonder if there is any possibility to calculate for each file the intersection(s) with MATLAB, Mathematica or anything else?

And after having calculated maybe generate a plot (preferred svg format but not important in this step) for that file so that I end up with only "useful" data files and plots with a fixed threshold.

I hope I could explain what my problem is and seeing forward for your ideas.

(Note: Both examples do not belong together, just choosed quickly and randomly from the files)

Data file example:

> #k    NFA NIA NFR NEA FAR FRR 
> #Alpha Vector 0 0 -1 0 0 0 -1 0 -1 0 0 -1 
> 0.4   280.0   280.0   0.0 40.0    100 0
> 0.41  280.0   280.0   0.0 40.0    100 0
> 0.42  280.0   280.0   0.0 40.0    100 0
> 0.43  280.0   280.0   0.0 40.0    100 0
> 0.44  280.0   280.0   0.0 40.0    100 0
> 0.45  280.0   280.0   0.0 40.0    100 0
> 0.46  280.0   280.0   0.0 40.0    100 0
> 
> # k is the threshold, FAR and FRR are 2 curves. k is on x-axis, value of FAR/FRR on y.

Example Plot:
EER with gnuplot

addon information.

I have no experience with matlab and just worked with wolframalpha mathematica during calculus at university. I study computer sciences in Germany, so ideas for scripting and co are also welcome and probably welcomed 🙂

Best Answer

Let $k_1,\ldots, k_N$ be your points on the $x$-axis. Denote the two data sets you want to compare by $f_i := f(k_i)$ and $g_i := g(k_i)$.

First, it can happen that $f_i = g_i$ for some $i$. In this case you already found an intersection.

Second, you can have that $f_i > g_i$ and $f_{i+1} < g_{i+1}$ (or vice versa). This means that there is an intersection in the interval $(k_i, k_{i+1})$. Does this information suffice?

If not: Where exactly the point of intersection is located, depends on how you interpolate the data. The simplest type of interpolation is probably a linear one (as in your plot), in which case you only have to find the intersection of two lines. Can you do that?

Related Question