Spontaneous behavioural changes in response to epidemics