A chi-square test for dimensionality with non-Gaussian data