Giter Club home page Giter Club logo

benfordslaw-irpf's Introduction

This tool use Benford's Law to analise IRPF files (Brazilian Personal Income Tax)

I got to know Benford's Law in a documentary, and I found it curious how it works. There are several applications, such as analyzing fraud in the Personal Income Tax. After wasting some time to calculate my Personal Income Tax, I decided to do an analysis applying Bendord's Law on it.

Benford's Law works for naturally occurring collections, and the larger the database the better. In the IRPF files it can vary, but as the intention was to execute the programming with something fun.

The tool's output displays in text format the frequency of the first digits, the number of analyzed values and how many of these are valid numbers (which do not start with zero). Then a PNG graphic is generated.

How to use

Preparation

This tool read de data in file irpf.xml , so the first step is copy one or more IRPF XML to this file. To see them use:

find ~/ProgramasRFB/ -regextype sed -regex '.*/IRPF.*[0-9]\{11\}.*xml'

If you you want to analyze one file, just copy to irpf.xml:

cp /home/antunes/ProgramasRFB/IRPF2022/aplicacao/dados/YOUR-CPF/*.xml

But, if you want to analyze all XML, joint all in same file:

find ~/ProgramasRFB/ -regextype sed -regex '.*/IRPF.*[0-9]\{11\}.*xml' | awk '{print "cat " $1 " >> irpf.xml"}' | sh

Run Forrest, Run!

python3 benfordslaw-irpf.py

The output

Chart

This is example outup saved titled: BenfordsLaw-analysis-on-IRPF.png

output chart BenfordsLaw analysis on IRPF

Text

output text BenfordsLaw analysis on IRPF

benfordslaw-irpf's People

Contributors

antun3s avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.