Adjusting y-values on a log-log scale

KTMc

New member
Joined
Jun 6, 2022
Messages
4
I have two sets of data (blue and grey) and they are plotted on a log-log scale. I want to change the y-values of the second (grey) dataset so the slope of the lines is the same (red). I solved for y using the slope and y-intercept of the other (blue) line but when I plot the new x,y series (red) the slope and y-intercept are different.ForMathforum.PNG


Single Point AreaSingle Point VolumeAdjusted Single Point VolumeGrid AreaGrid Volume
m2m3m3m2m3
7.77607​
1.244171​
2.24939​
360.2472​
3172.015​
5414.629​
9919.601​
5713.587​
622.4648​
9754.563​
2386.268​
1749.93​
2518.545​
13.27551​
264.4758​
11082.13​
4506.733​
11693.03​
6.878544​
46.29824​
44.39463​
9.470855​
47.77485​
23.25118​
182.1844​
11.8903​
2.457329​
13.48148​
1.666301​
0.466564​
2.694754​
6.705258​
0.894034​
8.011056​
3.415775​
0.318806​
4.540519​
11.76087​
1.881739​
13.34492​
0.607034​
0.024281​
1.577185​
2.882097​
0.438079​
3.977468​
1.16396​
0.093117​
2.164764​
0.235619​
0.022619​
1.185328​
0.213314​
0.015643​
1.161795​
0.248186​
0.024157​
1.198586​
0.71432​
0.061908​
1.690376​
27.29997​
7.461992​
29.7393​
2.565896​
0.307907​
3.643863​
1.364708​
0.181961​
2.376561​
12.60996​
1.849461​
14.24075​
 
Can you show us the formulae you used to adjust your data?
 
y=(x*1.0554)+0.93674

The x used is the same x that formed the grey line and this equation was from the linear fit assigned to the blue line AFTER I changed the plot to log-log scale. There is a different linear fit assigned when the scales are still linear. I want the slopes to match after I change to the log-log scale.

The log base of the blue/grid dataset is all close to 1 when I calculated it.


 
y=(x*1.0554)+0.93674

The x used is the same x that formed the grey line and this equation was from the linear fit assigned to the blue line AFTER I changed the plot to log-log scale. There is a different linear fit assigned when the scales are still linear. I want the slopes to match after I change to the log-log scale.

The log base of the blue/grid dataset is all close to 1 when I calculated it.


What I mean can you show the math you used to get your results. I cannot figure out how you got your red line without seeing all the mathematical details of the derivation.

I tried your data logarithms and got a pretty decent match using standard linear regression in Python/Numpy:
regr1.png
 
Thanks! I'm still learning python. I've tried plotting it in excel, origin, and matlab. The new data set is separate in origin and matlab. In excel, they match, but when I add the trend lines, it looks exponential. So I just used my x cell as the value in the "Single Point Area" column to calculate the " Adjusted Single Point Volume" column. So the " Adjusted Single Point Volum" column reads =("Single Point Area cell" *1.0554)+0.93674, then I just dragged the equation down the column.
 
If it is of any value, below is the script I used. It might not be a good sample for learning Python/Numpy; in particular the data initialization looks weird because I used cut & paste from your post, which required some transformation.


import numpy as np
import matplotlib.pyplot as plt

a1 = np.array ([ 7.77607, 1.244171, 2.24939, 360.2472, 3172.015, 5414.629, 9919.601,
5713.587, 622.4648, 9754.563, 2386.268, 1749.93, 2518.545, 13.27551,
264.4758, 11082.13, 4506.733, 11693.03, 6.878544, 46.29824, 44.39463,
9.470855, 47.77485, 23.25118, 182.1844]);

a2 = np.array ([ 11.8903, 2.457329, 13.48148, 1.666301, 0.466564, 2.694754, 6.705258,
0.894034, 8.011056, 3.415775, 0.318806, 4.540519, 11.76087, 1.881739,
13.34492, 0.607034, 0.024281, 1.577185, 2.882097, 0.438079, 3.977468,
1.16396, 0.093117, 2.164764, 0.235619, 0.022619, 1.185328, 0.213314,
0.015643, 1.161795, 0.248186, 0.024157, 1.198586, 0.71432,
0.061908, 1.690376, 27.29997, 7.461992, 29.7393, 2.565896, 0.307907,
3.643863, 1.364708, 0.181961, 2.376561, 12.60996, 1.849461, 14.24075]);

a1a = a1.reshape (-1,5).T;
a2a = a2.reshape (-1,3).T;

x = np.hstack ((a1a[0,:], a2a[0,:]));
y1 = np.hstack ((a1a[1,:], a2a[1,:]));
y2 = np.hstack ((a1a[2,:], a2a[2,:]));
xG = a1a[3,:];
yG = a1a[4,:];
x = np.log (x);
y1 = np.log (y1);
y2 = np.log (y2);
xG = np.log (xG);
yG = np.log (yG);

plt.plot ( (x), (y1), '.', color='gray', markersize=10);
plt.plot ( (xG), (yG), '.', color='blue', markersize=10);

def regr (x,y):
A = np.vstack ((x, np.full (x.shape, 1))).T;
AA1 = np.linalg.inv (np.matmul (A.T,A));
r1 = np.matmul (np.matmul (AA1, A.T), y.T);
return r1;

a,b = regr (x, y1);
print (a,b);
x0 = np.min (x);
x1 = np.max (x);
plt.plot ([x0,x1], [a*x0+b, a*x1+b], '.-', color='gray')

a2,b2 = regr (xG, yG);
print (a2,b2);
x0 = np.min (xG);
x1 = np.max (xG);
plt.plot ([x0,x1], [a2*x0+b2, a2*x1+b2], '.-', color='blue')

u = a2/a;
v = b2 - u*b;
y3 = u*y1 + v;
plt.plot ( (x), (y3), '.', color='green', markersize=10);
plt.grid ();
plt.show ();
 
Thanks for this!

I'm still trying to figure out what you did. So you took the log of each and then plotted it, but I'm a little confused about the green and blue lines, "
a2,b2 = regr (xG, yG);
print (a2,b2);
x0 = np.min (xG);
x1 = np.max (xG);
plt.plot ([x0,x1], [a2*x0+b2, a2*x1+b2], '.-', color='blue')

u = a2/a;
v = b2 - u*b;
y3 = u*y1 + v;
plt.plot ( (x), (y3), '.', color='green', markersize=10);
plt.grid ();
plt.show ();"

I'm not sure where the a and bs come from.

For my final result, I would like to keep the values in m3 and m2, so I won't have negative volume calculations. I'm trying to calculate a new volume based on the area volume relationship of the smaller dataset.

Thanks again!!
 
Top