示例#1
0
    def run(self,input):
        data = input["hvlog"]
        max_ind = numpy.max(input["mlog"])
        data = data[0:max_ind,:]
        data = data.transpose()
        N,M = data.shape
        H = numpy.max(numpy.array([2,numpy.ceil(M/3)]))
        
        T = 50
        maxIter = 20

        A = numpy.eye(H, H)
        C = numpy.eye(M, H)
        Q = numpy.eye(H, H)
        R = numpy.eye(M, M)
        mu0 = numpy.random.randn(1,H)
        Q0 = Q
        model = kalman.lds_model(A,C,Q,R,mu0,Q0)

        z_hat,y_hat,ind = kalman.learn_lds(model,data,T,H,self.step_size,maxIter,self.lookahead_flag)

        output = input
        output["predict"] = y_hat.transpose()
        output["smooth"] = z_hat.transpose()
        output["ind"] = np.array(ind)

        return input
示例#2
0
    def run(self, input):
        data = input["hvlog"]
        max_ind = numpy.max(input["mlog"])
        data = data[0:max_ind, :]
        data = data.transpose()
        N, M = data.shape
        H = numpy.max(numpy.array([2, numpy.ceil(M / 3)]))

        T = 50
        maxIter = 20

        A = numpy.eye(H, H)
        C = numpy.eye(M, H)
        Q = numpy.eye(H, H)
        R = numpy.eye(M, M)
        mu0 = numpy.random.randn(1, H)
        Q0 = Q
        model = kalman.lds_model(A, C, Q, R, mu0, Q0)

        z_hat, y_hat, ind = kalman.learn_lds(model, data, T, H, self.step_size,
                                             maxIter, self.lookahead_flag)

        output = input
        output["predict"] = y_hat.transpose()
        output["smooth"] = z_hat.transpose()
        output["ind"] = np.array(ind)

        return input
示例#3
0
	## Model Initialization
	N,M = y_noise.shape

	# A = np.array([[1,0,1,0],[0,1,0,1],[0,0,1,0],[0,0,0,1]])
	# C = np.array([[1,0,0,0],[0,1,0,0]])
	# Q = 0.1*np.eye(H)
	# R = 0.1*np.eye(M)
	# mu0 = np.array([10,10,1,0])

	A = 0.1*np.eye(H, H) + 0*np.random.randn(H, H)
	C = 0.1*np.eye(M, H) + 0*np.random.randn(M, H)
	Q = np.eye(H, H)
	R = np.eye(M, M)
	mu0 = np.random.randn(1,H)

	Q0 = Q
	model = kalman.lds_model(A,C,Q,R,mu0,Q0)

	z_hat,y_hat = kalman.learn_lds(model,y_noise,T,H,step_size,maxIter)

	plt.figure(1)
	plt.scatter(y_noise[:,0],y_noise[:,1])
	plt.scatter(y_hat[:,0],y_hat[:,1],c='r')
	plt.title('Predicted vs Actual Location')

	plt.figure(2)
	plt.plot(np.sqrt(np.sum((y_hat-y_noise)**2,1)))
	plt.title('Location Error')
	plt.show()
示例#4
0
    ## Model Initialization
    N, M = y_noise.shape

    # A = np.array([[1,0,1,0],[0,1,0,1],[0,0,1,0],[0,0,0,1]])
    # C = np.array([[1,0,0,0],[0,1,0,0]])
    # Q = 0.1*np.eye(H)
    # R = 0.1*np.eye(M)
    # mu0 = np.array([10,10,1,0])

    A = 0.1 * np.eye(H, H) + 0 * np.random.randn(H, H)
    C = 0.1 * np.eye(M, H) + 0 * np.random.randn(M, H)
    Q = np.eye(H, H)
    R = np.eye(M, M)
    mu0 = np.random.randn(1, H)

    Q0 = Q
    model = kalman.lds_model(A, C, Q, R, mu0, Q0)

    z_hat, y_hat = kalman.learn_lds(model, y_noise, T, H, step_size, maxIter)

    plt.figure(1)
    plt.scatter(y_noise[:, 0], y_noise[:, 1])
    plt.scatter(y_hat[:, 0], y_hat[:, 1], c='r')
    plt.title('Predicted vs Actual Location')

    plt.figure(2)
    plt.plot(np.sqrt(np.sum((y_hat - y_noise)**2, 1)))
    plt.title('Location Error')
    plt.show()