Answer the question
In order to leave comments, you need to log in
How to write an algorithm for the intersection of the graphs of two functions with a certain level of tolerance?
Hello!
There is a task to program an algorithm for the intersection of the graphs of two functions, with a set "proximity level" for the values of these functions. Roughly speaking, the values of the dP/dT function decrease, and the dH values increase, and at some point they may intersect or pass close to each other at the "proximity level". The task is to find the intersection when some values increase, while others decrease.
What has been done: data from functions are accumulated in arrays over time. A trend detection function has been written - values increase or decrease with the assignment of weight coefficients to values at different points in time.
How to define an intersection? - Is it trivial to compare arrays in a loop, each time counting the difference between the values, and if it satisfies the "closeness level", then consider the intersection to have happened? Or is there some better option? How to overcome noise or random values?
Answer the question
In order to leave comments, you need to log in
Not very clear, but still.
First, functions can intersect even when both of them grow or both fall. Just at different speeds. Did you intentionally dismiss this case?
Secondly, it is not clear, do you have all the measurement points accumulated in advance or do you solve the problem as the points arrive? If the latter, then there is nothing to think about, just measure the distance between the values and make a decision.
By the way, it is not clear whether your data comes at one moment, or at different ones. In the second case, you simply cannot get by with distance - you need to look for possible intersections of functions between measurement points. It's not difficult, but still.
Further. If the data is still available "batch accumulated" - then the easiest way is to use, for example, the same Pandas to build the corresponding DataFrame, in which the intersection point (or intersection points) is located using one line of a logical condition. And the ordering of points, if they are not measured at the same time, is also a standard procedure in Pandas.
If the function is continuous and if given in a table. Then it is possible to interpolate the values on the intervals between points at least along any smooth curve of the polynomial type. And then it turns out that despite the fact that the discrete points were not close enough to each other, and the interpolated segments approached a certain "epsilon".
That is, the condition of the problem most likely lacks details.
The task is to find the intersection when some values increase, while others decrease.We're talking about resonance, right?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question