GitHub

@@ -1,3 +1,14 @@

1+

---

2+

jupytext:

3+

text_representation:

4+

extension: .md

5+

format_name: myst

6+

kernelspec:

7+

display_name: Python 3

8+

language: python

9+

name: python3

10+

---

11+112

```{raw} html

213

<div id="qe-notebook-header" align="right" style="text-align:right;">

314

<a href="https://quantecon.org/" title="quantecon.org">

@@ -161,7 +172,7 @@ NumPy provides the basic array data type plus some simple processing operations.

161172162173

For example, let's build some arrays

163174164-

```{code-block} python3

175+

```{code-cell} python3

165176

import numpy as np # Load the library

166177167178

a = np.linspace(-np.pi, np.pi, 100) # Create even grid from -π to π

@@ -171,7 +182,7 @@ c = np.sin(a) # Apply sin to each element of a

171182172183

Now let's take the inner product

173184174-

```{code-block} python3

185+

```{code-cell} python3

175186

b @ c

176187

```

177188

@@ -183,7 +194,7 @@ The [SciPy](http://www.scipy.org) library is built on top of NumPy and provides

183194184195

For example, let's calculate $\int_{-2}^2 \phi(z) dz$ where $\phi$ is the standard normal density.

185196186-

```{code-block} python3

197+

```{code-cell} python3

187198

from scipy.stats import norm

188199

from scipy.integrate import quad

189200

@@ -251,7 +262,7 @@ single: SymPy

251262252263

The [SymPy](http://www.sympy.org/) library provides this functionality from within the Python shell.

253264254-

```{code-block} python3

265+

```{code-cell} python3

255266

from sympy import Symbol

256267257268

x, y = Symbol('x'), Symbol('y') # Treat 'x' and 'y' as algebraic symbols

@@ -260,32 +271,32 @@ x + x + x + y

260271261272

We can manipulate expressions

262273263-

```{code-block} python3

274+

```{code-cell} python3

264275

expression = (x + y)**2

265276

expression.expand()

266277

```

267278268279

solve polynomials

269280270-

```{code-block} python3

281+

```{code-cell} python3

271282

from sympy import solve

272283273284

solve(x**2 + x + 2)

274285

```

275286276287

and calculate limits, derivatives and integrals

277288278-

```{code-block} python3

289+

```{code-cell} python3

279290

from sympy import limit, sin, diff

280291281292

limit(1 / x, x, 0)

282293

```

283294284-

```{code-block} python3

295+

```{code-cell} python3

285296

limit(sin(x) / x, x, 0)

286297

```

287298288-

```{code-block} python3

299+

```{code-cell} python3

289300

diff(sin(x), x)

290301

```

291302

@@ -313,7 +324,7 @@ Pandas is fast, efficient, flexible and well designed.

313324

Here's a simple example, using some dummy data generated with Numpy's excellent

314325

`random` functionality.

315326316-

```{code-block} python3

327+

```{code-cell} python3

317328

import pandas as pd

318329

np.random.seed(1234)

319330

@@ -324,7 +335,7 @@ df = pd.DataFrame(data, columns=('price', 'weight'), index=dates)

324335

print(df)

325336

```

326337327-

```{code-block} python3

338+

```{code-cell} python3

328339

df.mean()

329340

```

330341

@@ -370,7 +381,7 @@ Its features include, among many other things:

370381371382

Here's some example code that generates and plots a random graph, with node color determined by shortest path length from a central node.

372383373-

```{code-block} ipython

384+

```{code-cell} ipython

374385

import networkx as nx

375386

import matplotlib.pyplot as plt

376387

%matplotlib inline

Read the original on github.com ↗