A mathematical model for plasmid replication and distribution in microbial populations