Paraboloid (3D parabola)

I am trying to set this data x: [0.4,0.165,0.165,0.585,0.585], data y: [.45, .22, .63, .22, .63] and data z: [1, 0.99 , 0.98,0.97,0.96] to the paraboloid. I am using scipy curve_fit tool. Here is my code:

doex = [0.4,0.165,0.165,0.585,0.585]
doey = [.45, .22, .63, .22, .63]
doez = np.array([1, .99, .98,.97,.96])

def paraBolEqn(data,a,b,c,d):
    if b < .16 or b > .58  or c < .22 or c >.63:
        return 1e6
    else:
        return ((data[0,:]-b)**2/(a**2)+(data[1,:]-c)**2/(a**2))

data = np.vstack((doex,doey))
zdata = doez

opt.curve_fit(paraBolEqn,data,zdata)

      

I am trying to center a paraboloid between .16 and .58 (x-axis) and between .22 and .63 (y-axis). I do this by returning a large value if b or c is outside this range.

Unfortunately the fit is gone and my popt values ​​are 1 and my pcov is inf.

Any help would be great.

thank

+3


source to share


1 answer


Rather than forcing high retracements for out-of-range areas, you need to provide a good initial guess. In addition, there is no offset parameter in the mode, and the paraboloid has the wrong sign. Change the model to:

def paraBolEqn(data,a,b,c,d):
    x,y = data
    return -(((x-b)/a)**2+((y-d)/c)**2)+1.0

      

I set the offset to 1.0 because if it were added as a match parameter the system would be underdefined (less or equal number of data points than the match parameters). Call curve_fit

with original guess like this:

popt,pcov=opt.curve_fit(paraBolEqn,np.vstack((doex,doey)),doez,p0=[1.5,0.4,1.5,0.4])

      



This gives:

[ 1.68293045  0.31074135  2.38822062  0.36205424]

      

and a nice data match:

enter image description here

+4


source







All Articles