The goal of this research is to introduce an improved method for detecting atrial fibrillation (AF). The foundation of our algorithm is the irregularity of the RR intervals in the electrocardiogram (ECG) signal, and their correlation with AF. Three statistical techniques, including root mean squares of successive differences (RMSSD), turning points ratio (TPR), and Shannon entropy (SE), are used to detect RR interval irregularity. We use the Massachusetts Institution of Technology / Beth Israel Hospital (MIT-BIH) atrial fibrillation databases and their annotations to tune the parameters of the statistical methods by biogeography-based optimization (BBO), which is an evolutionary optimization algorithm. We trained each statistical method to diagnose AF on each database. Then each trained method was tested on the rest of the databases. We were able to obtain accuracy levels as high as 99% for the detection of AF in the trained databases. We obtained accuracy levels of up to 75% in the tested databases. v