Numerical studies in rarefied gas dynamics, cosmological summary statistics, and scalar field dark matter