Remember the battle of Endor? A bunch of cuddly teddy bears, with sticks, kicked the crap outta the Storm Troopers.
Just like ninjas (originally angry farmers) took out samurai (trained combatants)
training may be a large portion of outcome, but other factors such as desparation can also edge a battle the other way.
besides, only one storm trooper got shot, but if you notice they couldn't hit the broad side of a barn with their aim either.