%matplotlib inline

import matplotlib.pyplot as plt

"""
Explanation: The first two cells below are used to tell the notebook that we want any plots (generated by matplotlib) to appear inline with the notebook and not in a separate window.
End of explanation
"""


from numpy import *

"""
Explanation: Next, we import all of the functions that come with the numpy package. This gives python a lot of array-based features that are optimized for computational speed.
End of explanation
"""


x = linspace(0,100, num=100)

x

"""
Explanation: The first is the command linspace
linspace creates an array filled with values set by the function parameters:
End of explanation
"""


linspace?

"""
Explanation: You can also find out more about a function by asking for help on the command line. Type the function name and a question mark:
End of explanation
"""


x = linspace(0,100,num=1024)
x

"""
Explanation: You should see a line that says:
Signature: linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)
This describes the function and what values you can specify. We used only the start and stop but we could also use the num parameter to tell it how many points we want in the array.
You can close the help by typing esc or by clicking on the small x in the upper right corner.
End of explanation
"""


y = sin(x)

plt.plot(x,y)

plt.plot(x,y,".")  #another example, with dots this time...

random.random()

fft.fft(y)
newy=fft.fft(y)

plt.plot(abs(newy[0:100]))

newarry = y + .1*random.random(1024)

newarry

plt.plot(x,newarry)

fft.fft(newarry)

plt.plot(abs(fft.fft(newarry))[0:40])

"""
Explanation: Starting from the example below, generate a few plots for practice:
 - a sine wave
 - the fourier transform of a sine wave
 - a sine wave with additional noise (add random values that are 10% of the sine-wave amplitude)
 - the fourier transform of the noisy sine wave
Hints: for these, you'll want to have a larger number of points in the array and we don't necessarily need to view the array each time, that was just for learning purposes. Try setting num=1024 in the linspace function.
The following functions will be useful (these are both part of numpy):
 - random.random()
 - fft.fft()
The dot indicates that the function is part of a module within numpy; the fft function is part of the fft module so you have to specify that when you use it. You can learn more about them with the help feature: 
random.random?
End of explanation
"""


