I have this function,
dn =fp(xn)+an =Asin(2π k xn +φ)+an
an is gaussian distributed random noise with σ2 = 1 and p denotes the particular choice of values of free parameters, p = [A,k,φ]
I need to write two functions:
(1)peval - is supplied a set of parameter values, p and the values of the independent variable, x and returns fp(x) and
(2)residuals -is supplied parameter values, the data set and the array of independent variable values, xn and returns the residuals
This is what I have at the moment, however I am not sure how to input "an", the gaussian distributed random noise. This was my guess..
an = np.random.normal(0,1,100)
def peval(x, p):
#Evaluate the model at the points in x for model parameter values in p.
# return a numpy array containing the set of points y(x)
return p[1]*np.sin(2*(np.pi)*p[2]*x+p[3])+an
def residuals(p, y, x):
# Evaluate the function at for the particular parameter set p,
# find the and return residuals.
# p is the set of parameters
# y is the measured data set
# x is the independent variable.
return (y-peval(x,p))
I have data which looks like this:
0.0003 6.09073051353
0.0006 5.51270817927
0.0009 6.89123564432
0.0012 4.99645189114
0.0015 6.7032515641
0.0018 8.9916107534
Thanks in advance for your help.