The main explanation for why we get certain songs stuck in our head is probably the simplest, but the remedy may be a surprise: chewing gum.
University of Wollongong researcher Tim Byron has been investigating what causes certain tunes to get lodged in our brains and play on repeat.
"We basically send texts to people at random points and ask them ‘is there a song stuck in your head now?’," he tells RNZ Nights' Emile Donovan.
"Probably the level is a bit inflated because they're doing the experiment in the first place, so they're probably thinking about it [more often], but we find about a third of the time people do have a song stuck in their head.
"What we find in the research is that pretty much everyone has a different song stuck in their head."
Dr Byron says there’s several reasons why certain songs are more likely to get stuck in your head.
“One that I've done research on and found evidence for is that basically the more recently you've heard a song and the more often you've heard a song, probably the more likely it is to be stuck in your head.
"That's sort of the most boring explanation for it ever - because people want it to be about, you know, crazy Freudian things about like unconscious desires and things like that, but it's pretty basic, and also unsurprising and what you'd expect.
“Other reasons why songs get stuck in your head ... I remember one day I had ‘New Year's Day’ by U2 stuck in my head and I was confused by this because I hadn't heard the song for ages ... I eventually realised the reason that it was stuck in my head is because it's January first. it's New Year's Day.”
He says environment comes into it too.
“One of the things that memory research has shown, for example, is that if you have to do a test ... a math test or something like that, and you learn how to do it underwater – like while you're snorkeling, for example – research shows that you are better at doing that test if you're also underwater again.
“The joke that we kind of make about that is that if you if you're studying for an exam drunk, you should do the exam drunk, but what that's actually showing us is that our memory is related to the things around us, and that we use the world around us to remember.
The same principle applies to music.
“You know, songs are ephemeral, in that kind of way where there’s that sort of four or five months where they're really popular and then you never hear it again. When they are tied to that kind of time and place it's easier for us to access some of the memories that are specifically associated with that.”
There’s also musical elements that make songs more catchy, he says.
"The songs that are more likely to be earworms statistically, they tend to have more leaps in the melody than steps, so they tend to have notes that go up by a lot – so if you think of like ‘Somewhere Over the Rainbow’ for example, the first two notes in that are a big leap - 'some-WHERE'."
He says simplicity of melody also had an effect.
“[If] in order to understand the melody it needs to be quite long, it's probably harder for it to be an earworm. There’s ways around that by using kind of repetitions within the melody but yeah, usually that would be the case.”
There's a bit more to it than that, of course, and just like comedy, good music is all about subverting - or harnessing - our expectations.
“Good composers are exploiting, basically, the expectations we have about music when we listen to it, and people will have different expectations … those are definitely going to play some role in the emotions we feel to music, but also probably the ones that we have as a result of the cultural differences that come into play here as well.”
He says music producer Jay Brown was quoted in a New Yorker article in 2012 saying people listening to American radio would switch off a song within seven seconds if they did not hear a hook, so most pop music has a hook every seven seconds.
“A hook every seven seconds is something that is hard to do, and there's ... absolutely an art to what a producer like [Katy Perry producer] Max Martin .. there’s definitely an art to what they do.
“It's the kind of thing where the end product doesn't seem very worked over and it seems very simple but there's a lot of under the surface stuff that's being done in order to have that hook every seven seconds and try to catch it.”
Dr Byron says that from his research, most of the time the songs stuck in people's heads are songs they like, because they're more likely to listen to them.
“The really annoying ones, like the ‘Baby Shark’s of the world … they're the ones that we kind of notice because we hear them and they’re stuck in our heads, and we notice because we don't want them.”
The solution to annoying earworms like seems little unlikely.
“The tip that I have - that is suggested by scientific research - is chewing gum.
"Working memory – the part of our brain that’s sort of happening right now and holding information, say for instance someone tells you a phone number and you’ve got about three seconds before you get the chance to write it down that's you using working memory … and what chewing gum does is this process of working memory isn’t just in your head as in the neurons in your brain, it’s embodied in other parts of your body.
“In particular it uses a pathway from your brain to your throat and back and that pathway it's basically equivalent to you … muttering the words under your breath as you're trying to remember the phone number.”
“The research suggests that chewing gum will reduce the incidence of the words it's not necessarily going to get rid of that but you know, chances are, it might reduce it and make it shorter or maybe get rid of it.”