1

I want to use power law to fit on my data points because I have to calculate the value of v. But the error on my fitting parameters is too large, although curve seems to pass all data points. How to reduce is error?enter image description here

`import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import math
import scipy 
from scipy import optimize

x_data= np.array([30, 45, 60, 75])
y_data= np.array([0.42597867, 0.26249343, 0.19167837, 0.08116507])

fig = plt.figure()
ax= fig.add_subplot(111)

def ff(L,v,c):
    return (L**(-1/v)+c)


ax2.scatter(x_data, y_data, marker='s',s=4**2,)


pfit,pcov = optimize.curve_fit(ff,x_data,y_data)
print("pfit: ",pfit)
print("pcov: ",pcov.shape)
#print(pcov)
perr = np.sqrt(np.diag(pcov))
x=np.linspace(20,85,1000)

ax2.plot(x,ff(x,*pfit),color='red')`
huda_
  • 57
  • 1
  • 7

0 Answers0