This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
custom_title = title + ' – sparse data' | |
plt.figure(figsize=figure_proportions) | |
plt.scatter(sparse_input, sparse_data, color = 'green', marker = "o", s=100) | |
plt.title(custom_title) | |
plt.xlabel(x_axis_label) | |
plt.ylabel(y_axis_label) | |
plt.xlim(x_min, x_max ) | |
plt.ylim(0, y_max ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sampling_increment = 15 | |
sparse_input = in_array[::sampling_increment] | |
sparse_data = curve[::sampling_increment] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
y_axis_label = 'altitude (feet)' | |
x_axis_label = 'time (seconds from arrival at target)' | |
title = 'Trajectory of flight' | |
custom_title = title + ' – noisy data' | |
figure_proportions = (10, 5) | |
y_max = 100 | |
x_min, x_max = -3.3, 4.3 | |
plt.figure(figsize=figure_proportions) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flux_range = 35 | |
random_flux = np.random.rand(len(curve))*flux_range - flux_range/2 | |
noisy_data = curve + random_flux |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
in_array = np.linspace(-3, 4, 100) | |
def curve1(in_array_ ): | |
return (in_array_**3) + ((in_array_*.9-4)**2) | |
def curve2(in_array_ ): | |
return (20*np.sin((in_array_)*3+4)+20) + curve1(in_array_ ) | |
x = in_array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
custom_title = title + ' - smooth data' + ' - linear interpolation only' | |
plt.figure(figsize=figure_proportions ) | |
plt.plot(in_array, curve, color = 'green') | |
plt.title(custom_title) | |
plt.xlabel(x_axis_label) | |
plt.ylabel(y_axis_label) | |
plt.xlim(x_min, x_max ) | |
plt.ylim(0, y_max ) | |
plt.savefig('viz/'+custom_title+'.svg') | |
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
custom_title = title + ' - smooth data' + ' - with linear interpolation' | |
plt.figure(figsize=figure_proportions ) | |
plt.plot(in_array, curve, color = 'green', marker = "o") | |
plt.title(custom_title) | |
plt.xlabel(x_axis_label) | |
plt.ylabel(y_axis_label) | |
plt.xlim(x_min, x_max ) | |
plt.ylim(0, y_max ) | |
plt.savefig('viz/'+custom_title+'.svg') | |
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
in_array = np.linspace(-3, 4, 100) | |
x = in_array | |
curve = np.piecewise(x, [x<.2, x >=.2], [lambda x: curve1(x), lambda x: curve2(x)]) | |
y_axis_label = 'altitude (feet)' | |
x_axis_label = 'time (seconds from arrival at target)' | |
title = 'Trajectory of flight' | |
figure_proportions = (10, 5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def curve1(in_array_ ): | |
return (in_array_**3) + ((in_array_*.9-4)**2) | |
def curve2(in_array_ ): | |
return (20*np.sin((in_array_)*3+4)+20) + curve1(in_array_ ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def curve1(in_array_ ): | |
return (in_array_**3) + ((in_array_*.9-4)**2) | |
def curve2(in_array_ ): | |
return (20*np.sin((in_array_)*3+4)+20) + curve1(in_array_ ) |