def add_demonstration(self, demonstration):
interpolate = interp1d(np.linspace(0, 1, len(demonstration)), demonstration, kind='cubic')
stretched_demo = interpolate(self.x)
self.Y = np.vstack((self.Y, stretched_demo))
self.nrTraj = len(self.Y)
self.W = np.dot(np.linalg.inv(np.dot(self.Phi, self.Phi.T)), np.dot(self.Phi, self.Y.T)).T # weights for each trajectory
self.meanW = np.mean(self.W, 0) # mean of weights
w1 = np.array(map(lambda x: x - self.meanW.T, self.W))
self.sigmaW = np.dot(w1.T, w1)/self.nrTraj # covariance of weights
self.sigmaSignal = np.sum(np.sum((np.dot(self.W, self.Phi) - self.Y) ** 2)) / (self.nrTraj * self.nrSamples)
评论列表
文章目录