Session 1: Foundations – Why Stats Powers Clinical Insights (Descriptive Stats & Basics)

Quick Review

From Amanda Ategeka, MD's notes: Biostatistics is the core for understanding clinical data patterns (essential for roles in research and healthcare). Think of how stats reveal 'hidden effects' in patient outcomes— you'll do the same for medical insights!

Get Started

Open your ukubona-clinical-lab folder in VS Code. In the terminal, type wsl (if on Windows) to enter Linux mode, then source venv/bin/activate to turn on your lab.

Step 1: Create s1.py

In terminal, type code s1.py. This opens the file in VS Code.

Copy-paste the code below into it, then save (Ctrl+S).

import numpy as np
import matplotlib.pyplot as plt
import os

os.makedirs("plots", exist_ok=True)

# Simulate simple clinical data: patient blood pressure readings
np.random.seed(42)
bp_readings = np.random.normal(120, 15, 100)  # Mean 120, std 15

# Calculate descriptive stats
mean_bp = np.mean(bp_readings)
std_bp = np.std(bp_readings)

fig, ax = plt.subplots()

ax.hist(bp_readings, bins=15, color="blue", alpha=0.7, label="BP Readings")
ax.axvline(mean_bp, color="red", linestyle="--", label=f"Mean: {mean_bp:.2f}")
ax.axvline(mean_bp + std_bp, color="green", linestyle="--", label=f"+1 SD: {std_bp:.2f}")
ax.axvline(mean_bp - std_bp, color="green", linestyle="--", label=f"-1 SD")

ax.set_xlabel("Blood Pressure")
ax.set_ylabel("Frequency")
ax.set_title("Descriptive Stats: Blood Pressure Distribution")
ax.legend()
ax.grid(True)

plt.savefig("plots/session1_bp_dist.png", dpi=200)
plt.close()

print("✅ Plot saved!")
print(f"Mean: {mean_bp:.2f}, Std Dev: {std_bp:.2f}")

Step 2: Run the Code

In terminal, type bash run.sh. This runs your script and saves a plot in plots/session1_bp_dist.png. Open the image—it's a histogram of simulated blood pressure data!

Excite: Play Around

Edit s1.py: Change the mean to 130 (higher average BP) or std to 20 (more variation). Save, run bash run.sh again. See how the distribution changes? That's stats revealing clinical patterns!

Homework

Try different parameters (e.g., larger sample size: 500 readings). Save your best plot. Commit to GitHub: In terminal, git add ., git commit -m "Session 1 descriptive stats", git push.

Math Focus

Descriptive statistics summarize data—like mean for average values and standard deviation for variation. Key for understanding clinical datasets!