Tips and Tricks

We are mostly using Julia in this class, though we will also show examples in Python. Julia comes with its own package manager; for Python, I recommend using miniconda, which is a minimial set of packages based around the conda package manager.

The repository containing these pages / chapters / notebooks is, itself, a Julia package. Download or clone the repo, and then you can “enter” the environment by starting julia and then entering:

> ]
Pkg> activate PATH_TO_REPO_TOP_DIR

or (without entering “package mode”):

> using Pkg
> Pkg.activate("path/to/repo/top/dir")

The @__DIR__ macro and the joinpath function are your friends here; @__DIR__ expands to whatever directory contains the current source file, and joinpath will let you “move around” from there to the package top-level directory.

The first time you activate the Julia environment for this class, you will need to download and build all the relevant packages:

> using Pkg
> Pkg.activate("path/to/repo/dir")
> Pkg.instantiate()

Once this has been done once you don’t need to do it again; you can update the packages in the environment (subject to any version constraints supplied in the Package.toml file in the top-level of the reop) by issuing

> using Pkg
> Pkg.activate("path/to/repo/dir")
> Pkg.update()

(if you are doing this all in one session, you only need to activate the environment once; subsequent commands will be interpreted in the context of the active environment).

On the Python side, you can create a Conda environment for the entire class:

conda create -n phy688 python=3 jupyterlab numpy scipy matplotlib pip

and then activate it

conda activate phy688

after which you can play around.

Of course, you only need to use Julia or Python if you want to execute the codes in the class notebooks; feel free to use your own favorite language and modelling languages. (I love learning new languages, too, so if you find something I don’t know about already, I’ll be extra happy.) Beware, though: the course moves fast, and we’re mostly interested in the conceptual issues around our statistical analyses, not the computational ones; so if you’re using a language / library stack where you have to start by writing your own MCMC kernels, you’ll probably not be able to keep up!