Joshua Frost link is blown away due to non-PURL conversion of the paizo site.
The formula that seems to work for all NPC I tested against is:
HIT_POINTS = FLOOR(HIT_DICE*(4.5+CON_BONUS))
See this calculator for an example.
https://jsfiddle.net/ledlogic/2su4otga/