Analysis and modeling of resistive switching statistics