Adding Future Homework Modules
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The project is structured to facilitate the addition of new homework modules (e.g., hw1, hw2) by utilizing a standardized pattern for data ingestion and statistical analysis. Each module typically resides in its own directory and contains a Python script that processes specific data files to generate descriptive statistics.
The architecture relies on the numpy and statistics libraries to perform calculations on numeric datasets stored in external text or CSV files. By following the established pattern of modular functions for file handling and computation, developers can easily extend the repository with new assignments.
Sources: hw1/p1.py:1-6, hw1/CHOLESTEROL.txt:1-28
Data Ingestion Architecture
New homework modules must implement a mechanism to read data from external sources. The current implementation uses a global list to store numeric values and a dedicated function to parse text files line by line.
File Parsing Logic
The system reads text files, strips whitespace, and attempts to cast each line to a float. It includes basic error handling to skip non-numeric values, ensuring the stability of the computation phase.
The diagram shows the logic used to populate the internal data structure from a source file.
Sources: hw1/p1.py:6-16
Statistical Computation Engine
The core of each homework module is the computation engine, which calculates various statistical metrics. Future modules should implement a wrapper function (e.g., compute_file) that orchestrates the data loading and the subsequent calculations.
Metrics and Implementation
The following table summarizes the metrics currently calculated in the homework modules:
| Metric | Library/Method | Description |
|---|---|---|
| Mean | np.mean(data) | Arithmetic average of the dataset. |
| Median | np.median(data) | Middle value of the dataset. |
| Mode | statistics.mode(data) | Most frequent value in the dataset. |
| Range | np.ptp(data) | Peak-to-peak (Maximum - Minimum) value. |
| Standard Deviation | np.std(data) | Measure of the amount of variation. |
| Variance | np.var(data) | Square of the standard deviation. |
| 1st CV | 3*(mean - median) / std | Skewness coefficient based on mean, median, and std. |
| 2nd CV | Custom List Comp | Skewness coefficient based on the 3rd moment. |
Sources: hw1/p1.py:18-53
Integration Workflow
When adding a new homework module, the following workflow should be followed to ensure consistency with the existing codebase:
- Directory Creation: Create a new directory (e.g.,
hw2/). - Data Provisioning: Place relevant data files (e.g.,
WEIGHT.txt,CHOLESTEROL.txt) within the directory. - Script Implementation: Create a Python script (
p1.py) that imports necessary libraries and defines the data processing functions. - Execution: Call the computation function with the target file path.
The sequence diagram illustrates the interaction between the script, the data source, and the mathematical libraries.
Sources: hw1/p1.py:18-55, hw1/WEIGHT.txt:1-12
Summary
Adding future homework modules to the BME533 repository involves creating a structured directory containing both the raw data and a processing script. By adhering to the numpy and statistics based framework demonstrated in hw1, the project maintains a consistent approach to biometric data analysis and statistical reporting.
Sources: hw1/p1.py:1-55