Modularize LuaSF and add bivariate statistics#16
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR prepares LuaSF for
v0.5.0by modularizing the internal source layout and adding bivariate statistics helpers.The goal is to make the codebase easier to maintain and extend while preserving the existing public API, legacy function names, compatibility entry points, and LuaRocks usage.
What changed
Modular source layout
Refactored the previous single-file implementation into smaller internal modules under
src/luasf/:src/luasf/core.luasrc/luasf/descriptive.luasrc/luasf/sampling.luasrc/luasf/distributions.luasrc/luasf/bivariate.luasrc/luasf/probability.luasrc/luasf/validation.luasrc/luasf/rng.luaThe public facade remains:
src/luasf.luaThis keeps the public usage stable:
Added bivariate statistics
Added the following modern API helpers:
covariance(x, y)correlation(x, y)pearson(x, y)covariance(x, y)uses the sample covariance formula withn - 1.correlation(x, y)andpearson(x, y)provide Pearson correlation.Added tests
Added bivariate statistics tests:
spec/test_bivariate.luaThe tests cover:
pearson(x, y)aliasAdded example
Added a new example:
examples/covariance_correlation.luaThis demonstrates covariance and correlation using a simple relationship between study hours and exam scores.
Updated CI
Updated CI to include:
Rockspec organization
Moved rockspec files into a dedicated
rockspec/directory.This keeps package metadata better organized as LuaSF continues to release new versions.
Documentation
Updated documentation for the modular layout and bivariate statistics:
README.mddocs/api.mdCHANGELOG.mdCONTRIBUTING.mdCompatibility notes
This PR does not remove or rename existing public functions.
Legacy API names remain available, including:
Compatibility entry points also remain available:
Testing
Tested locally with:
Examples can be run with:
Release target
This PR prepares LuaSF for:
Scope note
This release keeps LuaSF focused on lightweight statistics, probability, random variables, sampling, and simulation utilities.
Machine learning workflows, optimization-based modeling, non-linear regression, and training pipelines remain outside the current scope of LuaSF.