benfords-law/README.md

59 lines
2.5 KiB
Markdown
Raw Normal View History

2020-11-14 02:25:28 +00:00
# benfords-law
2020-11-14 15:44:42 +00:00
This was a test to determine if random numbers follow [Benford's Law](https://en.wikipedia.org/wiki/Benford%27s_law). I suspect it has more to do with the distribution real life data collected from than truly random numbers. If this is true, maybe this is why it works for fraud detection.
### Results
With One-Hundred-Million samples of random numbers between 0 and 9,999,999,999,999,999, the number of leading digits was the following:
2020-11-14 17:25:49 +00:00
```shell
$ ./benfords-law.exe
2020/11/14 10:24:18 generating numbers...
2020/11/14 10:24:19 18% completed generating and analyzing samples
2020/11/14 10:24:20 37% completed generating and analyzing samples
2020/11/14 10:24:21 56% completed generating and analyzing samples
2020/11/14 10:24:22 75% completed generating and analyzing samples
2020/11/14 10:24:23 93% completed generating and analyzing samples
2020/11/14 10:24:24 done.
1: 1108503 (11.085030%)
2: 1111584 (11.115840%)
3: 1111726 (11.117260%)
4: 1111122 (11.111220%)
5: 1110443 (11.104430%)
6: 1111248 (11.112480%)
7: 1111496 (11.114960%)
8: 1111777 (11.117770%)
9: 1112101 (11.121010%)
Press 'Enter' to continue...
```
2020-11-14 15:44:42 +00:00
This shows that Benford's law only works when the data is not random, such as natural data gathered in real life. This is because for data which Benford's law does work, it's natural data generated following a [power law](https://en.wikipedia.org/wiki/Power_law), which is quite common in nature.
2020-11-15 03:31:19 +00:00
### Run this program yourself
If you wish to run this program yourself, you can download it from the releases page for Windows or Linux. You can also build it yourself, instructions below:
### Build Prerequisites
You can have pretty much any mainstream Operating System or CPU architecture out there, but you need some buildtime dependancies on your system to move forward. You may already have these, you'll know if you do.
1. Install Go https://golang.org/, if you don't know what this is, yes that is a picture of a gopher on the home page but this is no joke.
2. Install Git https://git-scm.com/downloads, this is version control software which is used to download this code to be available on your system sp you can run it yourself if you like.
2020-11-15 03:31:19 +00:00
### Build Instructions
From a command prompt / shell or whatever you got, clone this repository using git.
```shell
git clone https://deadbeef.codes/steven/benfords-law.git
```
Change directory into the downloaded local copy, then build the program using Go.
```shell
cd benfords-law
go build .
```
You will be left with an executable file named benfords-law in the same directory.