I have two functions, y = f(x)
and y = g(x)
, defined through Array{Float64,2}
-- a sequence of (x, y) points.
I want to find such f'(x) = f(x+dx) + dy
that the distance between the functions on the chart is minimal. For example, here, the distance is already quite small, but it could be even smaller.
In my particular case, the number of points in two arrays is identical, so I tried to minimise the following function (assuming p = [dx, dy]):
loss(p) = sum(abs2, mapslices(x -> x .- p, f .- g, dims=2))
But, apparently, this doesn't work well. Also, it would be nice to be able to work with arrays of different sizes.
So the steps you would need to take is:
dx
that will ensure at least 50% overlap of the curvesf
and g
, using interpolate
(without extrapolate
) from Interpolations.jl using the points you havedx
and the range of curves (so that we integrate without extrapolating, call the ends of this range xmin
and xmax
): quadgk(x -> (f(x)-g(x+dy)+dy)^2, xmin, xmax))
; make it a function of dx
and dy
dx
and dy
(with the constraint on dx
)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With