Skip to content

Instantly share code, notes, and snippets.

View jmailman's full-sized avatar

Joshua Banks Mailman jmailman

View GitHub Profile
@jmailman
jmailman / 8_graphing_code.py
Last active April 2, 2021 15:25
8_graphing_code.py
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 )
@jmailman
jmailman / 7_sparse_data_with_sampling_increment.py
Created April 2, 2021 15:24
7_sparse_data_with_sampling_increment.py
sampling_increment = 15
sparse_input = in_array[::sampling_increment]
sparse_data = curve[::sampling_increment]
@jmailman
jmailman / 6_graphing_code_repeated.py
Created April 2, 2021 15:22
6_graphing_code_repeated.py
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)
@jmailman
jmailman / 5_random_flux_noisy_data.py
Created April 2, 2021 15:18
5_random_flux_noisy_data.py
flux_range = 35
random_flux = np.random.rand(len(curve))*flux_range - flux_range/2
noisy_data = curve + random_flux
@jmailman
jmailman / 4_two_curve_functions_and_resulting_curve.py
Last active April 2, 2021 14:58
4_two_curves_functions_and_resulting_curve.py
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
@jmailman
jmailman / 3_plot_linear_interpolation_only_of_ground_truth.py
Created April 2, 2021 03:34
3_plot_linear_interpolation_only_of_ground_truth.py
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()
@jmailman
jmailman / 2_plot_linear_interpolation_of_ground_truth.py
Created April 2, 2021 03:30
2_plot_linear_interpolation_of_ground_truth.py
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()
@jmailman
jmailman / 1_plot_piecewise_function_curve.py
Last active April 2, 2021 03:27
1_plot_piecewise_function_curve.py
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)
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_ )
@jmailman
jmailman / gist:434c2e35a254f65acd72b786295194a5
Created April 2, 2021 00:45
data smoothing code snippet 1
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_ )