lecture 12
1. Introduction and fundamental statistical concepts
Statistics serves as an essential component in scientific claims due to the inherent uncertainty present in data, stemming from measurement noise and uncontrolled variability like genetics or chance. Relying solely on individual anecdotes (n=1) provides weak evidence because random chance cannot be ruled out as the explanation for observed results. The primary goal of statistics in science is typically to test a hypothesis, determining whether observations merely reflect noise or indicate a genuine trend 2.
1.1 Key fundamental concepts
A strong understanding of core statistical principles is necessary for rigorous scientific practice. These foundational concepts govern how data variability and probability are managed and interpreted.
Key concepts that must be understood include:
-
The law of large numbers.
-
The central limit theorem.
-
Null models and P-values.
-
Identifying different types of "averages".
-
The mean, standard deviation, and standard error 3.
-
Expected value and confidence intervals.
-
Concepts related to probability, such as operations on probabilities and conditional probabilities, including Bayes’ theorem.
-
Understanding independent, identically distributed (i.i.d) variables.
-
Distinguishing between Type I and Type II errors.
Tip: Always adhere to the guiding principle: "Don’t try anything complicated unless it is well justified". Start with simple, standard statistical methods before resorting to complex simulations like Monte Carlo methods, unless necessary to control for important confounders.
1.2 Measures of central tendency and variability
The mean (mu or barx) represents the arithmetic average. The standard deviation (sigma or s) quantifies the spread or dispersion of individual data points around the mean.
The standard error (SE) is crucial as it estimates the precision of a sample statistic (like the mean) as an estimate of the population parameter. It is fundamentally related to the Central Limit Theorem (CLT), which allows for the estimation of the standard error for means or sums.
The standard error of the mean (textSE_barx) is calculated as the sample standard deviation divided by the square root of the sample size n: textSEbarx=fracssqrtn
Confidence intervals rely on these concepts to provide a range of values within which the true population parameter is likely to lie 4.
1.3 Guiding statistical hypothesis testing
Science fundamentally operates by testing hypotheses; statistics provides the framework to assess the likelihood that observed data arose by chance alone. When designing statistical assessments, the choice of test depends critically on the nature of the variables being compared 8.
1.3.1 Comparing variables: Categorical data
When testing for an association between two variables, if both are categorical, one typically generates a contingency table showing the counts (overlaps).
-
For large counts, the Chi-squared test is used if the smaller counts are sampled with replacement.
-
If counts are small, the binomial test is preferred when sampling with replacement.
-
If sampling is done without replacement, Fisher’s exact test should be used.
-
If the counts represent events over time, the Poisson distribution can be used to calculate a P-value 10.
1.3.2 Comparing variables: Continuous or ordinal data
When both variables are continuous or ordinal (e.g., assessing correlation between salt consumption and blood pressure):
-
If the relationship appears approximately linear and the data distribution is close to normal, Pearson’s R (linear correlation) is appropriate.
-
Otherwise, Spearman’s rho (rank-rank correlation) should be attempted.
-
If there are many ties in the data along either axis, Kendall’s Tau is recommended.
-
These correlation methods can be extended to multivariate analysis, modeling one output/dependent variable while controlling for others, such as energy intake in the salt/blood pressure example 11.
1.3.3 Comparing variables: Categorical versus Continuous data
When comparing one categorical variable (group definition) against one continuous variable (measurement) (e.g., comparing performance between student groups):
-
If the continuous data is approximately normally distributed, a t-test is appropriate.
-
If the data is not normal, the Mann-Whitney U-test should be used.
-
If the data is paired (e.g., before/after measurements), use the paired t-test (for normal data) or the Wilcoxon signed rank test 13.
1.4 Parametric versus non-parametric tests and normality
The choice between parametric tests (like the t-test, which assumes normality) and non-parametric tests is critical. For large datasets, standard normality tests will often detect minor, but statistically significant, deviations from perfect normality5.
Tip: If data is not sufficiently normal, this often manifests as strong outliers, which can disproportionately impact P-values when assuming normality. Distributions like power-law distributions (e.g., wealth distribution or network degree) are inherently non-normal and require careful handling.
To decide whether to proceed with a parametric test despite minor deviations:
-
Examine the resulting P-value from the parametric test against the P-value derived from the closest non-parametric alternative.
-
If the P-values differ substantially (much larger or smaller), the non-parametric test is likely the safer choice.
-
Visual inspection (plotting the distribution) is essential to confirm the deviation from normality 14.
A highly versatile test that bypasses strict assumptions about means is the Kolmogorov-Smirnov test, which determines if two distributions were sampled from the same underlying distribution, unlike t-tests or U-tests which focus only on central tendency (mean or median).
1.5 Statistical tools summary and decision making
A variety of statistical tools exist to address different scientific questions, encompassing parametric, non-parametric, and correlation methods.
Commonly Used Tools:
-
Parametric Tests: T-tests (paired and unpaired).
-
Non-parametric Tests: Mann-Whitney U-test, Wilcoxon signed rank test.
-
Categorical Tests: Chi-squared test, Binomial test.
-
Correlation Metrics: Pearson’s R, Spearman’s rho, and Kendall’s tau.
-
Data Transformation/Standardization: Z-normalization and log normalization 6.
-
Advanced/Estimation Methods: Bootstrapping (useful for estimating confidence intervals for statistics like the median) Multivariate linear regression 7.
The decision process for choosing the right tool focuses on variable types and assumptions. However, standard tests should always be prioritized when feasible 16 9.
1.5.1 Classification and Clustering
For identifying patterns or grouping data, statistical methods fall into supervised and unsupervised learning paradigms:
-
Clustering (unsupervised) groups data points based on similarity.
-
Dimensional reduction is used for visual segregation of high-dimensional data.
-
Classification (supervised) requires training on labeled data to predict outcomes (e.g., Naïve Bayes, logistic regression, Support Vector Machines - SVMs) 15.
1.5.2 Decision Outcomes and Visualization
Statistical inference often involves setting a threshold (hatY=0/hatY=1) that classifies observations, leading to potential classification errors.

The outcomes of such a decision process are summarized in a confusion matrix, identifying:
-
True Positive (TP): Correctly identified positive case.
-
False Positive (FP): Type I error, incorrectly identified as positive.
-
True Negative (TN): Correctly identified negative case.
-
False Negative (FN): Type II error, incorrectly identified as negative.
The Receiver Operating Characteristic (ROC) curve plots the True Positive Rate (TPR, or Sensitivity) against the False Positive Rate (FPR, or 1−textSpecificity) across all possible decision thresholds. This helps evaluate the overall trade-off between identifying true effects and incurring false alarms .
2. Hypothesis testing frameworks and null modeling
The core of statistical inference revolves around modeling expectations under the assumption that the hypothesis of interest is false, a concept formalized through the null model and hypothesis testing framework.
2.1 Null model and hypothesis definition
Statistical inference requires establishing a baseline expectation, known as the null model, which represents the scenario where the claim being tested is assumed to be false.
The formal hypotheses are defined as follows:
-
Null Hypothesis (textH_0): States that the observed data or result is consistent with the null model.
-
Alternative Hypothesis (textH_a): States that the observed data or result is inconsistent with the null model.
A statistical test quantifies the evidence against the null hypothesis by reporting the probability of observing the actual data, or data more extreme, assuming the null hypothesis is true. This probability measure is defined as the p-value. Typically, a p-value less than 0.05 is conventionally accepted as sufficient evidence to reject the null hypothesis and thereby accept the alternative hypothesis 17.
2.2 Statistical errors and performance metrics
When making decisions based on statistical tests, two primary types of errors can occur regarding the true state of nature:
-
Type I Error (False Positive): Occurs when the null hypothesis (textH_0) is true, but it is incorrectly rejected.
-
Type II Error (False Negative): Occurs when the null hypothesis (textH_0) is false, but it is incorrectly accepted.
The performance of a decision-making process that relies on classifying observations based on a threshold, such as in hypothesis testing, can be visualized using the concepts derived from a confusion matrix: True Positives (TP), False Positives (FP), True Negatives (TN), and False Negatives (FN). These metrics are fundamentally linked to the probability distributions under the null and alternative conditions, separated by a decision threshold. The Receiver Operating Characteristic (ROC) curve plots the True Positive Rate (TPR) against the False Positive Rate (FPR) to evaluate classifier performance across various thresholds, benchmarking it against a 'no skill' line 19.
2.3 Constructing the null distribution
To calculate the p-value, one must characterize the distribution of the test statistic under the null hypothesis, often referred to as the null distribution. There are two main approaches to establishing this distribution:
-
Standardization: Simplifying the underlying process to fit a known, standard distribution (e.g., Poisson) or relying on established expectations (e.g., using the expected statistic for a Mann-Whitney U-test). This allows for the application of standard statistical tests 20.
-
Simulation: Attempting to simulate the null model as realistically as possible, often by leveraging real data where appropriate, and then repeatedly sampling the statistic of interest (like the mean difference between groups) to empirically estimate the p-value through resampling methods.
Tip: Simulation-based null models offer greater flexibility when the underlying process is complex or does not easily map onto idealized mathematical distributions.
2.4 Data transformation considerations: Logarithms and pseudocounts
When dealing with data that exhibits multiplicative effects or spans several orders of magnitude, log transformations are often employed to normalize the distribution, typically rendering it closer to a Gaussian distribution.
Key considerations for log transformations include:
-
Symmetry in Log-Space: When standard deviation is expressed as a fold-change in log-normal distributions, the resulting error bars appear asymmetrical in absolute terms (e.g., a 33 loss vs. a 50 profit). However, in the log-space—representing the underlying normal distribution—these deviations are symmetrical.
-
Handling Zeros and Negatives: Logarithms are mathematically undefined for zero or negative input values. If the data contains negative numbers, logging is generally inappropriate. If zeros are present, a pseudocount (a small, non-zero value) must be added to every data point before transformation to ensure the mathematical validity of the log operation 21.
2.5 Calculating probabilities using combinatorics
In the absence of any pre-existing knowledge or expected biases (priors), statistical modeling defaults to the maximum entropy principle, which dictates that all possible scenarios should be considered equally likely.
Combinatorics is the mathematical tool used to systematically count the total number of possible scenarios and the subset of those scenarios that include the specific outcome being tested. The probability of that specific outcome occurring is then calculated as the ratio between the number of favorable outcomes and the total number of possible outcomes. This ratio is mathematically equivalent to the partition function in statistical mechanics, where the probability is the fraction of all possibilities that encompass the event of interest 22.
3. Probability theory, conditional probability, and Bayesian methods
This section summarizes the fundamental concepts of probability involving independent events, the crucial role of conditional probability, and the application of Bayes' Theorem, culminating in the structure of Naïve Bayes classifiers.
3.1 Basic Probability Operations for Independent Events
When dealing with probabilities, simple addition is used for events linked by "or" when they are small and independent. However, a more precise calculation is necessary to account for any potential overlap between the events.
-
Probability of A or B (for small independent events): The simple sum p=(AtextorB) can be estimated by adding individual probabilities, such as the probability of dying from a plane crash plus the probability of dying from an automobile crash.
-
Precise "Or" Calculation: To accurately account for potential, albeit small, overlaps between two independent events p_1 and p_2, the formula should be 1−(1−p_1)(1−p_2). This second approach is mandatory when the sum of probabilities exceeds one or two percent.
-
Joint Probability (A and B): For independent events, the joint probability, p=(AtextandB), is found by multiplying their individual probabilities, often relevant when calculating the likelihood of sequential independent occurrences, like surviving two separate car accidents 23.
3.2 Conditional Probability
Conditional probability introduces dependency between events, allowing predictions based on prior knowledge or observed conditions.
Conditional probability is denoted as P(A∣B), representing the probability that event A is true, given that condition B has occurred. These probabilities are essential as they allow different categorical variables to serve as input for predicting another categorical variable. Probabilities calculated without any given condition are referred to as marginal probabilities 24.
The definition of conditional probability can be expressed through the joint probability: p(textblackandroyal)=p(textblack)cdotp(textroyal∣textblack)=p(textroyal)cdotp(textblack∣textroyal) This relationship forms the basis for deriving Bayes' Theorem: P(x∣y)=fracP(x)P(y∣x)P(y) 25.
Tip: Understanding conditional dependence is key; if events are not independent, simply multiplying their probabilities would lead to an incorrect joint probability calculation.
3.3 Bayes' Theorem
Bayes' Theorem provides a formal method for updating the probability of a hypothesis based on new evidence or data.
The general formulation of Bayes' Theorem is: p(x∣textdata)=fracp(x)cdotp(textdata∣x)p(textdata).
In this theorem:
-
p(x) is the prior probability, representing the initial belief or bias regarding event x before observing the data.
-
p(x∣textdata) is the posterior probability, representing the updated belief about x after accounting for the evidence or observations 26.
-
p(textdata∣x) is the likelihood of observing the data given that x is true.
-
p(textdata) is the marginal probability of the data, which acts as a normalizing constant.
This theorem is widely applicable across various fields, such as updating the probability of a disease given observed symptoms: p(textdisease∣textsymptoms)=fracp(textdisease)cdotp(textsymptoms∣textdisease)p(textsymptoms) 27.
Using the Odds Ratio in Bayesian Analysis
Bayes' Theorem can be reformulated using the odds ratio, which conveniently eliminates the marginal probability p(y) from the calculation, simplifying the update process.
The odds ratio calculation is derived from the ratio of the posterior probability to the prior probability: fracp(x∣y)p(x∣negy)=fracp(y∣x)p(x)p(y∣negx)p(negx).
When data is observed, the posterior odds ratio (the left side of the equation) is proportional to the likelihood ratio (the right side), because the initial prior probability p(x) cancels out when considering the ratio of p(x∣y) to p(x∣negy). This simplification is vital in classification contexts, as the denominator term p(textdata) becomes irrelevant when comparing the odds of two competing hypotheses 29.
3.4 Naïve Bayes Classifier
The Naïve Bayes classifier employs a strong, simplifying assumption about the relationship between input features to leverage Bayes' Theorem efficiently for classification tasks.
The core principle of Naïve Bayes is the assumption that all features (x_1,x_2,x_3,dots) are conditionally independent given the class label (y). This assumption allows the joint conditional probability to be factorized into a product of individual conditional probabilities: p(x_1,x_2,x_3∣y)=p(x_1∣y)p(x_2∣y)p(x_3∣y).

This factorization is the defining "naïve" aspect of the classifier, as it dramatically simplifies the calculation required for determining the posterior odds ratio, which is often the goal in classification (e.g., comparing the odds of disease given symptoms): textOR=fracp(textdisease∣textsymptoms)p(textnotdisease∣textsymptoms).
Because the data (symptoms) are given during classification, their marginal probability p(textdata) becomes constant across the comparison, rendering it irrelevant when calculating the odds ratio.
Independence Assumption and Model Comparison
The Naïve Bayes assumption means that the likelihood ratios are multiplied directly without checking for redundancy or interaction effects among the features.
In contrast, models designed to control for redundancy fit all parameters simultaneously:
-
Multivariate linear regression achieves control by fitting all coefficients at once.
-
Logistic regression is considered the equivalent of Naïve Bayes but accounts for parameter redundancies by fitting all necessary parameters concurrently.
-
Cox proportional hazard modeling also fits all parameters simultaneously.
The difference in modeling perspective is visualized by contrasting models that assume independence versus those that fit parameters together to minimize errors across all inputs simultaneously, as seen in multivariate model fitting where prediction errors are calculated across all features against the real output 32.
Example: In a Naïve Bayes model predicting spam, the presence of the word "Viagra" and the word "Offer" are treated as completely independent events given that the email _is spam, even if they rarely appear without each other in real-world spam emails 30 31.
Common mistakes to avoid
-
Review all topics thoroughly before exams
-
Pay attention to formulas and key definitions
-
Practice with examples provided in each section
-
Don't memorize without understanding the underlying concepts
© 2026 Maeve. All rights reserved. This content is protected by copyright.