They are either crazy, or not. We can compare this to Ophelia's insanity because she couldn't snap out of her phase. She was truly insane and could not change her ways. Even as she killed herself she was still singing little songs and playing with the flowers, while when Hamlet was dying he was calm and rational, his true sane self. .
Secondly, truly insane people can not make swift, rational decisions with common sense and plan ahead. Hamlet shows both of these qualities many times during the play. Firstly, he asks the players to play "The Murder of Gonzago", which he knows deals with the murder of a king. (Act 2, Scene 2, Lines 533-534). Hamlet has a discussion with himself about how plays can make guilty people confess their crimes. He states, "Play something like the murder of my father before mine uncle; I"ll observe his looks." (Act 2, Scene 2, Lines 593-595) Hamlet is sane and smart enough to know that his uncle will act strange when he watches the play if he truly did murder his father. Someone who is mad would not be able to come up with such an intelligent plan. Another good example of Hamlet making rational decisions is how he holds off his revenge against Claudius until the right time. Hamlet had the perfect chance to murder his uncle while he is at confession, but he did not want to murder him like that. If Hamlet had killed him there, all of Cladius's sins would have been wiped away, and Hamlet feared sending him to heaven, so he would wait for a better time to kill Claudius. "A villain kills my father; and, for that, I, his sole son, do this same villain send to heaven. O, this is hire and salary, not revenge." (Act3, Scene 3, Lines77-80). Hamlet does not want Claudius to go to heaven, for this is not revenge. He wants him to go to hell. If Hamlet were truly insane he would not have enough will to hold off on perusing his revenge. Hamlet also makes many smart remarks to people through out the play that would take common sense to come up with.