Trying to imagine fat, fuzzy white lambs, jumping one by one over a fence, is a well-known remedy for sleeplessness. When I used to try this, I would insert a dapper black sheep with a red bow tie now and again 鈥 a nod to my inner rebel.

I don鈥檛 have insomnia often (thank heavens), but I鈥檝e often wondered just who came up with such a silly suggestion. If the idea is to bore yourself to sleep, why not count backward as you do when undergoing anesthesia? And who decided on sheep? Why not jackrabbits, horses, giant toads or kangaroos?

History supposedly provides the answer: It was said to be a way for medieval shepherds, devoid of human company for weeks at a time, to fall asleep each night 鈥 they counted their sheep until drowsy. Whether that鈥檚 true or not, I don鈥檛 know.

What is clear is that the concept of counting sheep to sleep is so old it was mentioned in a 13th century compilation of short stories titled 鈥淐ento Novelle Antiche.鈥 In one of the novellas, a storyteller in the service of Messer Azzolino was so sleepy that he told his master a tale of a farmer trying to get a flock of sheep across a swollen river in a small boat.

鈥淪o he jumped in with a single fleece, and began to row with all his might,鈥 the storyteller said. 鈥淭he river was broad, but he rowed and he rowed away. 鈥︹

The storyteller stopped talking as he fell asleep, prompting his master to prod him awake to finish the tale.

鈥淟et him get over the remainder of the sheep, and then I will proceed; for it will take him a year at least, and in the meantime your excellency may enjoy a very comfortable slumber,鈥 the fabulist replied before nodding off again.

The same tale was told in the earlier 12th century work 鈥淒isciplina Clericalis,鈥 and even became part of the 17th century book 鈥淒on Quixote鈥 鈥 only in this version Quixote鈥檚 squire, Sancho Panza, tells him to count goats, not sheep.

鈥淵ou鈥檇 better keep track of how many goats the shepherd carries across, your grace, because if we forget a single one that will be the end of the story, and it won鈥檛 be possible to tell another word,鈥 Panza tells him.

Does counting sheep work?

So does counting sheep really help you fall asleep? Search online, and you鈥檒l soon find stories about a 2002 study on combating insomnia that put the concept to the test.

In reality, that wasn鈥檛 the point of the research, said senior author Allison Harvey, a professor of psychology and director of the Golden Bear Sleep and Mood Research Clinic at the University of California, Berkeley.

鈥淥ur study more than 20 years ago wasn鈥檛 about counting sheep; it was just about using imagery to fight insomnia,鈥 said Harvey, who conducted the research while a professor of psychology at Oxford University.

Her research split 50 people into three groups, Harvey said. The first had no instructions on how to fall asleep, while members of the second were told to distract from thoughts, worries and concerns in any way they wanted. The third group was instructed to perform an interesting and engaging imagery task, such as creating or remembering a meadow, a waterfall, a holiday or a summer afternoon in the sun.

Those who used imagery reported falling asleep much faster than either of the two other groups, and they rated their thoughts, worries and concerns to be less uncomfortable and distressing than people in the distraction or no instruction group.

As it happened, two of the study participants in the distraction group did count sheep as a way to fall asleep 鈥渁nd somehow people latched onto that, I guess because they thought it was fun,鈥 Harvey said.

While she didn鈥檛 actually study counting sheep as a way of overcoming insomnia (and isn鈥檛 aware of any other studies to do so), Harvey does have an opinion based on her years as a sleep specialist.

鈥淪omething as mundane as counting sheep usually does not do the trick,鈥 she said. 鈥淚nstead, we work out a menu of options with people, because everyone is different and not one option is going to help every single time.鈥

What does work?

There are science-backed ways to help yourself empty your mind and fall asleep, however. More than 20 years later, using your imagination still remains a top tip, Harvey said. Here are her other recommendations.

Visualize relaxation: Envisioning a pleasant and engaging environment does work for many people and is most successful when all five senses are involved.

鈥淭ry to make your image as vivid as possible by asking yourself what you see, what you hear, what you smell, and if it applies, what you taste,鈥 she said.

Gratitude: Known for boosting happiness, counting your blessings is also a good way to relax and sleep, according to research.

Harvey suggests coming up with three things in your life that you are grateful for and then saying those to yourself before sleep.

Savouring: A cousin of gratitude, savouring is about reliving a wonderful moment from your day. Remember what happened, how you felt and let yourself bask in those good feelings to encourage sleep, Harvey said.

The next three suggestions are best done before your head hits the pillow, and all focus on controlling worry and rumination (which is chewing on repetitive thoughts much like a cow chews cud).

Problem-solving: Find a time before you hit the sack to pick up a pen or pencil and make two columns on a sheet of paper. Label the top of one column 鈥淐oncerns鈥 and the other 鈥淪olutions.鈥

List your problems or worrisome tasks in the concerns side and then brainstorm some potential fixes. Getting it down on paper frees your mind from chewing on it (so to speak).

Journaling: Keeping a diary or journal doesn鈥檛 have to focus on problem-solving, although it could, Harvey said. It can be a place to capture blessings and daily memories that you want to retrieve later 鈥 or just a way of expressing yourself.

Worry time: Not a writer by nature? Well, you can set aside a few hours before bed to just worry away and (hopefully) come up with solutions. Doing so can get it out of your head before your head hits the pillow, allowing sleep to come without counting sheep.