Welcome to the first data simulation lab for Psych 201a! This lab introduces you to statistical distributions and data simulation techniques commonly used in psychological research.
- Understand distributions: Learn how normal, binomial, and lognormal distributions describe behavioral data (accuracy, RTs, individual variability)
- Practice simulation: Generate and visualize synthetic datasets using tidyverse functions
- Reproducible reports: Learn how to write reproducible lab reports with inline statistics in Quarto
Make sure you have the following installed:
- Homebrew (macOS package manager)
- Git and GitHub CLI
- Pixi (package manager for R and Python)
- Go to https://github.com/psyc-201/data_simulation_lab_1
- Click the "Fork" button in the top-right corner
- This creates a copy of the repository under your own GitHub account
git clone https://github.com/YOUR_USERNAME/data_simulation_lab_1.git
cd data_simulation_lab_1Replace YOUR_USERNAME with your actual GitHub username.
pixi installpixi run setup- Open VS Code and use the account icon to login to your GitHub account
- Open the folder you cloned: File > Open
- Accept any pop-ups to configure VS Code with necessary extensions
- R Console:
pixi run r - Live Preview:
pixi run render - Preview specific file:
pixi run preview filename.qmd
This lab includes multiple versions to support different learning styles:
| File | Description |
|---|---|
code/index.qmd |
Introduction and overview |
code/distributions-lab.qmd |
Complete lab with full instructions |
code/distributions-lab-intermediate.qmd |
Scaffolded version with placeholders to fill in |
code/distributions-lab-withsolutions.qmd |
Complete solutions for reference |
code/distributions_lab.py |
Python implementation using pandas and matplotlib |
code/distributions_lab_withsolutions.py |
Python solutions |
- Open
code/distributions-lab-intermediate.qmdin VS Code - Use the command palette (
cmd+shift+p) to search: "Terminal: Create New Terminal" - Start the R console:
pixi run r - Fill in the
___placeholders in the intermediate version - Use "Run cell" buttons to execute code chunks
- Open
code/distributions_lab.pyin VS Code - Use the command palette to search: "Jupyter: Create Interactive Window"
- Use "Run cell" buttons to execute code
- Convert
.qmdto.ipynb:pixi run convert filename.qmd - Convert
.ipynbto.qmd:pixi run convert filename.ipynb
Use these commands to manage packages (they auto-update pixi.toml):
- Python:
pixi add packageorpixi add --pypi package - R:
pixi add r-package - Remove:
pixi remove packageorpixi remove r-package
- Normal distributions: Simulating continuous data
- Binomial distributions: Modeling accuracy and binary outcomes
- Lognormal distributions: Simulating reaction times
- Multi-participant experiments: Individual differences and group-level analysis
- Data visualization: Creating publication-ready plots
- R not found: Make sure you're using
pixi run rnot justr - Package not found: Use
pixi addinstead ofinstall.packages()orpip install - Render errors: The intermediate version cannot be rendered due to placeholder syntax - fill in the
___placeholders first
If anything goes wrong, you can safely reset:
rm -rf .pixi/ pixi.lock
pixi install
pixi run setup- Quarto Documentation
- Tidyverse Documentation
- Pandas Documentation
- Matplotlib Documentation
- Pixi Documentation
Always prefer using pixi add and pixi remove instead of install.packages() in R or pip install / conda install in Python
This will save you from many unexpected headaches and ensure reproducible environments!
Happy coding! 🎉