First attempt to generate weighted chi-squares (not yet tested)