My dogs sometimes will make the motions of running in their sleep, and light barking or growling, I always chalked it up to a bad dream and calmly and gently wake them up if it seems like they're in a nightmare. If it seems like a happy dream I will let sleeping dogs lie.
Not sure about violent shaking though. Sounds like it could be seizures. Might be worth a trip to the vet?