the sum of [ 2 3 5 7 11 13 17 19 23 29] is 129
Introduction to the Course
Welcome! I’m glad you’re here.
This is Psychology 9040: Scientific Computing, for FW25, Jan-Apr 2026.
Bring your computer to class! We will be writing code.
Course website: https://gribblelab.org/9040
Course Goals
In this one-semester graduate course you will learn skills in scientific computing—tools and techniques that you can use in your own research. You will learn to program using Python, which is a high-level programming language with many libraries that provide a rich ecosystem for scientific computing. If you want to use a different language in the course you are welcome to but I will focus on Python in class. Having said that, as much as I can I will teach concepts in a way that are language-agnostic.
The course is designed to achieve three primary goals:
- You will learn to write code in a high-level language (Python)
- You will learn to think computationally and algorithmically about data analysis
- You will learn some common data analysis techniques, which will give you a foundation from which to learn more complex scientific computing skills to suit your own research goals
Topics
In the first part of the course you will learn how to write code. The topics we will cover are common to any high-level language including Python, MATLAB, R, Javascript, C, Julia, Go, Swift, etc. All high level languages have things like numbers, strings, arrays, loops, if-statements. Languages differ in their syntax, in the names of common functions, and sometimes in some other subtle ways (e.g. passing by reference vs passing by value) but otherwise, all high-level languages basically work in the same way. Learning these fundamental concepts of high-level programming languages using one language will enable you to learn other languages as well in the future.
The other aspect of programming that you will learn is how to think algorithmically about solving problems and completing tasks with computers. In general there are two reasons to use a computer to perform a given task, (1) because the task would take too long by hand (e.g. churning through processing a huge amount of data), and (2) because the computer can do something clever that you cannot do yourself (e.g. applying complex algorithms to a dataset).
In learning the fundamentals of high-level programming languages (data types, loops, conditionals, etc) we will sometimes practice writing code to solve little toy problems. This will start to teach you how to think algorithmically. Think about it like learning to play a musical instrument. You don’t start by learining to play Beethoven. You start learning basic skills by playing scales, arpeggios, different key signatures, etc. Building up basic skills using toy problems is a convenient path towards using coding skills to solve real-world programming problems in the context of your own thesis research.
We will also practice and learn by using code to answer questions about data. Some of the data will be from real experiments and some will be fictitious. The goal will be to answer a series of questions by writing code that performs operations on the data (reorganization, summarising, counting, calculating, processing, plotting, etc) and writing a short summary of your findings. This mimics how you will be using your coding skills in your own research going forward.
Fundamentals of Coding
- digital representation of data
- basic data types, operators, & expressions
- control flow & conditionals
- functions
- complex data types
- file input & output
- graphical displays of data
- object oriented programming (OOP)
Reproducibility & Replicability
- Python venvs (virtual environments)
- Code versioning using Git & GitHub
- organization of code and data
- data analysis workflow
Topics in Data Analysis
- sampling, signal processing, & filtering data
- statistical tests (parametric vs resampling/boostrapping/randomization)
- fitting models to data
- simulating dynamical systems
By building upon the foundational knowledge and skills you have acquired in this course, you will be able to learn other techniques in programming and in data analysis as your scientific research progresses.
MacOS, Windows, or Linux?
Yes.
Sort of.
For this course, we will be working extensively with the command line and VS Code, which function similarly across all three major operating system, so you can use whichever OS you prefer or already have. Linux is the gold standard in scientific computing environments; most computing clusters, cloud servers, and neuroimaging pipelines run on it, so familiarity with its command line is invaluable. MacOS runs on a Unix variant under the hood, meaning the terminal experience is nearly identical, making it a convenient choice for researchers who want a polished laptop environment that translates well to work on Linux/Unix environments such as servers and clusters.
Windows has historically been the odd one out for scientific computing, but the Windows Subsystem for Linux (WSL) has changed this dramatically. The WSL lets you run a full Linux environment inside Windows, giving you access to the same tools and workflows. For our purposes, the key is having a working terminal and Python environment.
So if you are already using Unix/Linux, good news, you are all set, just some configuration things and some package installs and your computing environment will be ready for a modern course in coding / scientific computing.
If you are using MacOS, also good news, you may not know it but MacOS is based on a Unix variant, so with some small configuration things and some package installs, you will also be ready.
If you are using Windows, it will be ok. Something we will cover in this course is learning to use the terminal, learning about file systems, files, directories, and so on. On Linux/Unix and on MacOS (which is based on Unix) this is straightforward and you won’t need to do anything particularly special. On Windows however you will need to do some initial setup to install something called the Windows Subsystem for Linux (WSL). This will enable you to launch a Linux session within Windows, and follow along in the course with everyone else. It’s not such a big deal. Instructions are below.
PS: Personally I am most familiar with MacOS and Unix/Linux. I am quite unfamiliar with Windows.
Unix/Linux
Open up a terminal and (assuming Ubuntu Linux) update the system:
sudo apt update
sudo apt upgrade -y
and then install some necessary tools:
sudo apt install -y build-essential git curl
and then install the uv tool:
curl -LsSf https://astral.sh/uv/install.sh | sh
close your Terminal.
and then download Visual Studio Code and install it.
MacOS
Open up a terminal and install some necessary build tools:
xcode-select --install
Install the Homebrew package manager:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then close the terminal and open up a new one, and install some other necessary tools:
brew install git
Then install the uv tool:
curl -LsSf https://astral.sh/uv/install.sh | sh
close your Terminal.
and then download Visual Studio Code and install it.
If you want a nicer looking Terminal than the one that ships with MacOS you can try one of these:
Windows
First update Windows, I think you can access this by going to the Start menu and typing “update” and one of the options will be a system update.
Next, open up Powershell (again, go to the Start menu and type Powershell to access it) and type:
wsl --install
When it is done, reboot your computer.
Open up Powershell again and type:
wsl.exe --install Ubuntu
It will eventually ask you for a default Unix user account and password.
Close Powershell and any other junky windows that Windows may have opened.
Open Powershell and check to see which version of WSL is running:
wsl -l -v
if it shows version 1 instead of version 2 then switch:
wsl --set-version Ubuntu 2
Close Powershell and reboot the computer.
From your Start menu select “Ubuntu” and it should launch a terminal, which is now, running Ubuntu linux.
Now go through the steps above in the Unix/Linux section.
Check your setup
Create a new folder somewhere on your computer’s file system and name it Psych_9040, and then navigate inside of it.
Open a new terminal:
mkdir Psych_9040
cd Psych_9040
Use uv to install a python environment
uv init --python 3.12
Add the numpy package
uv add numpy
Create a new empty file:
touch hello.py
and add some Python lines of code to it:
echo "import numpy as np" >> hello.py
echo "x = np.array ([2, 3, 5, 7, 11, 13, 17, 19, 23, 29])" >> hello.py
echo "y = np.sum(x)" >> hello.py
echo "print(f\"the sum of {x} is {y}\")" >> hello.py
and test the code:
uv run python hello.py
and you should see this output:
Git/GitHub
We will be covering code versioning using Git and GitHub, so you should sign up for a (free) GitHub account.