I think my dog might be… mentally disabled?

Hi everyone, I have a 3 year old Miniature Schnauzer. I adopted her from someone when she was about a year old and I have been taking care of her for 2 years now. However, she has a tendency of randomly mouthing me viciously. They are painful, but not so bad as I don't bleed from them. I get a few temporary red marks though. Sometimes they just puncture my skin a little, but they aren't those serious bites.

She bites me a lot, everyday, anywhere and anytime. (Except when she just woke up/she's in her playpen) I notice she likes to bite me whenever I come out of a room, or exit the toilet. (She dislikes my grandfather a lot and since he uses that toilet, perhaps… she doesn't like it?) Also, whenever I am near the door when someone leaves home, she will turn around abruptly and bite me like there's no tomorrow, when I didn't even move a single bit.

One minute she's friendly and wagging her tail, the next split second, she starts to attack my legs and hands. I tried to use a very bad method–hitting her hard. But she doesn't even respond to those hits. And I felt that hitting a dog isn't a good way to discipline. (Don't throw those clichĂ©d "Spare the rod and spoil the child" phrases at me) It worked for her humping problem last time though.

So I tried the next method–which was standing still whenever she bites me. (I read it off the net) This was extremely hard for me because when she bites my feet I find it unbearable as my feet are quite sensitive. I would try to lower my hands down subtly so she would bite them instead but she'll just switch back to my feet shortly after.

Okay, so I just slightly suspect her of being mentally disabled. But does someone have an explanation of her behaviour? It really hurts me when people call her crazy and retarded when she randomly starts biting, so I would really, really LOVE to solve this problem ASAP.