I have a pistol, and I know how to use it. Really well. I always carry it in the country on our place whether I'm in the truck or on the mt bike. We have poisonous snakes as well as criminals. I don't go road riding alone out in Pointe Coupee Parish- too rural. We don't even have cell towers in a lot of places. My concern was always a fall and injury, but serial killers are best avoided in a place that remote.
I don't carry it in the city, because the police have s**t fits even though I have a permit. Besides, It scares the kids in the coffeehouses. The best way to deal with an assailant on foot is to give two teeth, lay into the pedals, and ride straight through them. I did have a soviet trained fencing coach spend a year teaching me how to run people through so it may be a bigger mind trick for some of you all than for me. Become a weapon. The idea is to knock them down at the least, preferably injure them so they don't came after you, then get away and around other people. The bastard who tried to mug me for my shiny new Zaskar a few years back will never screw with a woman on a bike again.
Karate? You have to get off the bike for that. Then you're stuck. Pepper spray? Great stuff if you're upwind. I gave myself a face full of dog repellent once and am leary of sprays.
Remember, A bike is more mobile than a car- even on a road bike you can hop curbs, take sidewalks, hit the dirt. Getting away is going to always be more effective than fighting. I fenced competively for fifteen years and cross trained in a boxing gym for six of those years. I can kick ***, and I think shoot them or flee is best.
Being aware of your surroundings is the key. You know a creep when you see him coming. Listen to your instincts. If you ride alone aren't you over that Be A Nice Girl crap by now?

Miss Liz