No doubt this is because of poor health. I don't think it can be linked to a single problem. I've had this problem ever since I was in high school (along with other symptoms; cold body, unrefreshing sleep, fatigue) and it has driven me nuts. I went from tons of friends to no friends. I tried every kind of meditation, hypnosis and whatever else kind of BS there is out there. Meditation helped me sleep better but thats about all I could tell.
About 10 months ago all my symptoms and especially my digestive issues got a lot worse. To the point where I wasn't digesting anything. I've ended up spending around $6k on meds/doctors since then which turned out to be a complete waste.
I'm on the road to recovery now though. I have seen some changes on a strict candida diet (Bee Wilder diet). My thoughts have become a lot more clear and I'm a lot calmer and have energy again. Still not ready for a relationship, or hiking up a mountain but I think it will come in the future.