The chi-square test is used to determine if an observed distribution of data differs from the theoretical distribution. It compares observed frequencies to expected frequencies based on a hypothesis. The chi-square value is calculated by summing the squared differences between observed and expected frequencies divided by the expected frequency. The chi-square value is then compared to a critical value from the chi-square distribution table based on the degrees of freedom. If the chi-square value is greater than the critical value, the null hypothesis that the distributions are the same can be rejected.