Analysis of Environmental and Biological Datasets

Husile Bai, Vanderbilt University, Department of Earth and Environmental Sciences
Author Profile
Initial Publication Date: October 6, 2026
DOI | Cite this

Summary

This activity is a sequence of MATLAB-based environmental statistics exercises that develops students' computational and statistical reasoning through analysis of environmental and biological datasets. Students use MATLAB to explore probability and conditional probability, descriptive statistics, sampling distributions, hypothesis testing, linear and multiple regression, confidence intervals, bootstrap resampling, and permutation tests. Activities emphasize implementing statistical calculations computationally, interpreting results in scientific terms, and connecting mathematical concepts with real data. Students progress from foundational probability and data description to statistical inference and regression, gaining experience with reproducible computational analysis and quantitative reasoning.
Keywords: MATLAB, environmental statistics, probability, descriptive statistics, data analysis, sampling distributions, hypothesis testing, t-tests, regression, bootstrap, permutation tests, computational thinking, environmental data, statistical inference.

Share your modifications and improvements to this activity through the Community Contribution Tool »

Learning Goals

The primary goal of this activity sequence is for students to develop a conceptual and computational understanding of environmental statistics. Students learn to apply probability, descriptive statistics, sampling distributions, hypothesis testing, correlation and regression, confidence intervals, bootstrap resampling, and permutation testing to environmental and biological data.
MATLAB is used as both a computational and learning tool. Students import and manipulate datasets, implement statistical equations, conduct simulations and resampling experiments, visualize data, and evaluate statistical models. In several exercises, students construct calculations from fundamental operations rather than relying on canned statistical functions. This helps connect the mathematical formulation of a statistical method to its computational implementation and interpretation.
The activities develop higher-order quantitative skills, including computational thinking, data analysis, model development, hypothesis formulation and testing, interpretation of uncertainty, and evaluation of statistical evidence. Students are asked not only to obtain numerical answers but also to explain what those results mean scientifically, compare alternative statistical approaches, and assess whether assumptions and models are appropriate for the data.
Students also develop scientific communication and reproducible-analysis skills by documenting their MATLAB code, showing their computational work, producing appropriate graphical and numerical results, and explaining conclusions in written form. The overall goal is for students to move from applying statistical formulas toward using computation and statistical reasoning together to investigate scientific questions.

Context for Use

This activity is designed for an upper-level undergraduate or graduate course in environmental science, atmospheric science, geoscience, or a related quantitative discipline. It is organized as a sequence of laboratory and problem-set activities distributed across an environmental statistics course rather than as a single class exercise. Individual activities can generally be completed in one or several class/lab periods, with additional time for independent analysis and interpretation.
Students should have basic MATLAB experience before beginning, including working with vectors and matrices, importing data, indexing and logical operations, writing scripts, using loops, performing basic calculations, and creating plots. As the activities progress, students gain experience using MATLAB for statistical computation, simulation, visualization, and resampling. The assignments intentionally ask students to implement some statistical calculations directly rather than relying exclusively on built-in statistical functions.
Students should have introductory knowledge of probability, algebra, and basic statistics, while more advanced concepts such as sampling distributions, hypothesis testing, regression, bootstrap methods, and permutation tests can be introduced as the sequence progresses.
The activities are situated throughout an Environmental Statistics course, with MATLAB serving as the computational environment connecting statistical theory to environmental and biological datasets. Individual modules are largely self-contained, so instructors can use the complete sequence or select particular activities to complement their own courses. The datasets and statistical questions could also be replaced with discipline-specific examples, making the activities adaptable to other STEM courses that teach statistics through computation.

Description and Teaching Materials

This activity consists of a sequence of MATLAB-based environmental statistics assignments and laboratory exercises that progressively move students from probability and descriptive statistics through statistical inference, regression, and computational resampling. Students receive an assignment describing the statistical questions to investigate, an accompanying dataset when needed, and instructions to show their work and provide the associated MATLAB code. For example, the probability activity uses daily precipitation observations from three SNOTEL sites and asks students to calculate compound and conditional probabilities and interpret them in an environmental context. 6040_assg_01_v2
The sequence includes activities on probability and conditional probability; descriptive statistics and correlation; sampling distributions; hypothesis testing; linear and multiple regression; confidence intervals; bootstrap resampling; and permutation testing. A sampling-distribution laboratory, for example, has students generate a large synthetic population, repeatedly draw random samples, calculate sample means, and investigate how the variance of the sample mean changes with sample size and population variance. 6040_lab_18Feb2021 Students subsequently extend this computational experiment across multiple sample sizes and compare the empirical results with the theoretical sampling variance. 6040_assg_03b
MATLAB is central to the activities. Students use it to import and subset data, perform matrix and vector calculations, write scripts, simulate random samples, calculate statistical quantities, visualize results, fit statistical models, and implement resampling procedures. Some assignments deliberately restrict the use of canned statistical functions. For example, students construct t tests from the underlying calculations rather than using ttest or ttest2, while still using distribution functions for CDF and inverse-CDF calculations. 6040_assg_03b Similarly, the regression activity initially requires students to calculate least-squares coefficients using elementary operations and summation before progressing to matrix-based regression. 6040_assg_04 This approach makes the connection between statistical theory, mathematical equations, and their computational implementation explicit.
The activities could be implemented in other computational environments such as Python or R. MATLAB is used here because it provides a consistent numerical computing environment in which students can move naturally between mathematical notation, vector and matrix operations, simulation, visualization, and statistical analysis. It also allows students to implement statistical methods directly before comparing their calculations with higher-level built-in functions.
Teaching materials provided with the activity include:
- Combined Environmental Statistics Activity Packet – the primary student-facing document containing the sequence of MATLAB activities and assignments.
- SNOTEL precipitation dataset (snotel.csv) – daily precipitation data used for the probability and conditional-probability exercises; the source assignment identifies columns for year, month, day, and precipitation at Brighton, Ben Lomond Peak, and Snowbird. 6040_assg_01
- Fish dataset (fish.txt) – a biological dataset used for regression, multiple regression, confidence-interval, bootstrap, and permutation-test activities. 6040_assg_04
- Perch dataset (perch.txt) – a compact two-variable dataset that can be used for introductory descriptive statistics, visualization, covariance, correlation, and exploration of relationships between variables.
- Descriptive Statistics notes – supporting instructional material covering quantiles, measures of location and spread, anomalies and z-scores, covariance, Pearson correlation, and rank correlation. 02_descriptive 02_descriptive
The materials are modular: instructors may use the complete progression in an environmental statistics course or select individual activities to support particular statistical topics. Datasets can also be replaced with locally relevant or discipline-specific data while retaining the computational structure of the exercises.
Combined Environmental Statistics Activity Packet (Microsoft Word 2007 (.docx) 44kB Sep30 26)



Teaching Notes and Tips

Students benefit from beginning each activity with a brief discussion of the statistical concept and its MATLAB implementation before working independently. Instructors should encourage students to separate the statistical reasoning from the coding: first identify the quantities, hypotheses, or model required, and then translate those steps into MATLAB operations.
A central feature of these activities is that students sometimes implement statistical calculations directly rather than relying immediately on built-in functions. For example, the inferential-statistics assignment asks students to construct t tests without ttest or ttest2, although built-in functions can be used afterward to verify results. 6040_assg_03b Similarly, the regression activity initially restricts students to elementary operations and summation when calculating least-squares coefficients. 6040_assg_04 Instructors should reinforce that these restrictions are intended to help students understand what the statistical functions are actually computing.
Common areas requiring reinforcement include logical indexing, distinguishing population and sample quantities, interpreting conditional probabilities, selecting appropriate degrees of freedom and one- versus two-tailed tests, and distinguishing statistical significance from scientific interpretation. Students may also need guidance with random sampling and resampling, particularly the difference between sampling with replacement for bootstrap analysis and rearranging/grouping observations for permutation tests.
For the sampling-distribution activity, encourage students to experiment with different sample sizes and compare their simulations with theoretical expectations rather than treating simulation as simply a way to obtain a numerical answer. The laboratory specifically asks students to examine how the distribution and variance of sample means change with sample size and population variance. 6040_lab_18Feb2021
Plots and intermediate calculations are useful debugging tools. Students should be encouraged to inspect their data visually, check array dimensions and indexing, and test scripts on small examples before running larger simulations such as thousands of bootstrap samples.
Finally, require students to accompany numerical results with a short scientific interpretation. The goal is not simply to produce correct MATLAB output, but to connect computation, statistical reasoning, and the environmental or biological question represented by the data.

Assessment

Students are assessed through their MATLAB code, numerical and graphical results, statistical reasoning, and written interpretation of findings. Successful completion requires students to implement the requested statistical methods correctly, document their computational work, and demonstrate that they understand the connection between the calculations and the underlying statistical concepts.
Assessment emphasizes both process and interpretation, rather than numerical answers alone. Students are expected to select and apply appropriate probability and statistical methods, verify calculations when appropriate, interpret uncertainty and hypothesis-test results, evaluate regression models, and explain the scientific meaning of their results. Several assignments explicitly require students to show their work and provide associated computer code. 6040_assg_01_v2
For computational activities involving simulation, bootstrap resampling, or permutation testing, students are also evaluated on whether their code correctly implements the procedure and whether they can interpret the resulting sampling or null distribution. For regression and hypothesis-testing exercises, assessment includes appropriate test statistics, critical values or p-values, model coefficients, and conclusions supported by quantitative evidence. 6040_assg_04
A student has met the goals of the activity when they can translate a statistical question into a reproducible MATLAB analysis, obtain and validate appropriate results, and communicate what those results mean in a scientific context.

References and Resources

The following resources support the datasets and MATLAB methods used in the activities:
- MathWorks — Statistics and Machine Learning Toolbox Documentation
https://www.mathworks.com/help/stats/
Reference documentation for statistical analysis in MATLAB, including descriptive statistics, probability distributions, hypothesis testing, regression, and related functions. This is useful for students as they progress from manually implementing statistical calculations to using and verifying results with MATLAB functions. MathWorks
- MathWorks — Student's t Distribution (tcdf and tinv)
MATLAB tcdf documentation
MATLAB tinv documentation
Documentation for calculating cumulative probabilities and critical values from Student's t distribution. These functions support the hypothesis-testing and confidence-interval activities, in which students calculate test statistics themselves and use MATLAB for distribution probabilities and critical values. MathWorks
- MathWorks — Bootstrap Sampling (bootstrp)
https://www.mathworks.com/help/stats/bootstrp.html
Documentation describing bootstrap sampling with replacement in MATLAB. This provides a useful reference for the resampling concepts explored in the regression activity, although students can also implement the resampling procedure directly to understand the underlying algorithm. MathWorks
- MathWorks — Linear Regression (fitlm)
https://www.mathworks.com/help/stats/fitlm.html
Documentation for fitting and examining linear regression models in MATLAB. It can be used to verify student calculations after students have implemented least-squares regression from the underlying equations. MathWorks
- USDA Natural Resources Conservation Service — SNOTEL Network
NRCS Water and Climate Data Collection and Stewardship
Background information on the Snow Telemetry (SNOTEL) network used to monitor snowpack, precipitation, temperature, and other climatic conditions in high-elevation watersheds in the western United States. This provides scientific context for the precipitation data used in the probability activities.