However, neither of those kinds of neighbors actually poses a serious threat to a surrounding area these days, but that doesn't mean outmoded perceptions won't influence future buyers. Long gone are the days when released psychiatric patients were allowed to trudge off into adjacent neighborhoods. Patients must now be delivered or discharged by a physician to another care facility or a family member, and that policy is strictly enforced. Ditto for prisons, which by law can't release inmates into their immediate community. Moreover, there are always guards and cops hanging around the periphery of the prison, and that can be good or bad, depending on your perspective. The scant few escapees we read about typically high-tail it away from their old digs as far and as fast as possible.
Unfortunately, there are no studies on this subject, and the automated valuation models that appraisers use aren't sophisticated enough to actually judge the impact that prisons or other institutions have on nearby property values.
I venture to say that neither of these places is actually next door to the house you're considering. If you did buy (literally) adjacent to a prison, you'd have to expect future buyers to react negatively, both visually and psychologically (except perhaps for prison management). A next-door psychiatric hospital might be less menacing, though there would also be potential buyer bias.
Before you sign on the dotted line, you should contact the police department for hard facts on crime in the immediate area for your own peace of mind, if nothing else. In the event you do buy, you could get an update on that data to reassure future buyers concerned about the safety of the two operations when it comes time to sell.
Success of any future resale might also depend heavily on factors such as the robustness of the area job and housing markets. In fact, had you bought at a rock-bottom price at the depth of the recession and were trying to sell now, you'd have held a far more advantageous position in this real estate cycle. Any value hit that the property has taken (when compared with like-size homes in the general area) because of those two facilities should have already been factored into the listing price that's being offered to you.
I hate to dash the home seller's hopes, but if you do not feel safe or secure in any way in this purchase, then please reconsider it. Unless you've fallen hopelessly in love with the place, are getting an aggressively negotiated low price and plan to stay for the long term (say, 10 years to life), it may not be worth the risk or worry. There are plenty of attractive neighborhoods out there that are not even close to prisons and psychiatric facilities.
But if you still decide to buy, here's a biggie: Please refrain from gallivanting around the neighborhood on Halloween dressed as an inmate. The tower guards might not get the joke.