Kim Jong Il is neither insane nor stupid.
From the CIA's psychological profilers to his many biographers, experts who have studied the North Korean leader believe that beneath the glaring eccentricities - the bouffant hairdo and the oddball Mao suits - there is a shrewd operator at work.
Despite an image as a "nut with a nuke," as some bloggers have disparaged him, Kim appears to have carefully orchestrated his country's path to nuclear sovereignty.
If the announced test is confirmed, one of the world's poorest and most dysfunctional countries will have become an unlikely gate-crasher in the exclusive club of nuclear powers.
That is an achievement that Kim apparently believes will ensure the top item on his agenda: maintaining power.
In Kim's eyes, a nuclear weapon should prevent the United States from attempting to topple him from his post in the manner of Iraq's Saddam Hussein. And the indomitable mystique of nuclear capability could in part substitute for the charisma that Kim Jong Il, unlike his late father, Kim Il Sung, is lacking.
Biographers over the years have frequently made the point that Kim Jong Il did not merely inherit power. He seized it. Short, dumpy and lacking in personal charm, the younger Kim had to fight his way through other possible successors before taking over in 1994, upon the death of Kim Il Sung.
Far less popular domestically than his father, Kim also has had his hands full staying in control - especially given the economic basket case that North Korean became under his watch.
Jerrold M. Post, founder of the CIA's Center for the Analysis of Personality and Political Behavior and who now teaches at George Washington University, says Kim has had a tougher act to follow than other filial heirs to power because his father was revered literally as God.
A psychiatrist by training, Post does not believe Kim is psychotic but thinks that he has a dangerous personality disorder that he diagnoses as "malign narcissism." As such, Kim has loyalty only to himself and lacks the ability to consider other people's feelings.
Propagandist No. 1
North Korea's leader apparently saw no hypocrisy in exiling people to the gulag for watching foreign media, while he personally amassed a collection of 20,000 foreign film titles.
Kim is known to love cinema. He once ordered the kidnapping of a South Korean actress and her director husband to run North Korea's film studio. He wrote a book, "On the Art of Cinema," on using film to instill socialist values in the masses. His first serious job, at the age of 30, was with the Department of Propaganda and Agitation for the ruling Workers' Party.
He oversaw a propaganda machine that maintained the elaborate mythology about the ruling family - including that his own birth was heralded by the appearance of a bright star and a double rainbow.
But Kim was not so delusional to be fooled by his own propaganda, and he knew he would need more to keep himself in power. After 1980, he turned his attention from cinema to weapons of mass destruction.
"Big toys for big boys," is how his psychological profiler, Post, puts it.
Grip on power
The younger Kim steered a nuclear energy program that had been launched in the 1960s more in the direction of weapons development. According to numerous accounts by defectors, he ordered nuclear research and missile development projects moved from the purview of the military to the Workers' Party Central Committee so that he could be more intimately involved.
During the famine of the mid-1990s, ordinary rank-and-file soldiers were allowed to starve to death while the regime poured millions in the development of weapons of mass destruction.
"Kim Jong Il didn't care if he bankrupted the rest of the country. He saw the missiles and nuclear weapons as the only way to maintain power," said Kim Dok-hong, the former deputy director of the Juche Institute, a Pyongyang think tank devoted to North Korean ideology, in a July interview.
Michael Breen, a Kim biographer, believes that Kim has been following a long-nurtured plan to become a nuclear power and that nothing the United States could have done - short of an invasion - would have stopped him.
"From inside the Beltway, people will be talking about the failure of American policy, but I believe the North Koreans did what they always set out to do and became a nuclear state," Breen said. "They weathered the storm of international condemnation, the potential for a coup or invasion. The way the North Koreans see it, a lesser man might have caved to the pressure, but not Kim Jong Il."