To gain more insight into bear attacks and how to prevent them, scientists recently completed a study—not yet published—examining 675 bear attacks on people. Their research revealed distinct patterns of bear behavior that can help people stay safe in bear habitat.

“There is a lot of mythology out there about why bear attacks happen,” says Tom Smith, a biologist at Brigham Young University in Utah.

“If I wanted to make a key point, it is that the vast majority of these negative encounters are avoidable. People don’t need to go out into bear country and get hurt, nor do bears. These incidents are largely preventable, but humans have to take more responsibility.”

Here's how to be smart in bear habitat—whether it's in the deep wilderness or your own backyard.

Find out which species live in the place where you live or plan to travel. Some places, such as Montana's Glacier National Park, are home to both grizzlies and black bears. It can be difficult to tell them apart, since black bears can also be brown, like grizzlies. However, black bears are generally smaller.

Notably, Smith says, brown bears inflicted more injuries than any other species in Alaska. The average brown bear encounter is more dangerous—3.5 times more likely to result in injury—than the average polar bear encounter, and 21 times more dangerous than the average black bear encounter, according to Smith and colleague Stephen Herrero, professor emeritus at the University of Calgary in Canada.

More than half of the attacks in the new analysis were over in less than three minutes, “consistent with the notion that the primary motivation for attacking bears is to neutralize a perceived threat, and once that is done they go on their way,” Smith says.

Don't unwittingly attract them.

Bears have a better sense of smell than dogs and love humans' food. So the main strategy to avoid run-ins is to minimize any scents or attractants on your body, campsite, or property.

"If you're a hiker, be more careful about various kind of scents and things that you would have on you," such as food, deodorant, and even chewing gum, Garshelis says.

Carry bear spray.

He recommends people practice in advance how to operate the spray, including being familiar with far it shoots. (Practice outdoors and upwind; bear spray is powerful stuff.) He also says a person traveling in bear country should wear the spray on a holster in front of their bodies, so that they're not fumbling for it if they run smack into a grizzly.

In a 2008 study that also involved Smith and Herrero, scientists found that bear spray was 92 percent effective in deterring attacks from the three species of North American bear in Alaska between 1985 and 2006. Ninety-eight percent of people carrying bear spray who got into close encounters with bears were uninjured.

Travel in groups.

Being alone in the wilderness can be fulfilling, but for safety's sake it's better to walk in a group of three people or more, he says. A bear is more likely to retreat if it sees or smells several people walking toward it than if a single person approaches. (See "Why Are Black Bear Attacks Up in Florida?")

If dogs are allowed in the area where you'll be, it's generally a good idea to bring them, since the canines often scare away bears. However, this approach can backfire: If a dog is ahead of its owner and then runs into a bear, the bear may chase it, which is not only dangerous to the dog but could endanger humans if the dog runs back to its owner.

Be alert for signs of bears.

If you see fresh scat, for instance, a bear has recently passed by. "It's a good idea to be very alert. Think through, 'How am I going to react?'"

Don't let yourself fall into a daze, either—stay present and look around as you walk.

If you're attacked or pursued, react according to the species of bear.

"Typically if you're in a place where there's just black bears, you would be bold and aggressive to a bear that approaches you," says Garshelis. Throwing things, standing tall, and yelling will drive away most black bears—although that strategy isn't foolproof.

When threatened, female grizzlies will often stand up, slap the ground, and make blowing sounds. However, "that means it's nervous; it's not aggressive," he says.

In Smith and Herrero's analysis of 675 bear attacks in Alaska, the vast majority of incidents in which bears charged occurred when people and bears confronted each other at close range, within ten yards (nine meters) or less.

In more than 50 percent of those situations, the person was not physically hurt. Of the 313 cases in which the bears injured the person, 36 percent of injuries were to legs and feet, 18 percent to the back, 18 percent to arms, and 9 percent to head and neck.

Never run.

"You can't outrun a bear," Garshelis says. "The best thing to do is walk away slowly from a bear if it already clearly sees you."

Keep watching the animal as you walk away, and some experts suggest speaking out loud in a calm voice.

WATCH: A bear can go from disinterested to dangerous in an instant. Do you know what to do if you're attacked by a startled grizzly?

Know when to play dead.

Only play dead after a bear has made contact with you.

If it's a black bear, try to fight back. If that strategy doesn't work, lay on your stomach (protecting your vital organs), clasp your hands on the back of your neck, and pull up your knees. At this point, the bear may give up and leave.

If it's a grizzly, do not try to defend yourself. "Once it's on you, and there's nothing else you can do, collapse and play dead," Garshelis says.

The analysis by Smith and Herrero also revealed that things don't always end well for the bear: In 600 physical run-ins with people, bears died 34 percent of the time from injury incurred during the incident or from subsequent management actions.

Be tolerant and put things in perspective.

"Tolerance goes a long way to living with wildlife," Garshelis says.

For instance, if you're a homeowner and like to put out birdseed, consider doing it in the winter, when birds really need it and when bears are hibernating—otherwise you could have an unwelcome visitor.

Todd Wilkinson is an environmental journalist. His most recent book is Grizzlies of Pilgrim Creek: An Intimate Portrait of 399, the Most Famous Bear of Greater Yellowstone, with photographer Thomas D. Mangelsen. Follow him on Twitter @bigartnature.