Some factors that encourage the equilibrium of the Hardy-Weinberg equation are a large population size, lack of migration, truly random mating and a lack of selective forces that encourage or hinder specific phenotypes. The Hardy-Weinberg equilibrium is an expression of the ideal distribution of phenotypes within a population given the assumption that the gene frequencies are already known.
The Hardy-Weinberg equation is only valid if there are no mutations, the population is infinitely large, the population undergoes random mating, there is no population migration and there is no genetic drift. If any of these conditions are not true for a specified population, the equation is not true. If these conditions are met, however, it is possible to calculate the genotype frequencies because they are in a constant proportion to each other. This is due to the predictable statistical likelihood of individual genes being passed down to the next generation.
The Hardy-Weinberg equation is used as a null hypothesis to test whether a population is in equilibrium or not. In order to do this, the actual gene frequencies within the population are determined. Then the expected gene frequencies are calculated and compared to the actual gene frequencies. If the actual gene frequencies are different from the expected gene frequencies, the population is not in Hardy-Weinberg equilibrium.