If you can justify taking action, take action. I have always felt that if you decide to carry, that means that you've agreed to the possibility of taking a human life if it becomes necessary. The issue is whether you decide to shoot or not, and why. You have to reason and justify in your head in about a half of a second.

For me, circumstances would dictate what I would do. There is no doubt I'm going for my gun, that's a certain fact. The question is when? I will go for it the instant that I safely can. If I am not seen, I will draw and get as close to the assailant as possible without being seen. I will then announce myself and pull the trigger as many times as it takes to drop the dirtbag. We had a trainer come in for a tactics related course who got into a shooting at a gas station. Thug enters and pulls a gun on the clerk. Cop was down one of the isles getting a bottle of pop and sees it, so he draws and sneaks up on the thug. Cop gets within a foot of the kid on the kid's 7 o'clock, yells "POLICE!" as loud as he could and then immediately pops the thug in the grape with a single shot. Game over. Store clerk told investigators that he heard the off-duty cop yell "police!" and then shoot the suspect. The cop said that he yelled "police" only for the benefit of the clerk.

This is ideally how I would do it. If I could not sneak up, I'd likely just hold as best of an advantageous position as possible behind any possible cover and send rounds downrange the instant that I knew it was a robbery or assault and that there was a weapon in play. Minnesota RECOMMENDS that a warning is given prior to the use of any force. As a cop, I would be judged in my actions like I would be as an on-duty cop, as I am using my gun under the authority of my department and our policies. As such, I am acting as a representative of my agency. Because of that, we're encouraged to give a warning if it is deemed feasible. However, this is rarely scrutinized in deadly force situations. All I have to do is explain that I was alone and had no backup, so I did not have anyone to cover me. I saw an immediate threat of death to the clerk, and if I made my presence known, my life would be in danger because action always beats reaction. If I lost on the reaction curve, I could be killed, or the clerk could be killed before I could shoot and STOP ( ) the suspect. That's why I basically executed the suspect. Besides that, there was no guarantee that my first round would incapacitate, so I needed to make sure I had the most accurate shot possible for as fast of incapacitation as possible. Additionally, I know through my training that criminals will kill witnesses to avoid prosecution, and I had reason to believe that the suspect would kill the clerk once he got the money/prescription drugs/lottery tickets/whatever.
If the criminal had regard for human life, they wouldn't be threatening a person with gun or knife in the first place.

My only issue with yelling "police" (for you obviously) is that the perp probably has his gun pointed at the clerk with their finger on the trigger...and you yelling police all of the sudden might startle them into pulling the trigger (by accident, but still)...