E
E
Evgeny Ivanov2017-12-14 21:47:54
Mathematics
Evgeny Ivanov, 2017-12-14 21:47:54

How to scale two graphs to compare their shape?

There are two graphs (two broken lines). Graphs are built by points in a rectangular coordinate system.
On the x-axis - time, on the y-axis - values. The simplest charts.
https://imgur.com/4XGChIm
The number of points on both graphs is always the same. (A value is measured at each point in time and "plotted" on each graph.)
The values ​​(on the y-axis) of the points can be very different. From very large to very small.
And if we draw these two graphs in the same coordinate system, we will often get straight lines.
You need to scale the graphs in order to evaluate their shape relative to each other.
How to scale two graphs to compare their shape?
So far, the algorithm (maybe wrong) is like this.
For each graph, we calculate a (own) scaling_factor.
To do this, we look for the minimum_value and maximum_value on the chart.
value1=100/ minimum_value value2
=100/ maximum_value scaling_factor
=(value1+value2)/2
Next, when plotting, we multiply the value of the point (along the y-value axis, of course, since we have time and we don’t touch it at all) by the scaling_factor .
point_value_on_y_axis=original_point_value_on_y_axis*scaling_factor.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Grichenko, 2017-12-14
@Kalobok

There are two simple solutions.
For each graph, we look for the maximum absolute value (modulo) and divide all values ​​​​by it. We get a normalized graph, where all values ​​lie in the range from -1 to 1. In this case, it may turn out that the graph does not reach one of the boundaries (-1 or 1) (for example, if all values ​​are positive). At the same time, we retain the proportions of both the distances between any pairs of points, and the distances from each point to zero. For example, if we had y2 = y1*2 and y3 = y1*3, then after normalization we get y2' = y1'*2 and y3' = y1'*3.
If zero is not important, then first we subtract the minimum from all values, and then apply the normalization to the maximum to the result. We get a graph in the range from 0 to 1. In this case, only the proportions of distances between points are preserved, but not between their absolute values. From the example above we get: y1'=0, y2'=0.5 (not y1'*2), y3'=1 (not y1'*3), but at the same time (y3-y1)/(y2-y1) =2 and (y3'-y1')/(y2'-y1')=2.

G
Griboks, 2017-12-14
@Griboks

I have an idea that will blow your mind! What if the graphs don't need to be scaled at all? It's brilliant! We simply build one graph, and on top of it - the second graph in its own coordinate system and display boundaries. As a result, we get two graphs with different shapes superimposed on each other.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question