Confidence expresses itself in body language, to which we’re all very attuned, even though we might not realise it. Animals can sense this too – even with humans, and we’re all familiar with the sorts of displays of aggression and submission all species of animals display in their relations with each other.
Being calm and confident even when you don’t feel like it, can get you out of a lot of potential trouble. Standing as tall as you can, relaxing, taking a few slow, deep breaths and then walking purposefully, will actually make you feel calmer and more confident inside. Aggressors often don’t expect positive reactions, and just as they will become more aggressive if people look like an easy target, they can back off if presented with someone who might be more problematical than they’d first calculated.
But you can’t count on this, so avoid dark areas where there’s nobody passing by, areas where feral urban youth might congregate – and other obvious problems areas.