Hello. Ive got two functions here. Somehow the program does not go in
to the second function wehn i call it. The bestfit function. Could
some1 help me identify the problem. Heres the code:
import Gnuplot
def bestfit(uinput) :
if not isinstance(uinp ut, list):
return False
else:
sigmax = sigmay = sigmaxy = sigmaxwhl = sigmaxsq = 0
for i in range(len(uinpu t)):
n = len(uinput)
sigmax = uinput[i][0] + sigmax
sigmay = uinput[i][1] + sigmay
sigmaxy = uinput[i][0] * uinput [i][1] + sigmaxy
sigmaxwhl = sigmax * sigmax
sigmaxsq = uinput[i][0] * uinput[i][0] + sigmaxsq
sigmaxsigmay = sigmax * sigmay
num = sigmaxsigmay - (n * sigmaxy)
den = sigmaxwhl - (n* sigmaxsq)
num2 = (sigmax * sigmaxy) - (sigmay * sigmaxsq)
gradient = num / den
intercept = num2 / den
m = gradient
c = intercept
p = Gnuplot.Gnuplot ()
p.plot ('%f * x+%f'%(m,c))
return p
def plot(original, expected, actual):
if not isinstance(orig inal, list):
return False
else:
gp = Gnuplot.Gnuplot ()
gp('set data style lines')
# Make the plot items
plot1 = Gnuplot.PlotIte ms.Data(origina l, title="Original ")
plot2 = Gnuplot.PlotIte ms.Data(expecte d, title="Expected ")
plot3 = Gnuplot.PlotIte ms.Data(actual, title="Acutal")
gp.plot(plot1, plot2, plot3)
bestfit(expecte d)
bestfit(actual)
return gp
-------
import Combine #The name of my file...
gp = Combine.plot( [(2,3), (4,8), (5,9), (6,2)], [(1,7), (3,3), (4,5),
(5,6)], [(1,3), (3,10), (4,8), (7,9) ] )
raw_input()
to the second function wehn i call it. The bestfit function. Could
some1 help me identify the problem. Heres the code:
import Gnuplot
def bestfit(uinput) :
if not isinstance(uinp ut, list):
return False
else:
sigmax = sigmay = sigmaxy = sigmaxwhl = sigmaxsq = 0
for i in range(len(uinpu t)):
n = len(uinput)
sigmax = uinput[i][0] + sigmax
sigmay = uinput[i][1] + sigmay
sigmaxy = uinput[i][0] * uinput [i][1] + sigmaxy
sigmaxwhl = sigmax * sigmax
sigmaxsq = uinput[i][0] * uinput[i][0] + sigmaxsq
sigmaxsigmay = sigmax * sigmay
num = sigmaxsigmay - (n * sigmaxy)
den = sigmaxwhl - (n* sigmaxsq)
num2 = (sigmax * sigmaxy) - (sigmay * sigmaxsq)
gradient = num / den
intercept = num2 / den
m = gradient
c = intercept
p = Gnuplot.Gnuplot ()
p.plot ('%f * x+%f'%(m,c))
return p
def plot(original, expected, actual):
if not isinstance(orig inal, list):
return False
else:
gp = Gnuplot.Gnuplot ()
gp('set data style lines')
# Make the plot items
plot1 = Gnuplot.PlotIte ms.Data(origina l, title="Original ")
plot2 = Gnuplot.PlotIte ms.Data(expecte d, title="Expected ")
plot3 = Gnuplot.PlotIte ms.Data(actual, title="Acutal")
gp.plot(plot1, plot2, plot3)
bestfit(expecte d)
bestfit(actual)
return gp
-------
import Combine #The name of my file...
gp = Combine.plot( [(2,3), (4,8), (5,9), (6,2)], [(1,7), (3,3), (4,5),
(5,6)], [(1,3), (3,10), (4,8), (7,9) ] )
raw_input()
Comment