Perfect.
Chuck Swiger wrote:
Just thought while going to sleep last night, piecemeal linear or
collecting several data
points and doing linear interpolation betwen them should work fine.
For (x1, y1) (x2, y2) (x3, y3) where x1 < x2 < x3 I can get slope m1
and y-intercept b1
between x1-x2, and slope m2 and y-intercept b2 between x2-x3. Then if
freq is between
x1-x2 use m1 and b1, if between x2-x3 use m2 and b2, etc.
The operator just has to make sure data points are close enough together.
import scipy.linalg.basic
xdata = [5.357, 5.457, 5.797, 5.936, 6.161, 6.697, 6.731, 6.775, 8.442,
9.769, 9.861]
ydata = [0.376, 0.489, 0.874, 1.049, 1.327, 2.054, 2.077, 2.138, 4.744,
7.068, 7.104]
matrix = []
for x in xdata:
matrix.append([1.0, x, x*x]) # for y = a + bx + cx^2
coeffs = scipy.linalg.basic.lstsq(matrix, ydata)[0]
print "scipy.linalg.basic.lstsq curve fitting example"
print "fitting data to quadratic equation y = a + bx + cx^2"
print "yields: x data y
data calc value error"
for i in range(len(xdata)):
ycalc = coeffs[0] + coeffs[1] * xdata[i] + coeffs[2] *
xdata[i] * xdata[i]
error = ycalc - ydata[i]
print
" %
.3f % .3f %
.3f % .3f" % (xdata[i], ydata[i], ycalc, error)
print
------------------------------------------------------------------------
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
--
AMSAT VP Engineering. Member: ARRL, AMSAT-DL, TAPR, Packrats,
NJQRP/AMQRP, QRP ARCI, QCWA, FRC. ARRL SDR Wrk Grp Chairman
Laziness is the number one inspiration for ingenuity. Guilty as charged!
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio