Add summary statistics helpers and simulation examples#13
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 adds a new LuaSF improvement phase focused on summary statistics helpers and simulation-oriented examples.
The goal is to make LuaSF more useful for teaching, scripting, lightweight data analysis, simulations, and game/modding scenarios while preserving the existing public API and compatibility entry points.
What changed
Added summary statistics helpers
Added the following modern API functions:
mode(array)range(array)iqr(array)percentile(array, p)summary(array)The new
summary(array)helper returns a compact table with common descriptive statistics:{ count = 5, min = 1, max = 5, mean = 3, median = 3, variance = 2.5, stddev = 1.5811 }Added simulation-oriented examples
Added new examples under
examples/:examples/weighted_loot_drop.luaexamples/monte_carlo_pi.luaexamples/poisson_arrivals.luaexamples/binomial_coin_flips.luaexamples/bootstrap_mean.luaThese examples are intended to make LuaSF easier to understand and more useful for practical simulation, teaching, and scripting scenarios.
Added tests
Updated
spec/test_stats.luawith tests for the new summary statistics helpers.The new tests cover:
mode(array)range(array)iqr(array)percentile(array, p)summary(array)Documentation
Updated documentation to include the new helpers and examples:
README.mddocs/api.mdCHANGELOG.mdLuaRocks preparation
Added a new rockspec draft for the next release:
luasf-0.4.0-1.rockspecThis prepares the project for:
Compatibility notes
This PR does not remove or rename existing public functions.
The existing legacy API remains available, including:
The new functions are added as modern API helpers only.
Testing
Tested locally with:
Examples can be run with:
Release target
After this PR is merged into
master, the next release target is:Recommended tag after merge:
git checkout master git pull origin master git tag -a v0.4.0 -m "LuaSF v0.4.0 - Summary Statistics and Simulation Examples" git push origin v0.4.0