TecKnow / muster-tools

A package for assigning players to tables at multi-table, walk-in gaming events.
GNU General Public License v3.0
0 stars 0 forks source link

Perform a chi-squared test against the shuffle function #17

Open TecKnow opened 3 years ago

TecKnow commented 3 years ago

As noted in #10, the system currently uses a Fisher-Yates shuffle. The shuffle function was manually implemented. Because proper shuffling is so important and so difficult, this should definitely be tested.

The best way to test this, as far as i know, is a chi-squared test. This requires shuffling an array many times and recording the frequencies of the resulting arrays and then performing statistical calculations on them to determine how likely the observed results would be if the null hypothesis - in this case a uniform distribution where all results are equally likely - would be.

There are JavaScript libraries on NPM that can perform the statistical calculations. However, gathering a reasonable number of samples is time consuming, so this should probably be an integration test, and not a unit test. It certainly shouldn't run every time a file is saved.

I need to look into which NPM module to use, and also how to set up integration tests with Jest and Git.