def plot_g_h_results(measurements, filtered_data, title='', z_label='Measurements', **kwargs): book_plots.plot_filter(filtered_data, **kwargs) book_plots.plot_measurements(measurements, label=z_label) plt.legend(loc=4) plt.title(title) plt.gca().set_xlim(left=0,right=len(measurements)) return import time if not interactive: book_plots.plot_filter(filtered_data, **kwargs) book_plots.plot_measurements(measurements, label=z_label) book_plots.show_legend() plt.title(title) plt.gca().set_xlim(left=0,right=len(measurements)) else: for i in range(2, len(measurements)): book_plots.plot_filter(filtered_data, **kwargs) book_plots.plot_measurements(measurements, label=z_label) book_plots.show_legend() plt.title(title) plt.gca().set_xlim(left=0,right=len(measurements)) plt.gca().canvas.draw() time.sleep(0.5)
def plot_g_h_results(measurements, filtered_data, title='', z_label='Measurements', **kwargs): book_plots.plot_filter(filtered_data, **kwargs) book_plots.plot_measurements(measurements, label=z_label) plt.legend(loc=4) plt.title(title) plt.gca().set_xlim(left=0, right=len(measurements)) return import time if not interactive: book_plots.plot_filter(filtered_data, **kwargs) book_plots.plot_measurements(measurements, label=z_label) book_plots.show_legend() plt.title(title) plt.gca().set_xlim(left=0, right=len(measurements)) else: for i in range(2, len(measurements)): book_plots.plot_filter(filtered_data, **kwargs) book_plots.plot_measurements(measurements, label=z_label) book_plots.show_legend() plt.title(title) plt.gca().set_xlim(left=0, right=len(measurements)) plt.gca().canvas.draw() time.sleep(0.5)
def plot_hypothesis5(): weights = [ 158.0, 164.2, 160.3, 159.9, 162.1, 164.6, 169.6, 167.4, 166.4, 171.0, 171.2, 172.6 ] xs = range(1, len(weights) + 1) line = np.poly1d(np.polyfit(xs, weights, 1)) with figsize(y=2.5): plt.figure() plt.errorbar(range(1, 13), weights, label='weights', yerr=5, fmt='o', capthick=2, capsize=10) plt.plot(xs, line(xs), c='r', label='hypothesis') plt.xlim(0, 13) plt.ylim(145, 185) plt.xlabel('day') plt.ylabel('weight (lbs)') book_plots.show_legend() plt.grid(False)
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_hypothesis4(): weights = [158.0, 164.2, 160.3, 159.9, 162.1, 164.6, 169.6, 167.4, 166.4, 171.0, 171.2, 172.6] with book_plots.figsize(y=2.5): plt.figure() ave = np.sum(weights) / len(weights) plt.errorbar(range(1,13), weights, label='weights', yerr=6, fmt='o', capthick=2, capsize=10) plt.plot([1, 12], [ave,ave], c='r', label='hypothesis') plt.xlim(0, 13) plt.ylim(145, 185) plt.xlabel('day') plt.ylabel('weight (lbs)') book_plots.show_legend()
def plot_hypothesis4(): weights = [158.0, 164.2, 160.3, 159.9, 162.1, 164.6, 169.6, 167.4, 166.4, 171.0, 171.2, 172.6] with book_plots.figsize(y=2.5): plt.figure() ave = np.sum(weights) / len(weights) plt.errorbar(range(1,13), weights, label='weights', yerr=6, fmt='o', capthick=2, capsize=10) plt.plot([1, 12], [ave,ave], c='r', label='hypothesis') plt.xlim(0, 13) plt.ylim(145, 185) plt.xlabel('day') plt.ylabel('weight (lbs)') book_plots.show_legend() plt.grid(False)
def plot_hypothesis5(): weights = [158.0, 164.2, 160.3, 159.9, 162.1, 164.6, 169.6, 167.4, 166.4, 171.0, 171.2, 172.6] xs = range(1, len(weights)+1) line = np.poly1d(np.polyfit(xs, weights, 1)) with figsize(y=2.5): plt.figure() plt.errorbar(range(1, 13), weights, label='weights', yerr=5, fmt='o', capthick=2, capsize=10) plt.plot (xs, line(xs), c='r', label='hypothesis') plt.xlim(0, 13) plt.ylim(145, 185) plt.xlabel('day') plt.ylabel('weight (lbs)') book_plots.show_legend()
x = gaussian(0., 1000.) # initial state process_model = gaussian(1., process_var) N = 12 zs = distancia(distance_std, N) ps = [] estimates = [] priors = np.zeros((N, 2)) for i, z in enumerate(zs): prior = predict(x, process_model) priors[i] = prior x = update(prior, gaussian(z, distance_std**2)) # save for latter plotting estimates.append(x.mean) ps.append(x.var) # plot the filter output and the variance book_plots.plot_measurements(zs) book_plots.plot_filter(estimates, var=np.array(ps)) book_plots.plot_predictions(priors[:, 0]) book_plots.show_legend() book_plots.set_labels(x='Tempo (s)', y='Posições') plt.show() plt.figure() plt.plot(ps) plt.title('Variância') print('Variance converges to {:.3f}'.format(ps[-1]))