t = np.linspace(-0.1, 0.1, 300) t_pred = np.linspace(-0.12, 0.12, 1000) flux = Transit_aRs(lc_pars, t) + 0.0005 * np.sin(2 * np.pi * 40 * t) + np.random.normal( 0, hp[-1], t.size) #guess parameter values and guess uncertainties guess_pars = hp + gp err_pars = np.array([0.0004, 0.1, 0.0001] + [0.00001, 0, 0.2, 0.0003, 0.02, 0.0, 0.0, 0.001, 0.]) #construct the GP MyGP = Infer.GP(flux, np.matrix([ t, ]).T, p=guess_pars, mf=Transit_aRs, mf_args=t, n_hp=3) #MyGP.logPrior = lambda p: np.log(norm_dist.pdf(p[6],.10,0.02)).sum() #make plot of the function pylab.figure(1) pylab.plot(MyGP.mf_args, MyGP.t, 'k.') pylab.plot(MyGP.mf_args, MyGP.MeanFunction(), 'g-') #get optimised parameters #MyGP.pars = Infer.Optimise(MyGP.logPosterior,guess_pars[:],(),fixed=(np.array(err_pars) == 0)*1) #pylab.plot(MyGP.mf_args,MyGP.MeanFunction(),'r-') MyGP.Optimise(fp=(np.array(err_pars) == 0) * 1)
lc_pars = [.0,2.5,11.,.1,0.6,0.2,0.3,1.,0.] hp = [0.0003,0.01,0.0003] #create the data set (ie training data) t = np.linspace(-0.1,0.1,300) t_pred = np.linspace(-0.12,0.12,1000) flux = Transit_aRs(lc_pars,t) + np.random.normal(0,hp[-1],t.size) #guess parameter values and guess uncertainties guess_pars = hp + lc_pars err_pars = np.array([0.00001,1,0.0001] + [0.00001,0,0.2,0.0003,0.02,0.0,0.0,0.001,0.0001]) X = np.matrix([t,]).T X_pred = np.matrix([t_pred,]).T MyGP = Infer.GP(flux,X,p=guess_pars,mf=Transit_aRs,mf_args=t,n_hp=3) #make plot of the function pylab.figure(1) pylab.plot(MyGP.mf_args,MyGP.t,'k.') pylab.plot(MyGP.mf_args,MyGP.mf(lc_pars,MyGP.mf_args),'g-') start = time.time() for i in range(100): gp = np.array(guess_pars) + np.random.normal(0,1) * err_pars # print gp lik = MyGP.logPosterior(gp) # print lik print " t = %.2f s" % (time.time()-start) MyGP.pars = Infer.Optimise(MyGP.logPosterior,guess_pars[:],(),fixed=(np.array(err_pars) == 0)*1)