Collective animal behaviour describes and analyzes the behaviour of groups of animals. In these groups, the animals are often all of the same species. As an example, a school of fish will be made of mostly the same type of fish and a flock of birds will have the same type of bird. A herd is a large group of hoofed, herbivorous mammals.

Animals tend to behave in such a way because this behaviour offers them a benefit. The group of animals also behaves differently from a single animal. Collective animal behaviour is about finding the rules each animal follows; how it communicates with other members of the group and how a decision to do something is reached in the group.

Scope of the term 
Full-time colonial animals fall into this category in principle, but in practice the species of interest here are those who form temporary groups. Colonial animals have been researched for many years, and are usually based on some kind of family relationship. Temporary collective behavior is a well-known phenomenon, but little researched until now.

Different functions
Different functions have been proposed, as follows:

1. Protection from predators.
1.1 A school of fish is better protected from predation than a single fish: see shoaling and schooling. One method by which fish schools or bird flocks may thwart predators is the ‘predator confusion effect’. This theory is based on the idea that it becomes difficult for predators to pick out individuals from groups, because the moving targets create a sensory overload of the predator's visual channel.
1.2 A second potential anti-predator effect of animal aggregations is the ‘many eyes’ hypothesis. As the size of the group increases, the task of scanning the environment for predators is spread out over many individuals. This gives a higher level of vigilance, and allows more time for individual feeding. 
1.3 A third possibility is the ‘encounter dilution’ effect. Hamilton proposed that the aggregation of animals was due to a “selfish” avoidance of a predator, and was a form of cover-seeking. Another formulation of the theory was combining avoidance and dilution. It was suggested that potential prey might benefit by living together since a predator is less likely to chance upon a single group than a scattered distribution. About attack, it was thought a predator is less likely to eat a particular animal when a greater number of individuals are present. In sum, an individual has an advantage if it is in the larger of two groups (assuming that the probability of detection and attack does not increase disproportionately with the size of the group).

2. Better foraging: A school of fish or a group of animals is better at foraging. 

3. Easier movement: Groups of animals moving together (such as fish or birds) save energy. Many of the larger birds fly in flocks. Flying in flocks helps in reducing the energy needed. Many large birds fly in a V-formation, which helps individuals save 12–20 % of the energy they would need to fly alone. Red Knots Calidris canutus and Dunlins Calidris alpina were found in radar studies to fly 5 km per hour faster in flocks than when they were flying alone.

4. Social interaction: This can be seen with fish, such as herring. If an animal is separated from the group, it will feel stressed.

5. Special factors come into play with migrating birds, or birds which gather in huge flocks, such as starlings. Bird behavior has a larger component of learning than fish. In addition to factors listed above is the possibility that migrating bird flocks are good at teaching first-year birds how to do the migration successfully. The specific routes may be genetically programmed or learned to varying degrees. The routes taken on forward and return migration are often different.

Swarms 
The usual term for insects which are not always in a fixed colony, but move in large numbers is swarm. There are many good examples: army ants for instance. The best researched is the locust.

Locust swarming 

Locusts are the swarming phase of short-horned grasshoppers of the family Acrididae. These are species that can breed rapidly under suitable conditions. Then they come together in large groups and become migratory. They form bands as nymphs and swarms as adults—both of which can travel great distances, rapidly stripping fields and greatly damaging crops.

There is no taxonomic difference between locust and grasshopper species, and in English the term "locust" is used for grasshopper species that change morphologically and behaviourally on crowding, to form swarms or hopper bands. These changes, or phase polymorphism, were first thought of as separate species. 

Research at Oxford University showed that swarming is a response to overcrowding. Increased tactile stimulation of the hind legs causes an increase in levels of serotonin. This causes the locust to change colour, eat much more, and breed much more easily. The transformation of the locust to the swarming variety is induced by several contacts per minute over a four-hour period. It is estimated that the largest swarms have covered hundreds of square miles and consisted of many billions of locusts. Plagues of locusts appear in both the Bible and the Koran, including one of the Biblical Plagues of Egypt, where locusts ate all the crops of Egypt.

Modelling large groups 
Often, animals in a herd are thought to follow simple rules, such as
Move in the same direction as your neighbour
Stay close to your neighbours
Do not collide with your neighbours
Recent studies have shown that an animal only picks five to seven other animals, and aligns with them. This seems to be independent of the distance. Another approach is when all animals within a certain distance are noted for alignment.

Small social groups 
Primates are a good example of animals which almost always live in small groups. The groups are based on a family, a group of families, or females 'owned' by a dominant male, together with offspring.

References

Zoology
Ethology