The role of chance, or "luck", in science comprises all ways in which unexpected discoveries are made.
Many domains, especially psychology, are concerned with the way science interacts with chance — particularly "serendipity" (accidents that, through sagacity, are transformed into opportunity). Psychologist Kevin Dunbar and colleagues estimate that between 30% and 50% of all scientific discoveries are accidental in some sense (see examples below).
Psychologist Alan A. Baumeister says a scientist must be "sagacious" (attentive and clever) to benefit from an accident. Dunbar quotes Louis Pasteur's saying that "Chance favors only the prepared mind". The prepared mind, Dunbar suggests, is one trained for observational rigor. Dunbar adds that there is a great deal of writing about the role that serendipity ("happy accidents") plays in the scientific method.
Research suggests that scientists are taught various heuristics and practices that allow their investigations to benefit, and not suffer, from accidents. First, careful control conditions allow scientists to properly identify something as "unexpected". Once a finding is recognized as legitimately unexpected and in need of explaining, researchers can attempt to explain it: They work across various disciplines, with various colleagues, trying various analogies in order to understand the first curious finding.
Accidental discoveries have been a topic of discussion especially from the 20th century onwards. Kevin Dunbar and Jonathan Fugelsang say that somewhere between 33% and 50% of all scientific discoveries are unexpected. This helps explain why scientists often call their discoveries "lucky", and yet scientists themselves may not be able to detail exactly what role luck played (see also introspection illusion). Dunbar and Fugelsang believe scientific discoveries are the result of carefully prepared experiments, but also "prepared minds".
The author Nassim Nicholas Taleb calls science "anti-fragile". That is, science can actually use — and benefit from — the chaos of the real world. While some methods of investigation are fragile in the face of human error and randomness, the scientific method relies on randomness in many ways. Taleb believes that the more anti-fragile the system, the more it will flourish in the real world. According to M. K. Stoskopf, it is in this way that serendipity is often the "foundation for important intellectual leaps of understanding" in science.