Skip to content
Switch branches/tags
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Introduction to Statistical Mechanics in Python 3

Introduction to Statistical Mechanics in python 3.x, using jupyter notebooks. This repository is part of the University of Milano course Introduzione alla Fisica Statistica.

We will go through the notebooks of each seassion together. Each notebook explores a different topic and proposes some exercises for you to do. There will be some time for you to try the exercises, and we will solve some of them together. You are expected then to solve the rest of exercises on your own.

Please send your solutions no later than the indicated date using the labonline platform.

Notebook Deadline
3-Random-Walks.ipynb 2020-10-30, 23:59h
4-Ising-Model.ipynb 2020-12-14, 23:59h

Installing jupyter on your computer

To follow these lectures, you need a modern installation of python, together with jupyter, numpy, matplotlib and some other standard python libraries. The simplest way to install all these packages without interfeering with your current python installation is the Anaconda distribution. Choose python 3.x and your OS, download, install, and you should be good to go.

Using an online environment

Alternatively, if you cannot install jupyter on your computer, you can use the mybinder online environment, which is basically an online version of the repository. Notice that the code will not run on your computer, and that you will loose your work if you close the browser window. To launch the mybinder page for the course, click here!


After completing a notebook, remember to download it to your local computer!

Getting started

These instructions should work for linux & mac users. Windows users might not be able to execute the which command, and might need to install the git command beforehand. In case of technical difficulties, please use the binder online environment.

Open a terminal and cd to a directory of your choice

$ cd Documents

Check that you have correctly installed Anaconda's python.

$ which python

Clone this repository

$ git clone

A new folder called stat-mech-python-course will be created. Enter it and start jupyter by typing jupyter lab

$ cd stat-mech-python-course
$ jupyter lab

A browser window/tab pointing to localhost:8888 will open automatically. Open the notebooks folder, then open the first notebook by double-clicking 1-Generating-Random-Numbers.ipynb. You are ready to go!

Searching for help online

Being able to re-use someone else's code is as important as being able to write your own. You are not supposed to figure out everything by yourself, so googling how to X in python is just fine. In addition, some useful resources are:


You can reach me at if you need any help. Given the current COVID situation, it is unlikely that you will find me in my office, but you can send me an email to book a skype/zoom meeting if you want to discuss some of the exercises.


Introducion to Statistical Mechanics in Python



No releases published


No packages published