About 10 percent of Americans have some sort of sleep disorder, including sexsomnia. (Photo: Getty Images)We've all heard of sleepwalking. And there are plenty of people who talk in their sleep, or even eat in their sleep. But having sex in your sleep, and not remembering a thing about it afterward?

It's called "Sexsomnia," and yes, it happens.

Also on Shine: 7 Tips to Encourage Better Sleep

Earlier this week Andrew Machin, 40, was acquitted of raping a 21-year-old three years ago after the court determined that he had been asleep when he assaulted her. Though he agreed that the victim had been drinking and had not consented to having sex, he also argued that he had a 25-year history of sleep disorders, including having sex with his long-time partner while asleep, and he was "disgusted" when he woke up and realized what had happened.

"I just wanted to go to sleep," he told the court, crying. "I didn't know where I was when I woke up. … All I wanted to do was help her. I didn't want to hurt her. I feel disgusted."

His partner, 38-year-old Denise Jacks, told The Daily Mail that Machin has been a sexsomniac for a long time. "It's like he's hypnotized and someone's got the remote control on," she said. "He's disgusted with himself. He just can't help it."

Sexsomnia is a type of parasomnia, or sleep disorder, in which deviant behavior or physiologic events happen while sleeping, according to Medcape.com. "It’s similar to sleepwalking and night terrors in that those behaviors occur during deep sleep so you don’t have much memory of them," Gerald Kennedy, associate professor of psychology at Victoria University, told Vice magazine. "The same is true for sexsomnia. The person isn’t actually having sexual dreams, they’re just acting automatically."

"Sexsomnia is a very real condition," agreed Matthew Walker, professor of neurology at the National Hospital for Neurology and Neurosurgery in London. He told the BBC that people have to be careful about the diagnosis, warning that it "potentially could be abused as an excuse for rape."

"People who suffer from sexsomnia are those who have an extended history of sleepwalking or other unusual sleep behaviors," Kennedy explained. "It doesn't just occur out of the blue."

It also "is not something that can be faked," attorney Martin von Bülow told a Danish newspaper after losing a molestation case in April. A 32-year-old man was acquitted of assaulting two teenage girls after a sleep specialist scientifically proved that the man had sexsomnia. “We had a professor in court who concluded that the fluctuations in the man’s brain patterns matched others who suffered from sexsomnia,” von Bülow explained.

The National Sleep Foundation estimates that approximately 10 percent of Americans suffer from some sort of parasomnia. It's a condition that affects both men and women and, like other disorders, it can run in families. During his trial Machin's sister, Kathy Pickering, told the court that she suffers from sexsomnia as well.

"I have sleep sex," she testified. "I discovered that when I was married. My husband told me about it. I'm not aware. I've no recollection of what I've done or what I've said."