Minimize distance between curves
2 vues (au cours des 30 derniers jours)
I have a dataset with values of multiple curves. An example plot is shown below.
I want to shift the curves (up/down) so that all curves overlap. This would mean the data points in each curve is scaled up/down by a factor.
I am not sure how to frame this as a mathematical problem (to minimize the vertical distance between each pair of curves) and determine the scaling factor
for each curve. I tried to start by computing the pair-wise distance matrix using norm fucntion
but I am not sure what to do next and which MATLAB function can be used for set up this problem.
Suggestions will be really appreciated.
John D'Errico le 1 Juil 2022
Modifié(e) : John D'Errico le 1 Juil 2022
This is a classic calibration problem of sorts. Lacking any data, I cannot really help you as much as I might want to. But I can at least generate some fake data. If you want to provide some data, feel free to do so, attached to a comment.
First, you need to decide if the problem is PURELY that of a scaling problem, or if you wanted to add some constant also to each curve to translate it up and down.
Next, you will need to choose some target curve. Which one will be the aim, the one that all others will be adjusted to look like?
For example, here is some fake data I just made up:
x = 0:10; nx = length(x);
ytar = 2*x - x.^2/10 + randn(size(x))/8;
So a little noise in it. But not too bad.
Now I'll generate some other random curves that we will need to adjust. 5 curves should be about right.
ny = 5;
ydata = (randn(ny,1)+2)*ytar + randn(ny,nx)/2;
Does that seem at least similar to what you have?
Now, each of those curves need to be adjusted by a pure scale factor to look like the ytar curve. We can do that using some simple linear algebra. Backslash is your friend here.
calconstants = ytar'\ydata'
These are the scale factors we need to re-scale the data, to make all of the curves look like the ytar curve. Il plot them all on top of each other now, after re-scaling.
ycal = ydata./calconstants'
As you can see, all of the red curves now look as much as possible like the blue curve.
In the event that you also needed a constant additive translation up or down, that is also possible, but I don't have your data to know if that would be useful.