### How to find a curve from points?

Hi there.

I’ve been struggling with this for some days now.

I have a float going from 0. to 1. and I want to scale it to numbers from 40 to 20000, not linear …

It should have the same curve as the Hz-fader in Lexicon’s PCM plug-ins, but I can’t figure out the equation.

I have extracted some points from the curve:

0.000000, 40

0.005556, 50

0.011111, 60

0.016667, 70

0.022222, 80

0.027778, 90

0.033333, 100

(I can get the first number (x) into Max, the other number (y) I have to read off the screen, the vst~ doesn’t output Hz value, just fader value 0. to 1.)

I could keep on extracting points, but then, how do I find the right equation for the curve?

And even better, is there another way?

Sincerely – Jonas Barsten Johnsen

to me your curve doesn’t seem to be curve. It seems to follow be this (linear) equation:

y(x) = x * 1800 +40;

y(0.0055555) = 0.0055555 * 1800 + 40 = 50 (with some differences because of the rounding)

jan

Thanks for your answer Jan.

I should have presented a more representative selection of points:

0.000000, 40

0.033333, 100

0.255556, 500

0.311111, 1000

0.422222, 2000

0.500000, 2700

0.644444, 4000

0.755556, 5000

0.822222, 8000

0.844444, 9000

0.911111, 12000

0.944444, 15000

0.977778, 18000

0.988889, 19000

1.000000, 20000

As you can see now, it’s not linear, but thanks a lot for your suggestion!

Now, as I have these points, are there any way of interpolating between them, send them to a table and use that as a scale?

Keep up the good work!

-jbj

Couple of options.

The mathematical way is to use the method of least squares to get a best fit for a polynomial of whatever order you want (quadratic, cubic, quartic, etc.). Doing that by hand is hard, but Mathematica or other math-oriented software would have a function for that. Somewhere.

Perhaps a more manageable way would be to build a 101-point table (with the indices 0, 1, 2, etc. representing the x values 0.00, 0.01, 0.02, etc.). Store appropriate values in the table, then hook up something like [float]->[* 100]->table.

Finally, even with the extra numbers it looks more like what you’ve got is not really a smooth polynomial but several line segments. For instance, in the range [0.9 .. 1.0] the relation appears to be f(x) = 11000 + 90000*(x-0.9). (Caveat: this is quick eye-balling, my arithmetic might be off somewhere. The principle still holds.) If this is the case, you can use a chain of [split] objects to separate out the x ranges and feed each one into an appropriate [expr].

It’s a small tool that gains the credit for this result:

You can find it here, but unfortunately everything is in German. (http://www.mathe-online.at/nml/materialien/innsbruck/regression/)

Here is the equation with a reasonable prognosis that still has a reasonable length:

x1 are the values on the left of your table.

x2 = -34.3261 + 14273.3843(x1^2)-24946.0709(x1^4)+30918.0835(x1^6)

the graphic show your values from the table in relation with the result of the equation above.

But looking at this diagram indeed it seems that the relation between the values are related in different line-segments.

[attachment=156219,1911]

Jan, that’s awesome!

And Peter, thanks for your contribution :)

I figured I have already used so much time on this, I just started to register many points, for making an [itable].

I have registered the following points, I couldn’t figure out how to use that German program, could you put there values into it and see if you get an equation?

#, Hz (0-1000);

1, 40 0;

2, 50 5;

3, 65 13;

4, 75 19;

5, 85 25;

6, 100 33;

7, 110 38;

8, 125 47;

9, 135 52;

10, 145 58;

11, 160 66;

12, 170 72;

13, 180 77;

14, 195 86;

15, 205 91;

16, 220 100;

17, 230 105;

18, 240 111;

19, 255 119;

20, 265 125;

21, 275 130;

22, 290 138;

23, 300 144;

24, 335 163;

25, 360 177;

26, 370 183;

27, 385 191;

28, 395 197;

29, 405 202;

30, 420 211;

31, 445 224;

32, 465 236;

33, 490 250;

34, 500 255;

35, 575 263;

36, 625 269;

37, 675 275;

38, 750 283;

39, 800 288;

40, 875 297;

41, 925 302;

42, 975 308;

43, 1050 316;

44, 1100 322;

45, 1150 327;

46, 1225 336;

47, 1350 349;

48, 1400 355;

49, 1450 361;

50, 1525 369;

51, 1575 375;

52, 1625 380;

53, 1700 388;

54, 1750 394;

55, 1800 400;

56, 1875 408;

57, 1925 413;

58, 2000 422;

59, 2050 427;

60, 2100 433;

61, 2175 441;

62, 2225 447;

63, 2275 452;

64, 2350 461;

65, 2400 466;

66, 2475 474;

67, 2525 480;

68, 2575 486;

69, 2650 494;

70, 2700 500;

71, 2750 505;

72, 2825 513;

73, 2925 524;

74, 3000 533;

75, 3050 538;

76, 3125 547;

77, 3175 552;

78, 3225 558;

79, 3300 566;

80, 3350 572;

81, 3400 577;

82, 3475 586;

83, 3525 591;

84, 3600 600;

85, 3650 605;

86, 3700 611;

87, 3775 619;

88, 3725 625;

89, 3875 630;

90, 3950 638;

91, 4000 644;

92, 4050 649;

93, 4125 658;

94, 4175 663;

95, 4250 672;

96, 4300 677;

97, 4350 683;

98, 4425 691;

99, 4475 697;

100, 4525 702;

101, 4600 711;

102, 4650 716;

103, 4725 725;

104, 4775 730;

105, 4825 736;

106, 4900 744;

107, 4950 750;

108, 5000 755;

109, 5375 763;

110, 5625 769;

111, 5875 774;

112, 6250 783;

113, 6500 788;

114, 6875 797;

115, 7125 802;

116, 7375 808;

117, 7750 816;

118, 8000 822;

119, 8250 827;

120, 8625 836;

121, 8875 841;

122, 9250 850;

123, 9500 855;

124, 9750 861;

125, 10125 869;

126, 10375 875;

127, 10625 880;

128, 10000 888;

129, 10500 894;

130, 11000 899;

131, 11750 908;

132, 12250 913;

133, 13000 922;

134, 13500 927;

135, 14000 933;

136, 14750 941;

137, 15250 947;

138, 15750 952;

139, 16500 961;

140, 17000 966;

141, 17750 975;

142, 18250 980;

143, 18750 986;

144, 19500 994;

145, 20000 1000;

Sincerely – Jonas

I put these values in MSexcel and it is definitely 4 separate linear segments– best to use a lookup table,

But I did get this formula out of excel:

y = -3E-13x^6 + 1E-09x^5 – 1E-06x^4 + 0.0006x^3 – 0.1299x^2 + 11.203x – 98.171

(polynomial)

and this one

y = 150.16e^(0.005x)

(exponential)

Forums > MaxMSP