%pylab inline %run talktools import scipy.special as spec x = linspace(0, 20, 200) for n in range(0,13,3): plot(x, spec.jn(n, x), label=r'$J_{%i}(x)$' % n) grid() legend() title('Bessel Functions are neat'); @interactive(x=(1, 10)) def f(x): print 'X is:', x from sklearn import datasets digits = datasets.load_digits() n = len(digits.images) @interactive(i=(0,n-1)) def view_image(i): print 'Classif. Label:', digits.target[i] plt.matshow(digits.images[i], cmap=cm.gray_r) plt.show() Image('fig/logo.png') Video('fig/animation.m4v') # Credit: Chris Kees, Army ERDC; created with Proteus. plot_audio('voice.wav') Audio('voice.wav') Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx') from sympy import symbols, Eq, factor, init_printing, expand init_printing(use_latex=True) x, y = symbols("x y") eq = ((x+y)**3 * (x+1)) display(Eq(eq, expand(eq))) @interactive(n=(1,10)) def _(n): eq = ((x+y)**n * (x+1)) display(Eq(eq, expand(eq))) X = np.array([0,1,2,3,4]) Y = np.array([3,5,4,6,7]) # Now, load R support %load_ext rmagic %%R -i X,Y -o XYcoef XYlm = lm(Y~X) XYcoef = coef(XYlm) print(summary(XYlm)) par(mfrow=c(2,2)) plot(XYlm) %load_ext julia.magic %julia @pyimport matplotlib.pyplot as plt %julia @pyimport numpy as np %%julia # Note how we mix numpy and julia: x = linspace(0,2*pi,1000); # use the julia linspace y = sin(3*x + 4*np.cos(2*x)); # use the numpy cosine and julia sine plt.plot(x, y, color="red", linewidth=2.0, linestyle="--") jfib = %julia jfib(n, fib) = n < 2 ? n : fib(n-1, jfib) + fib(n-2, jfib) def pyfib(n, fib): if n < 2: return n return fib(n-1, pyfib) + fib(n-2, pyfib) pyfib(20, jfib) # Credit: Steven Johnson, MIT. %load_ext fortranmagic %%fortran subroutine f1(x, y, n) real, intent(in), dimension(n) :: x real, intent(out), dimension(n) :: y !intent(hide) :: n y = sin(x**2) end subroutine f1 x = np.linspace(0, 2*pi, 300) plot(x, f1(x)); website('nbviewer.ipython.org') website('http://www.nature.com/ismej/journal/v7/n3/full/ismej2012123a.html', 'Paper:') website('http://qiime.org/home_static/nih-cloud-apr2012', 'Companion Website:') website('http://jakevdp.github.io/blog/2013/12/05/static-interactive-widgets', 'Pythonic Perambulations') YouTubeVideo('tlontoyWX70',start='800', width=600, height=400) website('camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers', 'Probabilistic programming...') website('http://cs109.org/homework/homework.php', 'CS 109 Homeworks') website('http://nbviewer.ipython.org/gist/jackparmer/7729584', 'Rosling Countries', width=900, height=600) YouTubeVideo('UUjTAq8cCcs', width=600, height=500)