DavidCico / Benfords-law-with-JAVA

In this repository, a program is written in JAVA to check whether a dataset follows Benford's law.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Benfords-law-with-JAVA

The purpose of this project is to verify whether a given data set follows the distribution of Benford's Law

Background

Benford's Law is an observation about the frequency distribution of the leading digits of a number from a table of physical constants or statistical data where the probability of digit `1` to occur is about 30.1% rather than 10% as one might expects if all digits were equally likely.

This implies that a number in a statistical data or a table of physical constants is more likely to begin with smaller digit than larger ones.

Project Structure

The project contains 4 files:

  • Benford.java where the different methods are implemented for obtaining the data, and calculating the number of occurrence of first digits by reading a String line.
  • Driver.java (main) to run the program with choice of data handling by the user and, finally will print a graph for the first digits occurrence (1 to 9), that can be compared with Benford's law.
  • AAPL.csv with the daily adjusted returns of "Apple" stocks for 5 years.
  • household_power_consumption.csv with individual household electric power consumption from UCI repository.
Data can be obtained by reading a CSV file, or generated randomly following a uniform or Gaussian distribution (for checking). CSV reading has been chosen as it is one of the most common ways to get and read data. Data is then stored into a HashMap structure to be treated.

Note

One of the best visualization effort for this law can be found at Testing Benford's Law

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

David Cicoria - Initial work - DavidCico

See also the list of contributors who participated in this project.

About

In this repository, a program is written in JAVA to check whether a dataset follows Benford's law.


Languages

Language:Java 100.0%