The clustering illusion refers to the tendency to erroneously perceive small samples from random distributions as having significant "streaks" or "clusters", caused by a human tendency to underpredict the amount of variability likely to appear in a small sample of random or semi-random data due to chance.
Thomas Gilovich found that most people thought that that the sequence "OXXXOXXXOXXOOOXOOXXOO looked non-random, when, in fact, it has several characteristics maximally probable for a "random" stream, such as having an equal number of each result and the number of adjacent results with the same outcome is equal for both possible outcomes. In sequences like this, people seem to expect to see a greater number of alternations than one would predict statistically. The probability of an alternation in a sequence of random binary events is .5, yet people seem to expect an alternation rate of about .7. In fact, in a short number of trials, variability and non-random-looking "streaks" are quite probable.
Daniel Kahneman and Amos Tversky explained this kind of misprediction as being caused by the representativeness heuristic. Gilovich argues that a similar effect occurs for other types of random dispersions, including 2-dimensional data such as seeing clusters in the locations of impact of V-1 flying bombs on London during World War II or seeing streaks in stock market price fluctuations over time.
The clustering illusion was central to a widely reported study by Gilovich, Robert Vallone and Amos Tversky. They found that the idea that basketball players shoot successfully in "streaks", sometimes called by sportcasters as having a "hot hand" and widely believed by Gilovich et al's subjects, was false. In the data they collected, if anything the success of a previous throw very slightly predicted a subsequent miss rather than another success.
Using this cognitive bias in causal reasoning may result in the Texas sharpshooter fallacy. It may also have a relationship with gambler's fallacy. More general forms of erroneous pattern recognition are pareidolia and apophenia.