Skip to content

Releases: HubertRonald/LuaSF

LuaSF v0.8.0 - Simple Regression Summaries and Student's t Random Variable

10 Jun 03:41
9bde7f4

Choose a tag to compare

LuaSF v0.8.0 - Simple Regression Summaries and Student's t Random Variable

This release expands LuaSF — Lua Statistics Functions with a Student's t random variable generator and formula-based simple linear regression summaries.

It builds on v0.7.0, which introduced probability and combinatorics helpers.

Added

Student's t random variable

Added:

stats.studentTVA(df)
stats.student_t(df)
stats.t_student(df)

The Student's t random variable is generated using:

T = Z / sqrt(V / df)

where:

  • Z is an approximately standard normal random variable.
  • V is a chi-square random variable with df degrees of freedom.
  • df is the number of degrees of freedom.

Example:

local stats = require("luasf")

print(stats.student_t(10))

Formula-based simple linear regression

Added:

stats.simple_linear_regression(x, y)

Example:

local stats = require("luasf")

local x = {1, 2, 3, 4, 5}
local y = {3, 5, 7, 9, 11}

local model = stats.simple_linear_regression(x, y)

print(model.intercept) -- 1
print(model.slope)     -- 2
print(model.r_squared) -- 1

Regression helpers

Added:

stats.predict(model, x)
stats.fitted_values(model)
stats.residuals(model)

predict(model, x) accepts either a single numeric value or an array of numeric values.

Regression summary fields

The regression model includes:

  • slope
  • intercept
  • coefficients
  • r
  • r_squared
  • adjusted_r_squared
  • sst
  • ssr
  • sse
  • mse
  • rmse
  • residual_standard_error
  • standard_error_slope
  • standard_error_intercept
  • t_slope
  • t_intercept
  • fitted_values
  • residuals
  • anova

ANOVA-style summary

The regression result includes an ANOVA-style summary:

model.anova.regression
model.anova.residual
model.anova.total

This includes degrees of freedom, sums of squares, mean squares, and the F statistic when defined.

LuaSF does not compute p-values for the ANOVA summary.

Added files

Added:

src/luasf/regression.lua
spec/test_student_t.lua
spec/test_regression.lua
examples/student_t_distribution.lua
examples/simple_linear_regression.lua
rockspec/luasf-0.8.0-1.rockspec

Updated:

src/luasf.lua
src/luasf/distributions.lua
.github/workflows/ci.yml
.github/workflows/publish-luarocks.yml
README.md
docs/api.md
CHANGELOG.md
CONTRIBUTING.md

Testing

Tested locally with:

lua spec/test_stats.lua
lua spec/test_distributions.lua
lua spec/test_sampling.lua
lua spec/test_bivariate.lua
lua spec/test_shape.lua
lua spec/test_probability.lua
lua spec/test_student_t.lua
lua spec/test_regression.lua

Examples can be run with:

lua examples/dice_simulation.lua
lua examples/normal_quality_control.lua
lua examples/gamma_distribution.lua
lua examples/weighted_loot_drop.lua
lua examples/monte_carlo_pi.lua
lua examples/poisson_arrivals.lua
lua examples/binomial_coin_flips.lua
lua examples/bootstrap_mean.lua
lua examples/covariance_correlation.lua
lua examples/skewness_kurtosis.lua
lua examples/probability_helpers.lua
lua examples/student_t_distribution.lua
lua examples/simple_linear_regression.lua

Compatibility

This release does not remove or rename existing public functions.

Existing users can continue using:

local stats = require("luasf")
local stats = require("LuaSF")
local stats = require("LuaStat")

Legacy LuaSF names remain available.

LuaRocks

This release includes:

rockspec/luasf-0.8.0-1.rockspec

After creating the v0.8.0 tag, the package can be validated and published through the manual LuaRocks workflow using:

rockspec/luasf-0.8.0-1.rockspec

Scope note

LuaSF now includes formula-based simple regression summaries, but it intentionally does not provide:

  • p-values
  • confidence intervals
  • critical values
  • multiple regression
  • non-linear regression
  • optimization-based modeling
  • machine learning workflows
  • model training pipelines

LuaSF remains focused on lightweight statistics, probability, random variables, regression summaries, and simulation utilities.

LuaSF v0.7.0 - Probability Helpers

09 Jun 23:44
2e3c9e8

Choose a tag to compare

LuaSF v0.7.0 - Probability Helpers

This release expands LuaSF — Lua Statistics Functions with lightweight probability and combinatorics helpers.

It builds on v0.6.0, which introduced shape statistics helpers such as skewness and kurtosis.

Added

Probability and combinatorics helpers

Added:

stats.factorial(n)

stats.permutations(n, r)
stats.combinations(n, r)

stats.combinations_with_repetition(n, r)
stats.permutations_with_repetition(n, r)

stats.permutations_without_repetition(n, r)
stats.combinations_without_repetition(n, r)

stats.multiset_permutations(counts)

Also added common aliases:

stats.nPr(n, r)
stats.nCr(n, r)

Helper behavior

Factorial

factorial(n) returns the factorial of a non-negative integer.

local stats = require("luasf")

print(stats.factorial(5)) -- 120

Ordered selections without repetition

permutations(n, r) returns ordered selections without repetition.

local stats = require("luasf")

print(stats.permutations(5, 2)) -- 20

If r is omitted, it returns n!.

print(stats.permutations(5)) -- 120

Ordered selections with repetition

permutations_with_repetition(n, r) returns ordered selections with repetition.

local stats = require("luasf")

print(stats.permutations_with_repetition(10, 4)) -- 10000

This is useful for PIN-like sequences, codes, or ordered choices where values can repeat.

Unordered selections without repetition

combinations(n, r) returns unordered selections without repetition.

local stats = require("luasf")

print(stats.combinations(5, 2)) -- 10

Unordered selections with repetition

combinations_with_repetition(n, r) returns unordered selections with repetition.

local stats = require("luasf")

print(stats.combinations_with_repetition(5, 3)) -- 35

Repeated item arrangements

multiset_permutations(counts) returns distinct arrangements of repeated item groups.

local stats = require("luasf")

print(stats.multiset_permutations({3, 2, 1})) -- 60

This corresponds to:

n! / (a! * b! * c! * ...)

where n is the sum of all repeated counts.

Added files

Added:

spec/test_probability.lua
examples/probability_helpers.lua
rockspec/luasf-0.7.0-1.rockspec

Implemented:

src/luasf/probability.lua

Changed

Updated GitHub Actions workflows to run the new probability helper test and example:

lua spec/test_probability.lua
lua examples/probability_helpers.lua

Updated the LuaRocks publishing workflow default rockspec path to:

rockspec/luasf-0.7.0-1.rockspec

Updated documentation:

README.md
docs/api.md
CHANGELOG.md
CONTRIBUTING.md

Testing

Tested locally with:

lua spec/test_stats.lua
lua spec/test_distributions.lua
lua spec/test_sampling.lua
lua spec/test_bivariate.lua
lua spec/test_shape.lua
lua spec/test_probability.lua

Examples can be run with:

lua examples/dice_simulation.lua
lua examples/normal_quality_control.lua
lua examples/gamma_distribution.lua
lua examples/weighted_loot_drop.lua
lua examples/monte_carlo_pi.lua
lua examples/poisson_arrivals.lua
lua examples/binomial_coin_flips.lua
lua examples/bootstrap_mean.lua
lua examples/covariance_correlation.lua
lua examples/skewness_kurtosis.lua
lua examples/probability_helpers.lua

Compatibility

This release does not remove or rename existing public functions.

Existing users can continue using:

local stats = require("luasf")
local stats = require("LuaSF")
local stats = require("LuaStat")

Legacy LuaSF names remain available.

LuaRocks

This release includes:

rockspec/luasf-0.7.0-1.rockspec

After creating the v0.7.0 tag, the package can be validated and published through the manual LuaRocks workflow using:

rockspec/luasf-0.7.0-1.rockspec

Scope note

Lua numbers may lose precision for very large combinatorial values. LuaSF intentionally remains lightweight and dependency-free, so this release does not add big integer support.

Optimization-based modeling, machine learning workflows, model training pipelines, and non-linear regression remain outside the current scope of LuaSF.

LuaSF v0.6.0 - Shape Statistics

08 Jun 23:48
13253c6

Choose a tag to compare

LuaSF v0.6.0 - Shape Statistics

This release expands LuaSF — Lua Statistics Functions with shape statistics helpers for analyzing the shape of numeric distributions.

It builds on v0.5.0, which introduced the modular internal source layout and bivariate statistics helpers.

Added

Shape statistics helpers

Added new helpers:

stats.central_moment(array, order)
stats.skewness(array)
stats.kurtosis(array)
stats.excess_kurtosis(array)

These functions support lightweight descriptive analysis of distribution shape.

Central moment

central_moment(array, order) calculates the central moment of a numeric array for a given positive integer order.

Example:

local stats = require("luasf")

local values = {1, 2, 3, 4, 5}

print(stats.central_moment(values, 2))

Skewness

skewness(array) returns a moment-based skewness value.

Skewness helps describe whether a distribution is approximately symmetric, right-skewed, or left-skewed.

Example:

local stats = require("luasf")

local values = {1, 2, 3, 4, 10}

print(stats.skewness(values))

Kurtosis and excess kurtosis

kurtosis(array) returns a moment-based kurtosis value.

excess_kurtosis(array) returns:

kurtosis(array) - 3

Example:

local stats = require("luasf")

local values = {1, 2, 3, 4, 5}

print(stats.kurtosis(values))
print(stats.excess_kurtosis(values))

Added files

Added:

src/luasf/shape.lua
spec/test_shape.lua
examples/skewness_kurtosis.lua
rockspec/luasf-0.6.0-1.rockspec

Changed

Updated the public facade:

src/luasf.lua

to expose the new shape statistics helpers through:

local stats = require("luasf")

Updated GitHub Actions workflows to run the new test and example:

lua spec/test_shape.lua
lua examples/skewness_kurtosis.lua

Updated documentation:

README.md
docs/api.md
CHANGELOG.md
CONTRIBUTING.md

Testing

Tested locally with:

lua spec/test_stats.lua
lua spec/test_distributions.lua
lua spec/test_sampling.lua
lua spec/test_bivariate.lua
lua spec/test_shape.lua

Examples can be run with:

lua examples/dice_simulation.lua
lua examples/normal_quality_control.lua
lua examples/gamma_distribution.lua
lua examples/weighted_loot_drop.lua
lua examples/monte_carlo_pi.lua
lua examples/poisson_arrivals.lua
lua examples/binomial_coin_flips.lua
lua examples/bootstrap_mean.lua
lua examples/covariance_correlation.lua
lua examples/skewness_kurtosis.lua

Compatibility

This release does not remove or rename existing public functions.

Existing users can continue using:

local stats = require("luasf")
local stats = require("LuaSF")
local stats = require("LuaStat")

Legacy LuaSF names remain available.

LuaRocks

This release includes:

rockspec/luasf-0.6.0-1.rockspec

After creating the v0.6.0 tag, the package can be validated and published through the manual LuaRocks workflow using:

rockspec/luasf-0.6.0-1.rockspec

Scope note

LuaSF remains focused on lightweight statistics, probability, random variables, sampling, and simulation utilities.

Optimization-based modeling, machine learning workflows, model training pipelines, and non-linear regression are intentionally outside the current scope of LuaSF.

LuaSF v0.5.0 - Modularization and Bivariate Statistics

07 Jun 20:49
5a57786

Choose a tag to compare

LuaSF v0.5.0 - Modularization and Bivariate Statistics

This release reorganizes LuaSF — Lua Statistics Functions into a modular internal source layout and adds bivariate statistics helpers.

It builds on v0.4.0, which introduced summary statistics helpers and simulation-oriented examples.

Added

Bivariate statistics

Added new helpers for paired numeric arrays:

  • covariance(x, y)
  • correlation(x, y)
  • pearson(x, y)

covariance(x, y) uses the sample covariance formula with n - 1.

correlation(x, y) computes Pearson correlation.

pearson(x, y) is provided as a readable alias for Pearson correlation.

Example:

local stats = require("luasf")

local x = {1, 2, 3, 4, 5}
local y = {2, 4, 6, 8, 10}

print(stats.covariance(x, y))
print(stats.correlation(x, y))
print(stats.pearson(x, y))

Bivariate tests

Added:

  • spec/test_bivariate.lua

The new tests cover covariance, positive correlation, negative correlation, alias behavior, and validation errors.

Bivariate example

Added:

  • examples/covariance_correlation.lua

This example demonstrates covariance and correlation using a simple relationship between study hours and exam scores.

Changed

Modular source layout

LuaSF is now internally organized into smaller modules:

  • src/luasf/core.lua
  • src/luasf/descriptive.lua
  • src/luasf/sampling.lua
  • src/luasf/distributions.lua
  • src/luasf/bivariate.lua
  • src/luasf/probability.lua
  • src/luasf/validation.lua
  • src/luasf/rng.lua

The public facade remains:

  • src/luasf.lua

This preserves the main public entry point:

local stats = require("luasf")

Canonical module usage

Tests and examples now use the canonical LuaSF module name:

local stats = require("luasf")

Rockspec organization

Rockspec files were moved into a dedicated directory:

rockspec/

This prepares the project for cleaner future LuaRocks releases.

Documentation

Updated documentation for the modular layout and bivariate statistics:

  • Updated README.md.
  • Updated docs/api.md.
  • Updated CHANGELOG.md.
  • Updated CONTRIBUTING.md.

Testing

Tested locally with:

lua spec/test_stats.lua
lua spec/test_distributions.lua
lua spec/test_sampling.lua
lua spec/test_bivariate.lua

Examples can be run with:

lua examples/dice_simulation.lua
lua examples/normal_quality_control.lua
lua examples/gamma_distribution.lua
lua examples/weighted_loot_drop.lua
lua examples/monte_carlo_pi.lua
lua examples/poisson_arrivals.lua
lua examples/binomial_coin_flips.lua
lua examples/bootstrap_mean.lua
lua examples/covariance_correlation.lua

Compatibility

This release does not remove or rename existing public functions.

Existing users can continue using:

local stats = require("luasf")
local stats = require("LuaSF")
local stats = require("LuaStat")

Legacy function names remain available.

Scope note

LuaSF remains focused on lightweight statistics, probability, random variables, sampling, and simulation utilities.

Optimization-based modeling, machine learning workflows, model training pipelines, and non-linear regression are intentionally outside the current scope of LuaSF.

LuaSF v0.4.0 - Summary Statistics and Simulation Examples

04 Jun 23:29
7d85d57

Choose a tag to compare

LuaSF v0.4.0 - Summary Statistics and Simulation Examples

This release expands LuaSF — Lua Statistics Functions with new summary statistics helpers and simulation-oriented examples.

It builds on the v0.3.0 release, which introduced sampling utilities, deterministic RNG support, and LuaRocks publishing.

Added

Summary statistics helpers

  • Added mode(array).
  • Added range(array).
  • Added iqr(array).
  • Added percentile(array, p).
  • Added 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
}

Simulation-oriented examples

Added new runnable examples:

  • examples/weighted_loot_drop.lua
  • examples/monte_carlo_pi.lua
  • examples/poisson_arrivals.lua
  • examples/binomial_coin_flips.lua
  • examples/bootstrap_mean.lua

These examples make LuaSF easier to use for teaching, scripting, simulation, and lightweight game/modding scenarios.

LuaRocks packaging

  • Added luasf-0.4.0-1.rockspec.

Documentation

Updated documentation for the new helpers and examples:

  • Updated README.md.
  • Updated docs/api.md.
  • Updated CHANGELOG.md.

Testing

Updated tests for the new summary statistics helpers.

Tested locally with:

lua spec/test_stats.lua
lua spec/test_distributions.lua
lua spec/test_sampling.lua

New examples can be run with:

lua examples/weighted_loot_drop.lua
lua examples/monte_carlo_pi.lua
lua examples/poisson_arrivals.lua
lua examples/binomial_coin_flips.lua
lua examples/bootstrap_mean.lua

Compatibility

This release does not remove or rename existing public functions.

Existing users can continue using the compatibility entry points:

local stats = require("LuaSF")
local stats = require("LuaStat")

The LuaRocks entry point remains:

local stats = require("luasf")

Notes

LuaSF remains focused on being a small, pure-Lua statistics and random variable utility library with compatibility, readability, and practical examples as priorities.

LuaSF v0.3.0 - Statistics and Sampling Utilities

04 Jun 15:48
dc2ef31

Choose a tag to compare

LuaSF v0.3.0 - Statistics and Sampling Utilities

This release expands LuaSF — Lua Statistics Functions with new descriptive statistics helpers, sampling utilities, and deterministic simulation support.

It builds on the v0.2.0 compatibility revival and keeps the existing public API stable.

Added

Descriptive statistics

  • Added variance(array).
  • Added median(array).
  • Added min(array).
  • Added max(array).
  • Added quantile(array, q).

Sampling utilities

  • Added choice(array).
  • Added shuffle(array).
  • Added sample(array, n).
  • Added weighted_choice(items, weights).

Deterministic simulation support

  • Added seed(value).
  • Added set_rng(rng_function).
  • Added reset_rng().

Fixed

  • Fixed seed() to use math.randomseed.
  • Improved random helper behavior for sampling utilities.
  • Preserved compatibility with existing LuaSF public function names.

Tests

Added and updated tests for Phase 3 functionality.

Tested locally with:

lua spec/test_stats.lua
lua spec/test_distributions.lua
lua spec/test_sampling.lua

Compatibility

This release keeps the existing legacy LuaSF API available.

Existing users can continue using:

local stats = require("LuaSF")
local stats = require("LuaStat")

The modern implementation module remains available as:

local stats = require("src.luasf")

Notes

This release prepares LuaSF for future CI/CD and LuaRocks publishing work.

LuaSF v0.2.0 - Compatibility Revival

04 Jun 18:24
0b251b5

Choose a tag to compare

LuaSF v0.2.0 - Compatibility Revival

This release revives LuaSF — Lua Statistics Functions with a compatibility-first structure.

Added

  • Added src/luasf.lua as the main implementation module.
  • Added LuaSF.lua as a compatibility entry point.
  • Added LuaStat.lua for legacy README/example compatibility.
  • Added modern aliases for the existing public API.
  • Added Phase 1 tests under spec/.
  • Added runnable examples under examples/.
  • Added initial API documentation under docs/api.md.
  • Added CHANGELOG.md.
  • Added CONTRIBUTING.md.
  • Added draft LuaRocks rockspec: luasf-0.2.0-1.rockspec.

Fixed

  • Fixed compatibility export for nomalVA.
  • Fixed compatibility export for lognoRandVA.
  • Fixed triangular random variable implementation.
  • Updated chi-square random variable behavior to return a non-negative chi-square-style value.
  • Added safer validation for several statistics and random variable functions.

Compatibility

This release preserves the existing public API and keeps legacy names available.

Existing users can continue using:

local stats = require("LuaSF")
local stats = require("LuaStat")