0

I am doing some least square fitting things. and it's two dimensional which means (x1i,x2i)-->(yi).So far i checked a lot online documents which are designed for 1 dimensional (xi)->(yi).

1 So anyone knows how to solve multi-dimensional least fitting using any standard packages? such as leastsq?

2 And the other question is how to return multiple functions!!! The reason I want to do this is just dealing with the yi-f(xi) part. If i have limited dataset, i can do something shown below. But How could i do it with a lot data? I am not able to write every individual function by hand...

def F(x):
return (weight(x[0],x[1],x[2],weeknumbers[0])-13,
        weight(x[0],x[1],x[2],weeknumbers[1])-21,
        weight(x[0],x[1],x[2],weeknumbers[2])-28,
        weight(x[0],x[1],x[2],weeknumbers[3])-36,
        weight(x[0],x[1],x[2],weeknumbers[4])-36,
        weight(x[0],x[1],x[2],weeknumbers[5])-39,
        weight(x[0],x[1],x[2],weeknumbers[6])-39,
        weight(x[0],x[1],x[2],weeknumbers[7])-41,
        weight(x[0],x[1],x[2],weeknumbers[8])-42)
baozi
  • 679
  • 10
  • 30

1 Answers1

0

For input you can declare multiple arguments "def F(x,y,z):" for return you can use tuples (How do you return multiple values in Python?) or just return a table: "return [a,b,c]"

Community
  • 1
  • 1
hegelsturm
  • 71
  • 1
  • 6