A demo of some very basic features of Jupyter notebooks.

Author: Lehman Garrison (lgarrison@cfa.harvard.edu)

Made for the CfA Jupyter Workshop at Wolbach Library, 12/7/2016

Setup


In [1]:
print 'hello world!'


hello world!

In [2]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

In [7]:
x = np.linspace(0,10,1000)
y = np.sin(x)

Plotting

The following is a plot of $f(x) = \sin(x)$:


In [8]:
plt.plot(x,y)


Out[8]:
[<matplotlib.lines.Line2D at 0x7f6e3e98b810>]

Timing


In [24]:
%timeit np.random.rand(100000)


1000 loops, best of 3: 990 µs per loop

In [25]:
%%timeit
a = np.random.rand(100000)
b = np.fft.fft(a)


100 loops, best of 3: 3.88 ms per loop