From The Aquarium Wiki
Stocking ratio can refer to the number of males per female kept in a tank, it can also at time be referenced as a ratio of fish per gallon of water.
Male to Female meanings
Stocking Ratio refers to how many male of the species in question should be kept to females. In some creatures it's best to only keep one of the species, either male or female, to a tank. In other cases the species may be hermaphroditic and in which case the ratio will not apply. Refer to the article in question for more details on how the creature should be kept in more detail.
Number of fish per gallon
The most common misconception is that the appropriate rule of thumb is 2.5cm (1") per 3.8 Litres (1 US G.). This is generally considered a huge mistake and will typically result in a heavily overstocked tank.
This rule dose not take into account a few issues, such as the fish's behavior, maximum size, and waste productions.
Size ConsiderationsCommon Pleco, a favorite amongst starting aquarium owners due to their price and availability. This fish can easily reach 30.5cm (12") long after just a few years in a fish tank. The fish however is typically initially sold at 5.1cm (2") or less, and within a year will reach 12.7-20.3cm (5-8"). This size, combined with the fact that the most common aquarium size for starting owners is a 37.9 Litres (10 US G.) which measures 50.8cm (20") long.
So after one year, this single fish stretches almost half the length of the tank. This is typically considered much to large, and considering the tank is only 25.4cm (10") long, the fish can barely turn around. Combine this with the fact that this fish is almost never purchased solo, it now is sharing space with other fish, your tank is getting a bit more cramped.
Behavior ConsiderationsZebra Danio is one of them. These fish are usually sold at 2.5cm (1"). They make great first-fish animals because they have a lot of energy and will spend the day darting around the tank, which is unfortunately the problem. Some fish need room the swim, and a regular 37.9 Litres (10 US G.) tank cannot provide this space. However a 56.8 Litres (15 US G.) long is not much more expensive and provides the perfect habitat for this fish. (37.9 Litres (10 US G.) long are available but are fairly uncommon).
Waste ConsiderationsCommon Pleco also falls into this category, but in the interest on picking on another fish, we will use the colorful Oscar. This fish also falls into the Size and behavior category for personalty quirks, but for now we will focus on its waste production. The general formula for this is the larger the fish, the more it eats, the more waste it produces. This factors into the amount of filtration required more so then directly to the tank size. However the consideration is that the more water in the tank, the less of an impact waste production will have on the overall water chemistry.
The Oscar is a fish typically fed live or frozen food, and it usually will not eat all of it. This leaves the remainder to rot on the bottom of the tank. This, combined with the fish's excrement need to be filtered by the tank's bacteria colony. The larger the tank, the larger of a bacteria colony that can be supported to keep the water healthy.
The important question to ask yourself, or another experienced aquarium owner, is Will my fish be happy and healthy with this set-up?