Many of us categorise ourselves as either optimist or pessimist, but what can science tell us about how we got that way and can we change, asks Michael Mosley.

Debbie and Trudi are identical twins.

They have much in common, except that Trudi is cheerful and optimistic while Debbie is prone to bouts of profound depression.

It is likely that her depression was triggered by a major life event, though the twins have different views as to what that event might have been.

By studying a group of identical twins like Debbie and Trudi, Prof Tim Spector, based at St Thomas' hospital in London, has been trying to answer fundamental questions about how our personality is formed. Why are some people more positive about life than others?

About the author Michael Mosley is a medical journalist, TV presenter and trained doctor

He has regularly explored scientific questions by experimenting on himself, and has been credited with popularising the 5:2 diet

Spector has been able to identify a handful of genes which are switched on in one twin and not the other.

Twin studies suggest that, when it comes to personality, about half the differences between us are because of genetic factors. But Spector points out that throughout our lives, in response to environmental factors, our genes are constantly being dialled up and down as with a dimmer switch, a process known as epigenetics.

With twins like Trudi and Debbie they have found changes in just five genes in the brain's hippocampus which they believe have triggered depression in Debbie.

Spector, who describes himself as an optimist, hopes that this research will lead to improved treatments for depression and anxiety.

"We used to say," he told me, "that we can't change our genes. We now know there are these mini mechanisms that can switch them on and off. We're regaining control, if you like, of our genes."

Image caption Trudi (l) is an optimist whereas her twin Debbie has suffered from depression

Even more surprising is research which has identified changes in the activity of genes caused by the presence or absence of maternal love.

Find out more Michael Mosley presents The Truth about Personality on BBC Two at 21:00 GMT on Wednesday 10 July

He explores what science can tell us about optimism and pessimism and whether we can change our outlook Or catch up with iPlayer (UK only)

Prof Michael Meaney, from McGill University in Canada, is investigating ways to measure how many glucocorticoid receptors are activated in someone's brain.

The number of active glucocorticoid receptors is an indicator of that person's ability to withstand stress. It may also be a measure of how well mothered they were at a young age - reflecting how anxious and stressed their mothers were, and how this impacted on the amount of affection they received in their early years.

I am one of a small handful of people who have done their test and had the results. I haven't told my mother yet.

I see myself as being more at the pessimistic end of the spectrum but would like to change, so I went to visit psychologist and neuroscientist Prof Elaine Fox at her laboratory at Essex University.

Fox is interested in how our "affective mindset", the way we view the world, shapes us. As well as using questionnaires she and her team look for specific patterns of brain activity.

They began by measuring the levels of electrical activity on the two sides of my brain with an electroencephalograph. It turns out I have more electrical activity in my right frontal cortex than my left. This, Fox explains, is associated with people who are prone to higher levels of pessimism and anxiety.

Then I did another test, designed to measure my "negative bias". Still wired up I was asked to press a button whenever I saw dots flashing in a particular pattern behind faces being displayed on a computer screen. I was asked not to focus on the faces, just on the dots.

"Sometimes," Fox says afterwards, "there was an angry face near the dots, sometimes a happy face. Your response time to the dots was faster when they appeared near the angry face.

10 quotes on optimism and pessimism "A pessimist sees difficulty in every opportunity. An optimist sees the opportunity in every difficulty" - Winston Churchill

"The man who is a pessimist before 48 knows too much; if he is an optimist after it, he knows too little" - Mark Twain

"The point of living, and of being an optimist, is to be foolish enough to believe that the best is yet to come" - Peter Ustinov

"Blessed is he who expects nothing, for he shall never be disappointed" - Alexander Pope

"A pessimist is a person who has had to listen to too many optimists" - Don Marquis

"An optimist may see a light where there is none, but why must the pessimist always run to blow it out?" - Rene Descartes

"The basis of optimism is sheer terror" - Oscar Wilde

"No pessimist ever discovered the secret of the stars, or sailed to an uncharted land, or opened a new doorway for the human spirit" - Helen Keller

"I'm a pessimist because of intelligence, but an optimist because of will" - Antonio Gramsci

"I like pessimists. They're always the ones who bring lifejackets for the boat" - Lisa Kleypas Source: Goodreads, Brainyquote, Jimpoz Discover more about the mind and body

"The reason you were faster is because your attention had already been drawn to the angry face, even though you may not have been aware of that."

The tests confirmed I have a fundamentally negative bias. To counter this, Elaine suggested I try a short course of CBM (cognitive bias modification) and mindfulness meditation.

Being a pessimist, constantly on the lookout for things that can go wrong, leads to increased stress and anxiety. And it's more than just a state of mind. It's powerfully connected to your health.

In one study, which started in 1975, scientists asked more than a thousand inhabitants of the town of Oxford, Ohio, to fill in a questionnaire about jobs, health, family and attitudes towards growing older.

Decades later Prof Becca Levy of Yale University tracked down what had happened. When Levy went through the death records she found that those who had felt the most optimistic about growing older had lived, on average, around seven and a half years longer than those who were more pessimistic.

It was a striking finding and took into account other possible explanations, such as the fact that people who were more pessimistic may have been influenced by prior sickness or depression.

Similar results emerged from a study of nuns done by Deborah Danner and others at the University of Kentucky. They looked at the diaries of 180 Catholic nuns, written when they had entered their nunneries in the 1930s.

Image caption Nuns living in a closed community are good for a scientific study because they have very similar environmental experiences, allowing more robust comparison

They then rigorously scored these diaries for optimistic or pessimistic outlook. Nuns who live in a closed community are a good group to study because they live in the same environment for most of their lives, eating the same foods and having similar experiences.

When the researchers traced what had happened to the nuns they discovered that those who expressed the most positive emotions about life when they were in their early 20s lived up to 10 years longer than those who expressed the least.

As for me, after seven weeks of doing mindfulness meditation and CBM I felt much calmer and returned to Prof Fox's lab for more tests. The results were extremely encouraging.

It seems that even later in life you can change your outlook. Even for the pessimists, that should be worth celebrating.

Michael Mosley's search for the roots of optimism can be seen on Horizon - The Truth about Personality, at 21:00, Wednesday 10 July on BBC Two

You can follow the Magazine on Twitter and on Facebook