A few years ago, I learned about an interesting mathematical phenomenon known as Benfordâ€™s law, or the first digit law. The law states that most â€śnaturalâ€ť numbers begin with the number 1, followed by 2, followed by 3, and so on. There are many great blog posts and videos that do a good job of explaining this (see Wikipedia, Wolfram, or this video). Note that a cool application of Benfordâ€™s Law is in fraud detection.
IBM SPSS Statistics 24 makes it easy to build extensions based on R, Python, or SPSS syntax, so I decided to write a quick extension that graphs the distribution of a variableâ€™s most significant digit and compares it to the â€śpureâ€ť value as calculated by Benfordâ€™s Law.
As an example, I used the extension to plot country populations in 2014 (blue bars) with the Benfordâ€™s Law prediction (green line). Country populations seem to hold up to Benfordâ€™s Law quite well.
Download the extension for free today by navigating to the Extension Hub in SPSS Statistics 24. Try it on your own datasets to see if Benfordâ€™s Law holds true for your variables.
BONUS: Feel free to expand upon this extension by adding to the code. Simply open the Custom Dialog Builder for Extensions and click on the â€śOpen Installedâ€ť button to view and modify the SPSS syntax used for this extension.