def plot_dog_track(xs, dog, measurement_var, process_var):
    N = len(xs)
    bp.plot_track(dog)
    bp.plot_measurements(xs, label='Sensor')
    bp.set_labels('variance = {}, process variance = {}'.format(
              measurement_var, process_var), 'time', 'pos')
    plt.ylim([0, N])
    bp.show_legend()
    plt.show()
示例#2
0
def plot_dog_track(xs, dog, measurement_var, process_var):
    N = len(xs)
    bp.plot_track(dog)
    bp.plot_measurements(xs, label='Sensor')
    bp.set_labels(
        'variance = {}, process variance = {}'.format(measurement_var,
                                                      process_var), 'time',
        'pos')
    plt.ylim([0, N])
    bp.show_legend()
    plt.show()
def plot_gh_results(weights, estimates, predictions, time_step=0):

    n = len(weights)
    if time_step > 0:
        rng = range(1, n + 1)
    else:
        rng = range(n, n + 1)

    plt.xlim([-1, n + 1])
    plt.ylim([156.0, 173])
    act, = book_plots.plot_track([0, n], [160, 160 + n], c='k')
    plt.gcf().canvas.draw()

    for i in rng:
        xs = list(range(i + 1))

        #plt.cla()

        pred, = book_plots.plot_track(xs[1:],
                                      predictions[:i],
                                      c='r',
                                      marker='v')
        plt.xlim([-1, n + 1])
        plt.ylim([156.0, 173])
        plt.gcf().canvas.draw()
        time.sleep(time_step)

        scale, = book_plots.plot_measurements(xs[1:],
                                              weights[:i],
                                              color='k',
                                              lines=False)
        plt.xlim([-1, n + 1])
        plt.ylim([156.0, 173])
        plt.gcf().canvas.draw()
        time.sleep(time_step)

        book_plots.plot_filter(xs[:i + 1], estimates[:i + 1], marker='o')
        plt.xlim([-1, n + 1])
        plt.ylim([156.0, 173])
        plt.gcf().canvas.draw()
        time.sleep(time_step)

        plt.legend([act, scale, pred],
                   ['Actual Weight', 'Measurement', 'Predictions'],
                   loc=4)
    book_plots.set_labels(x='day', y='weight (lbs)')
def plot_gh_results(weights, estimates, predictions, time_step=0):

    n = len(weights)
    if time_step > 0:
        rng = range(1, n+1)
    else:
        rng = range(n, n+1)

    plt.xlim([-1, n+1])
    plt.ylim([156.0, 173])
    act, = book_plots.plot_track([0, n], [160, 160+n], c='k')
    plt.gcf().canvas.draw()

    for i in rng:
        xs = list(range(i+1))

        #plt.cla()

        pred, = book_plots.plot_track(xs[1:], predictions[:i], c='r', marker='v')
        plt.xlim([-1, n+1])
        plt.ylim([156.0, 173])
        plt.gcf().canvas.draw()
        time.sleep(time_step)

        scale, = book_plots.plot_measurements(xs[1:], weights[:i], color='k', lines=False)
        plt.xlim([-1, n+1])
        plt.ylim([156.0, 173])
        plt.gcf().canvas.draw()
        time.sleep(time_step)

        book_plots.plot_filter(xs[:i+1], estimates[:i+1], marker='o')
        plt.xlim([-1, n+1])
        plt.ylim([156.0, 173])
        plt.gcf().canvas.draw()
        time.sleep(time_step)

        plt.legend([act, scale, pred], ['Actual Weight', 'Measurement', 'Predictions'], loc=4)
    book_plots.set_labels(x='day', y='weight (lbs)')
示例#5
0
#"I know you would never set
#both g and h to zero as that takes a special kind of genius that only I
#possess, but I promise that if you are not careful you will set them lower
#than they should be."

#
#
# Tracking train
#
#
#from numpy.random import randn
def compute_new_position(pos, vel, dt=1):
	""" dt is the time delta in seconds."""
	return pos + (vel * dt)
def measure_position(pos):
	return pos + randn()*500
def gen_train_data(pos, vel, count):
	zs = []
	for t in range(count):
		pos = compute_new_position(pos, vel)
		zs.append(measure_position(pos))
	return np.asarray(zs)

pos, vel = 23*1000, 15
zs = gen_train_data(pos, vel, 100)
plt.plot(zs / 1000.) # convert to km
book_plots.set_labels('Train Position', 'time(sec)', 'km')

# ослабление h может помочь проверять отследить ускорение
show()