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
// 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', |
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
/* | |
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.). |
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_ ) |
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
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
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
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
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
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) |
OlderNewer