Skip to content

thelaycon/saibot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Saibot: A Lua Statistics Library

Saibot is a powerful statistics library for Lua, designed to provide efficient solutions for both simple and complex statistical problems. Inspired by the reliability of Noob Saibot, Saibot aims to simplify statistical analysis on Lua with a focus on descriptive and inferential statistics techniques.

Noob Saibot

Tests

Unit tests are conducted using Factos, a quick and effective unit testing module for Lua.

lua54 factos.lua

Compilation

Saibot leverages C++ libraries, particularly the Boost libraries, for rapid statistical analysis. Ensure the Boost libraries are in the path before compiling the C++ modules. Additionally, include Lua binaries in the working directory before compiling the C++ modules for Saibot. For Windows users, lua54.dll should be present in the compilation directory.

Linux

# Example
g++ -shared -o saistats.so -llua saistats.cpp

Windows

# Example
g++ -shared -o saistats.dll lua54.dll saistats.cpp

Usage

Import Saibot in your Lua or MoonScript code:

Lua

local s = require("saibot")
print(s.saibot.mean({1,2,4}))

MoonScript

s = require "saibot"
print s.saibot.mean {1,2,4}

Descriptive Statistics

Saibot currently supports various descriptive statistics techniques for 2D Lua tables:

mean(arr)       -- Calculates the mean of arr.
median(arr)     -- Calculates the median of arr.
mode(arr)       -- Calculates the mode of arr.
std(arr)        -- Calculates the standard deviation of arr.
var(arr)        -- Calculates the variance of arr.
corr(arr1, arr2)-- Calculates Pearson Moment correlation coefficient of arr1 and arr2.
range(arr)      -- Calculates the range of arr.

Inferential Statistics

Linear Regression

model = s.saibot.LinearRegression(X, Y)
print model\predict(x) -- Predicts the y value for x

One Way ANOVA

model = s.saibot.ANOVA({
  "1": {6.33, 6.26, 6.31, 6.29, 6.40},
  "2": {6.26, 6.36, 6.23, 6.27, 6.19, 6.50, 6.19, 6.22},
  "3": {6.44, 6.38, 6.58, 6.54, 6.56, 6.34, 6.58},
  "4": {6.29, 6.23, 6.19, 6.21}
})
print model\summary()
Source df SS MS F
Between 3 0.2366 0.0789 10.1810
Error 20 0.1549 0.0077
Total 23 0.3915

F Critical (Alpha=0.05) => 3.0984 Conclusion: Reject NULL Hypothesis.

For more ANOVA functions:

model.cal_ssc()
model.cal_sse()
model.cal_sst()
model.cal_msc()
model.cal_mse()
model.f_value()

t-Test for a Single Sample

model = s.saibot.OneSampleTTest({22.6, 27.0, ...}, 25)
model\summary()

t-Test of a single population: mu = 25

Variable N Mean StD T
Weight 20 25.5100 2.1933 1.0399

t-Test for Two Samples

Assuming equal variances:

model = s.saibot.TwoSampleTTest({56, 50, ...}, {59, 54, ...})
model\summary()

Assuming unequal variances:

model = s.saibot.TwoSampleTTest({56, 50, ...}, {59, 54, ...}, false)
model\summary()

For detailed results, including means, standard deviations, t-Stats, and critical values.

References

Ken Black, 2010. Business Statistics For Contemporary Decision Making.

About

A Statistics Library for Lua and Moonscript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published