2020年12月19日星期六

how to do a linear fit where my variable X is vector in 3d?

I need to do a linear fit as follows:

Y=a*X+b

I need to find the values ​​of a and b that fit the experimental data the first thing that occurred to me was to use the polyfit function, but the problem is that in my data, X is a vector with 3 entries,

this is my code:

p_0=np.array([10,10,10])  p_1=np.array([100,10,10])  p_2=np.array([10,100,10])  p_3=np.array([10,10,100])    # Experimental data:  x=np.array([p_0,p_1,p_2,p_3])  y=np.array([35,60,75,65])    a=np.polyfit(x, y,1)  print(a)  

I was expecting a list of lists to print, with the matrix and matrix b ... but I got TypeError("expected 1D vector for x")

Is there any way to do this with numpy or some other library?

https://stackoverflow.com/questions/65376864/how-to-do-a-linear-fit-where-my-variable-x-is-vector-in-3d December 20, 2020 at 12:13PM

没有评论:

发表评论