Skip to content

Instantly share code, notes, and snippets.

View jmailman's full-sized avatar

Joshua Banks Mailman jmailman

View GitHub Profile
@jmailman
jmailman / homework-01.js
Created October 5, 2017 19:02
homework-01.js
// Homework 1
// Hint: You may need SOME of these array iterator methods:
// .map(), .filter(), .forEach() , .some(), .every()
// Hint: You may also need SOME of the following methods:
// Number(), .reverse(), typeof(), .join()
// Let's say we have an array of prices named `prices`.
var prices = ['100', '125', '129', '37', '38', '75', '87', '94', '300', '301',
'305', '50', '0.30', '0.01', '0.5', '5', '15', '24', '35', '1041', '1', '17',
/*
READ ME
The bot responds to hearing the words "today", "yesterday", and "tomorrow" in any context.
In response, in proper English, it provides the date, month, and year.
It also provides a link to the Wikepedi page for that specific date and a
link to a website listing celebrities born on that date.
Then the bot asks for the user's favorite day of the week.
It listens (in any context) for the days of the week (Sunday, Monday, etc.).
@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_ )
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 / 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)
@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 / 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 / 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 / 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 / 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)