[WIP] Chi squared test

API and code structure.