As a working Geologist, I have spent quite a few months walking in Canadas artic tundra on my lonesome, and living in small tent camps. The first bear I saw up close and personal was a Barrenland Grizzly that had come to inspect our kitchen supplies. He was less than 30 yards away from me, outside of the tents. I got the shotgun and a coworker went to get the bear bangers. You would not believe the speed those animals can travel at. There are no trees where I work, and yet the bear banger had him out of sight within a few seconds.
The rest of the encounters I have had were not as close: I spotted another Barrenland grizzly crossing the lake in front of our camp about a half-mile distant. He just kept moving and had little interest in us. We had four grizzlys like that come within the same distance in four days. At one point there was a grizzly headed straight towards one of our drill crews. They were scared $h!tless and called for the helicopter to drive it off. The pilot estimated its size at over 1000 lbs!
We had two Polar bears spotted within seven miles of our camp near Hudsons bay. We were barbecuing steaks for fifty people at dinner and also had bacon and eggs cooking every morning. Polar bears are the most dangerous of all bears, and these two were uncharacteristically inland by about 12-15 miles. I dont know if they smelled our cooking or not, but they didnt come and bother us. Polar bears are also the only North American species known to actively hunt humans on a regular basis. Black bears only rarely try to eat people and I dont believe I have ever heard of a grizzly eating anyone. We just dont taste that good, although pepper spray may help as a seasoning. I regard black bears and polar bears as unpredictable and dangerous, and grizzlies as fairly predictable.
In Alberta, I have walked within a few meters of a black bear and didnt know it until my camping buddy came back from just passing me (going the other way) with a terror-stricken look on his face. It was right beside the path. He didnt care that I was there, and I couldnt care because I didnt see him, so we were both OK when we passed each other. Another time we were staying on an isolated cut line in tents and there was another camping couple fifty yards away. The other couple left during the night, and I found fresh black bear tracks right on top or their tire tracks, about halfway between our camp and theirs. Again, he didnt much care to bother us, and we didnt know he was there until morning.
I think that bears generally dont give a rats @$$ if people are around, as long as those people dont surprise them, threaten their cubs or act/smell like food. If you can avoid these three mistakes, then you have a better likelihood of falling of a cliff when hiking than getting attacked.
I can heartily recommend reading Stephen Herrero's "Bear Attacks - Their Causes and Avoidance." This will take some of the illusion out of how you plan on conducting yourself in bear country.
You could do a search and likely find it at most bookstores.
An attack by a bear is a rapidly explosive thing. I gather that often you won't have time to react. In the very rare and unlikely instance that one is hunting you, you probably wont even know until it is too late. These animals spend part of their time hunting deer or moose or caribou or muskox or seals, and have honed their stealth and hunting capabilities all of their lives. It would be a lucky thing to detect a bear stalking you before it made an attack.
If you confront one, frequently charges are false just to let you know who is boss. So it comes down to displaying awareness and not acting like food when you see one. Running often triggers a prey response. One should learn which parts of the bush bears frequent and then endeavor to give them their space. As with human predators, prudence is key to avoiding a fight. In a confrontation, speak in a low voice and tell the bear that you are sorry you have invaded its space and that you are going to leave now. Wish it a wonderful life, filled with salmon/lake trout and many liaisons with bears of the opposite sex. Dont run as you leave or it will think you are food.
Don't count on taking down a charging bear with a handgun. Handgun cartridges are weak in comparison to shotgun/rifle rounds, hard to hit with compared to rifles/shotguns, and a wound may just stimulate the bear to neutralize its attacker. Pepper spray is a last-ditch effort too. People in our camp watched a grizzly take down a large muskox, and I have seen pictures of one taking down a moose. Are you as strong as a moose? Can you draw a .44 magnum and place two or three shots into his heart/lungs in the ~1.5 seconds it takes to reach you at it bounds up and down at 40mph? What if it is a false charge and the bear stops 2-10 feet away from you. When will you shoot? Do you want to risk only wounding it? Ok as a last resort, but you have to be PRUDENT. Our standard bear defense weapon was and is a 12 gauge pump with slugs, or slugs and buckshot. You can also load the first round as a blank or a rubber bullet as a deterrent. I prefer to fire a live round into the air or the ground as an effective noisemaker. A 12 gauge at close range is a VERY good stopper. But again, if you are prudent, you are carrying a shotgun in anticipation of winning the lottery. If you have to shoot a bear at close range, dont stop firing unless you have the sense to stop one round short before reloading. Not likely you can count to five or six in a confrontation like that. You wont even know youve soiled your pants until you smell it five minutes afterward. Be realistic about your marksmanship abilities under extreme stress if you choose a firearm to lug around.
Also, cooking bacon over an open fire is a very good way to attract black bears. Just pour the left-over grease into the pit and you are virtually guaranteed excitement in the next day or so.
A spooky Halloween type thought: Wildlife biologists are coming to the conclusion that the only black bears you see in daylight are young ones. The really huge, older, dangerous, mainly carnivorous ones are nocturnal and hunt large game by night.
I want to conclude this very long post with the sentiment that I love bears and feel that wilderness would not be truly wild without these majestic predators. I would rather walk in the wild knowing I am at risk, than in an ecosystem castrated by human sentiment.