Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lectures/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sphinx:
html_theme_options:
authors:
- name: Thomas J. Sargent
url: http://www.tomsargent.com/
url: https://www.tomsargent.com/
- name: John Stachurski
url: https://johnstachurski.net/
dark_logo: quantecon-logo-transparent.png
Expand Down
38 changes: 19 additions & 19 deletions lectures/about_py.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ Even if you don't yet know Python, you can see that the code is far simpler and
import csv

total, count = 0, 0
with open(data.csv, mode='r') as file:
with open('data.csv', mode='r') as file:
reader = csv.reader(file)
for row in reader:
try:
Expand Down Expand Up @@ -311,7 +311,7 @@ But when we want to work with larger arrays in real programs we need more effici
For this we need to use libraries for working with arrays.

For Python, the most important matrix and array processing library is
[NumPy](http://www.numpy.org/) library.
[NumPy](https://www.numpy.org/) library.

For example, let's build a NumPy array with 100 elements

Expand Down Expand Up @@ -365,7 +365,7 @@ This lecture series will provide you with extensive background in NumPy.

### SciPy

The [SciPy](http://www.scipy.org) library is built on top of NumPy and provides additional functionality.
The [SciPy](https://www.scipy.org) library is built on top of NumPy and provides additional functionality.

(tuple_unpacking_example)=
For example, let's calculate $\int_{-2}^2 \phi(z) dz$ where $\phi$ is the standard normal density.
Expand All @@ -381,14 +381,14 @@ value

SciPy includes many of the standard routines used in

* [linear algebra](http://docs.scipy.org/doc/scipy/reference/linalg.html)
* [integration](http://docs.scipy.org/doc/scipy/reference/integrate.html)
* [interpolation](http://docs.scipy.org/doc/scipy/reference/interpolate.html)
* [optimization](http://docs.scipy.org/doc/scipy/reference/optimize.html)
* [distributions and statistical techniques](http://docs.scipy.org/doc/scipy/reference/stats.html)
* [signal processing](http://docs.scipy.org/doc/scipy/reference/signal.html)
* [linear algebra](https://docs.scipy.org/doc/scipy/reference/linalg.html)
* [integration](https://docs.scipy.org/doc/scipy/reference/integrate.html)
* [interpolation](https://docs.scipy.org/doc/scipy/reference/interpolate.html)
* [optimization](https://docs.scipy.org/doc/scipy/reference/optimize.html)
* [distributions and statistical techniques](https://docs.scipy.org/doc/scipy/reference/stats.html)
* [signal processing](https://docs.scipy.org/doc/scipy/reference/signal.html)

See them all [here](http://docs.scipy.org/doc/scipy/reference/index.html).
See them all [here](https://docs.scipy.org/doc/scipy/reference/index.html).

Later we'll discuss SciPy in more detail.

Expand All @@ -400,7 +400,7 @@ Later we'll discuss SciPy in more detail.

A major strength of Python is data visualization.

The most popular and comprehensive Python library for creating figures and graphs is [Matplotlib](http://matplotlib.org/), with functionality including
The most popular and comprehensive Python library for creating figures and graphs is [Matplotlib](https://matplotlib.org/), with functionality including

* plots, histograms, contour images, 3D graphs, bar charts etc.
* output in many formats (PDF, PNG, EPS, etc.)
Expand All @@ -427,10 +427,10 @@ More examples can be found in the [Matplotlib thumbnail gallery](https://matplot

Other graphics libraries include

* [Plotly](https://plot.ly/python/)
* [Plotly](https://plotly.com/python/)
* [seaborn](https://seaborn.pydata.org/) --- a high-level interface for matplotlib
* [Altair](https://altair-viz.github.io/)
* [Bokeh](http://bokeh.pydata.org/en/latest/)
* [Bokeh](https://bokeh.pydata.org/en/latest/)

You can visit the [Python Graph Gallery](https://www.python-graph-gallery.com/) for more example plots drawn using a variety of libraries.

Expand All @@ -452,7 +452,7 @@ Python has many libraries for studying networks and graphs.
```{index} single: NetworkX
```

One well-known example is [NetworkX](http://networkx.github.io/).
One well-known example is [NetworkX](https://networkx.org/).

Its features include, among many other things:

Expand Down Expand Up @@ -503,14 +503,14 @@ firms.
Here's a short list of some important scientific libraries for Python not
mentioned above.

* [SymPy](http://www.sympy.org/) for symbolic algebra, including limits, derivatives and integrals
* [statsmodels](http://statsmodels.sourceforge.net/) for statistical routines
* [scikit-learn](http://scikit-learn.org/) for machine learning
* [SymPy](https://www.sympy.org/) for symbolic algebra, including limits, derivatives and integrals
* [statsmodels](https://www.statsmodels.org/) for statistical routines
* [scikit-learn](https://scikit-learn.org/) for machine learning
* [Keras](https://keras.io/) for machine learning
* [Pyro](https://pyro.ai/) and [PyStan](https://pystan.readthedocs.org/en/latest/) for Bayesian data analysis
* [Pyro](https://pyro.ai/) and [PyStan](https://pystan.readthedocs.io/en/latest/) for Bayesian data analysis
* [GeoPandas](https://geopandas.org/en/stable/) for spatial data analysis
* [Dask](https://docs.dask.org/en/stable/) for parallelization
* [Numba](http://numba.pydata.org/) for making Python run at the same speed as native machine code
* [Numba](https://numba.pydata.org/) for making Python run at the same speed as native machine code
* [CVXPY](https://www.cvxpy.org/) for convex optimization
* [scikit-image](https://scikit-image.org/) and [OpenCV](https://opencv.org/) for processing and analyzing image data
* [BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/bs4/doc/) for extracting data from HTML and XML files
Expand Down
2 changes: 1 addition & 1 deletion lectures/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ There are many other useful magics:
* `%whos` gives a list of variables and their values
* `%quickref` gives a list of magics

The full list of magics is [here](http://ipython.readthedocs.org/en/stable/interactive/magics.html).
The full list of magics is [here](https://ipython.readthedocs.io/en/stable/interactive/magics.html).


## Handling Errors
Expand Down
14 changes: 7 additions & 7 deletions lectures/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ For more information on conda, type conda help in a terminal.
```{index} single: Jupyter
```

[Jupyter](http://jupyter.org/) notebooks are one of the many possible ways to interact with Python and the scientific libraries.
[Jupyter](https://jupyter.org/) notebooks are one of the many possible ways to interact with Python and the scientific libraries.

They use a *browser-based* interface to Python with

Expand All @@ -149,7 +149,7 @@ They use a *browser-based* interface to Python with

Because of these features, Jupyter is now a major player in the scientific computing ecosystem.

Here's an image showing execution of some code (borrowed from [here](http://matplotlib.org/examples/pylab_examples/hexbin_demo.html)) in a Jupyter notebook
Here's an image showing execution of some code (borrowed from [here](https://matplotlib.org/stable/gallery/statistics/hexbin_demo.html)) in a Jupyter notebook

```{figure} /_static/lecture_specific/getting_started/jp_demo.png
:figclass: auto
Expand Down Expand Up @@ -269,7 +269,7 @@ In a code cell, try typing `\alpha` and then hitting the tab key on your keyboar

Let's run a test program.

Here's an arbitrary program we can use: [http://matplotlib.org/3.1.1/gallery/pie_and_polar_charts/polar_bar.html](http://matplotlib.org/3.1.1/gallery/pie_and_polar_charts/polar_bar.html).
Here's an arbitrary program we can use: [https://matplotlib.org/stable/gallery/pie_and_polar_charts/polar_bar.html](https://matplotlib.org/stable/gallery/pie_and_polar_charts/polar_bar.html).

On that page, you'll see the following code

Expand Down Expand Up @@ -350,7 +350,7 @@ In addition to executing code, the Jupyter notebook allows you to embed text, eq
For example, we can enter a mixture of plain text and LaTeX instead of code.

Next we `Esc` to enter command mode and then type `m` to indicate that we
are writing [Markdown](http://daringfireball.net/projects/markdown/), a mark-up language similar to (but simpler than) LaTeX.
are writing [Markdown](https://daringfireball.net/projects/markdown/), a mark-up language similar to (but simpler than) LaTeX.

(You can also use your mouse to select `Markdown` from the `Code` drop-down box just below the list of menu items)

Expand Down Expand Up @@ -410,7 +410,7 @@ You can explore more functionality of the debugger in the [Jupyter documentation

Notebook files are just text files structured in [JSON](https://en.wikipedia.org/wiki/JSON) and typically ending with `.ipynb`.

You can share them in the usual way that you share files --- or by using web services such as [nbviewer](http://nbviewer.jupyter.org/).
You can share them in the usual way that you share files --- or by using web services such as [nbviewer](https://nbviewer.jupyter.org/).

The notebooks you see on that site are **static** html representations.

Expand Down Expand Up @@ -510,7 +510,7 @@ print("foobar")

This writes the line `print("foobar")` into a file called `foo.py` in the local directory.

Here `%%writefile` is an example of a [cell magic](http://ipython.readthedocs.org/en/stable/interactive/magics.html#cell-magics).
Here `%%writefile` is an example of a [cell magic](https://ipython.readthedocs.io/en/stable/interactive/magics.html#cell-magics).

### Editing and Execution

Expand Down Expand Up @@ -553,7 +553,7 @@ Right now, an extremely popular text editor for coding is [VS Code](https://code

VS Code is easy to use out of the box and has many high quality extensions.

Alternatively, if you want an outstanding free text editor and don't mind a seemingly vertical learning curve plus long days of pain and suffering while all your neural pathways are rewired, try [Vim](http://www.vim.org/).
Alternatively, if you want an outstanding free text editor and don't mind a seemingly vertical learning curve plus long days of pain and suffering while all your neural pathways are rewired, try [Vim](https://www.vim.org/).

## Exercises

Expand Down
8 changes: 4 additions & 4 deletions lectures/matplotlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ kernelspec:

## Overview

We've already generated quite a few figures in these lectures using [Matplotlib](http://matplotlib.org/).
We've already generated quite a few figures in these lectures using [Matplotlib](https://matplotlib.org/).

Matplotlib is an outstanding graphics library, designed for scientific computing, with

Expand Down Expand Up @@ -438,9 +438,9 @@ plt.rcParams['figure.figsize'] = (10, 6)

## Further Reading

* The [Matplotlib gallery](http://matplotlib.org/gallery.html) provides many examples.
* A nice [Matplotlib tutorial](http://scipy-lectures.org/intro/matplotlib/index.html) by Nicolas Rougier, Mike Muller and Gael Varoquaux.
* [mpltools](http://tonysyu.github.io/mpltools/index.html) allows easy
* The [Matplotlib gallery](https://matplotlib.org/stable/gallery/index.html) provides many examples.
* A nice [Matplotlib tutorial](https://scipy-lectures.org/intro/matplotlib/index.html) by Nicolas Rougier, Mike Muller and Gael Varoquaux.
* [mpltools](https://tonysyu.github.io/mpltools/index.html) allows easy
switching between plot styles.
* [Seaborn](https://github.com/mwaskom/seaborn) facilitates common statistics plots in Matplotlib.

Expand Down
2 changes: 1 addition & 1 deletion lectures/numba.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Another is that the set of algorithms that can be entirely vectorized is not uni

In fact, for some algorithms, vectorization is ineffective.

Fortunately, a new Python library called [Numba](http://numba.pydata.org/)
Fortunately, a new Python library called [Numba](https://numba.pydata.org/)
solves many of these problems.

It does so through something called **just in time (JIT) compilation**.
Expand Down
22 changes: 15 additions & 7 deletions lectures/numpy.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ kernelspec:
"Let's be clear: the work of science has nothing whatever to do with consensus. Consensus is the business of politics. Science, on the contrary, requires only one investigator who happens to be right, which means that he or she has results that are verifiable by reference to the real world. In science consensus is irrelevant. What is relevant is reproducible results." -- Michael Crichton
```

In addition to what's in Anaconda, this lecture will need the following libraries:

```{code-cell} ipython3
:tags: [hide-output]

!pip install quantecon
```

## Overview

[NumPy](https://en.wikipedia.org/wiki/NumPy) is a first-rate library for numerical programming
Expand All @@ -42,7 +50,7 @@ In this lecture, we will start a more systematic discussion of
1. the fundamental array processing operations provided by NumPy.


(For an alternative reference, see [the official NumPy documentation](http://docs.scipy.org/doc/numpy/reference/).)
(For an alternative reference, see [the official NumPy documentation](https://docs.scipy.org/doc/numpy/reference/).)

We will use the following imports.

Expand All @@ -64,11 +72,11 @@ from matplotlib import cm
The essential problem that NumPy solves is fast array processing.

The most important structure that NumPy defines is an array data type, formally
called a [numpy.ndarray](http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html).
called a [numpy.ndarray](https://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html).

NumPy arrays power a very large proportion of the scientific Python ecosystem.

To create a NumPy array containing only zeros we use [np.zeros](http://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros.html#numpy.zeros)
To create a NumPy array containing only zeros we use [np.zeros](https://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros.html#numpy.zeros)

```{code-cell} python3
a = np.zeros(3)
Expand Down Expand Up @@ -212,7 +220,7 @@ na is np.array(na) # Does make a new copy --- perhaps unnecessarily
```

To read in the array data from a text file containing numeric data use `np.loadtxt`
or `np.genfromtxt`---see [the documentation](http://docs.scipy.org/doc/numpy/reference/routines.io.html) for details.
or `np.genfromtxt`---see [the documentation](https://docs.scipy.org/doc/numpy/reference/routines.io.html) for details.

### Array Indexing

Expand Down Expand Up @@ -456,7 +464,7 @@ B = np.ones((2, 2))
A @ B
```

(For older versions of Python and NumPy you need to use the [np.dot](http://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html) function)
(For older versions of Python and NumPy you need to use the [np.dot](https://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html) function)

We can also use `@` to take the inner product of two flat arrays

Expand Down Expand Up @@ -526,7 +534,7 @@ Here is a visual representation of this broadcasting operation:
tags: [hide-input]
---
# Adapted and modified based on the code in the book written by Jake VanderPlas (see https://jakevdp.github.io/PythonDataScienceHandbook/06.00-figure-code.html#Broadcasting)
# Originally from astroML: see http://www.astroml.org/book_figures/appendix/fig_broadcast_visual.html
# Originally from astroML: see https://www.astroml.org/book_figures/appendix/fig_broadcast_visual.html


def draw_cube(ax, xy, size, depth=0.4,
Expand Down Expand Up @@ -1155,7 +1163,7 @@ np.linalg.inv(A) # Compute the inverse
```{index} single: Python; SciPy
```

Much of this functionality is also available in [SciPy](http://www.scipy.org/), a collection of modules that are built on top of NumPy.
Much of this functionality is also available in [SciPy](https://www.scipy.org/), a collection of modules that are built on top of NumPy.

We'll cover the SciPy versions in more detail {doc}`soon <scipy>`.

Expand Down
12 changes: 6 additions & 6 deletions lectures/pandas.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ In addition to what’s in Anaconda, this lecture will need the following librar

## Overview

[Pandas](http://pandas.pydata.org/) is a package of fast, efficient data analysis tools for Python.
[Pandas](https://pandas.pydata.org/) is a package of fast, efficient data analysis tools for Python.

Its popularity has surged in recent years, coincident with the rise
of fields such as data science and machine learning.
Expand All @@ -47,7 +47,7 @@ Here's a popularity comparison over time against Matlab and STATA courtesy of St
:scale: 100
```

Just as [NumPy](http://www.numpy.org/) provides the basic array data type plus core array operations, pandas
Just as [NumPy](https://www.numpy.org/) provides the basic array data type plus core array operations, pandas

1. defines fundamental structures for working with data and
1. endows them with methods that facilitate operations such as
Expand All @@ -58,7 +58,7 @@ Just as [NumPy](http://www.numpy.org/) provides the basic array data type plus c
* dealing with missing values, etc., etc.

More sophisticated statistical functionality is left to other packages, such
as [statsmodels](http://www.statsmodels.org/) and [scikit-learn](http://scikit-learn.org/), which are built on top of pandas.
as [statsmodels](https://www.statsmodels.org/) and [scikit-learn](https://scikit-learn.org/), which are built on top of pandas.

This lecture will provide a basic introduction to pandas.

Expand Down Expand Up @@ -536,7 +536,7 @@ In the second case, you can either
* switch to another machine
* solve your proxy problem by reading [the documentation](https://requests.readthedocs.io/en/master/)

Assuming that all is working, you can now proceed to use the `source` object returned by the call `requests.get('http://research.stlouisfed.org/fred2/series/UNRATE/downloaddata/UNRATE.csv')`
Assuming that all is working, you can now proceed to use the `source` object returned by the call `requests.get('https://research.stlouisfed.org/fred2/series/UNRATE/downloaddata/UNRATE.csv')`

```{code-cell} ipython3
url = 'https://fred.stlouisfed.org/graph/fredgraph.csv?bgcolor=%23e1e9f0&chart_type=line&drp=0&fo=open%20sans&graph_bgcolor=%23ffffff&height=450&mode=fred&recession_bars=on&txtcolor=%23444444&ts=12&tts=12&width=1318&nt=0&thu=0&trc=0&show_legend=yes&show_axis_titles=yes&show_tooltip=yes&id=UNRATE&scale=left&cosd=1948-01-01&coed=2024-06-01&line_color=%234572a7&link_values=false&line_style=solid&mark_type=none&mw=3&lw=2&ost=-99999&oet=99999&mma=0&fml=a&fq=Monthly&fam=avg&fgst=lin&fgsnd=2020-02-01&line_index=1&transformation=lin&vintage_date=2024-07-29&revision_date=2024-07-29&nd=1948-01-01'
Expand Down Expand Up @@ -604,9 +604,9 @@ in the exercises.
For now let's work through one example of downloading and plotting data --- this
time from the World Bank.

The World Bank [collects and organizes data](http://data.worldbank.org/indicator) on a huge range of indicators.
The World Bank [collects and organizes data](https://data.worldbank.org/indicator) on a huge range of indicators.

For example, [here's](http://data.worldbank.org/indicator/GC.DOD.TOTL.GD.ZS/countries) some data on government debt as a ratio to GDP.
For example, [here's](https://data.worldbank.org/indicator/GC.DOD.TOTL.GD.ZS/countries) some data on government debt as a ratio to GDP.

The next code example fetches the data for you and plots time series for the US and Australia

Expand Down
2 changes: 1 addition & 1 deletion lectures/parallelization.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ To get some basis for comparison for the last example, let's try the same
thing with Numba.

In fact there is an easy way to do this, since Numba can also be used to
create custom {ref}`ufuncs <ufuncs>` with the [@vectorize](http://numba.pydata.org/numba-doc/dev/user/vectorize.html) decorator.
create custom {ref}`ufuncs <ufuncs>` with the [@vectorize](https://numba.pydata.org/numba-doc/dev/user/vectorize.html) decorator.

```{code-cell} python3
from numba import vectorize
Expand Down
Loading
Loading