2
$\begingroup$

enter image description here

I want to raise the lower graph toward the upper graph to make the points of the lower graph as close as possible to those of the upper graph, in other words, to make the graphs "match" as closely as possible.

Any idea of how to do this in mathematical way? I tried taking the means of both graph then translating the lower graph by the percentage difference of the means, but this doesn't give me what I want.

$\endgroup$
2
  • 1
    $\begingroup$ I come up with an idea similar to Riemann integral, but it's only an idea. Let's call $f$ and $g$ the functions whose graps are the blue one and the red one, respectively. Divide the domain in $n$ intervals with the same lenght. In each one of those intervals, change the value of $f$ on all the interval to be the mean of the values of $g$ in the same interval. With this, $f$ will become a piecewise function, where in each interval is as closely as possible to the graph of $g$. Finally, let $n$ tend to $\infty$. $\endgroup$ Commented Mar 2, 2023 at 16:01
  • 1
    $\begingroup$ I think this question is a bit underspecified. When you say translate, do you mean shift by a constant value? In this case, just add the minimum of the difference of the functions to the lower one. If that's not what you mean, then note that you could trivially just let the blue function be the red function, and they would match exactly, so you must want to preserve some features of the original function, what are those features? $\endgroup$ Commented Mar 2, 2023 at 16:15

1 Answer 1

2
$\begingroup$

I believe you want to vertically translate the blue curve such that the signed area between the two curves is zero. This is equivalent to translating the blue curve upwards by the average value of the difference between the two curves. To do this:

  • if the red and blue curves respectively represent $y=f(x)$ and $y=g(x)$ and the horizontal interval of interest is $[a,b],$ then translate the blue curve upwards by $$\frac1{b-a}\int_a^b f(x)-g(x)\,\mathrm dx.\tag1$$

For example,

enter image description here

on the interval $[2,4],$ translating this blue curve upwards by $0.5$ units (obtained from evaluation $(1)$) gives the green curve, which is its closest "match" to this red curve.


Addendum

Thank you so much, @ryang! That worked perfectly. How would I change it from "units shifted" to percentage shifted?

  • The resulting average percentage increase of $g(x)$ is $$\frac1{(b-a)^2}\int_a^bf(x)-g(x)\,\mathrm dx\int_a^b\frac1{|g(x)|}\,\mathrm dx.$$

In the above example, this equals $59.3\%.$

$\endgroup$
6
  • $\begingroup$ Thank you so much, @ryang! That worked perfectly. How would I change it from "units shifted" to percentage shifted? So instead of saying 0.5 units, I would give a percent instead? After taking the integral of both functions, I found the percentage difference from that and divided by b-a, but after shifting the graph by the percent, it didn't seem to match up. $\endgroup$
    – anon1212
    Commented Mar 4, 2023 at 19:08
  • $\begingroup$ You added 0.5 units to shift the graph up, which works just fine. But I am asking, is there a way to shift the graph of up by a percentage instead? Sorry - I am not very good at explaining what I mean.... $\endgroup$
    – anon1212
    Commented Mar 4, 2023 at 19:45
  • $\begingroup$ Lets use your example above. In the second function you listed, let imagine we plot all of its points. Now we want to translate it 0.5 units. Is there a fixed % number that we could multiply to each y-value of the points where it would shift graph up 0.5 units? $\endgroup$
    – anon1212
    Commented Mar 4, 2023 at 22:00
  • $\begingroup$ Thank you Ryang, however, the relative change is giving me different percentages for each different point. I need a fixed percentage to raise the graph by.... What am I doing wrong here? $\endgroup$
    – anon1212
    Commented Mar 4, 2023 at 22:27
  • $\begingroup$ I'll need to test those other formulas in that answer in a bit.. Thank you for your help! $\endgroup$
    – anon1212
    Commented Mar 4, 2023 at 22:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .