Giter Site home page Giter Site logo

the-other-mariana / lagrange-for-gini-croatia Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 17.59 MB

Program that estimates the Gini coefficient of a country using Lagrange Interpolation for Lorenz curve approximation.

License: MIT License

Python 100.00%
lagrange-interpolation monte-carlo-methods sympy python gini-coefficient numerical-methods

lagrange-for-gini-croatia's Introduction

Estimating Croatia's GINI Coefficient using Lagrange Interpolation Method for Lorenz Curve Approximation

This project consists of a program that calculates the Gini coefficient in the case of Croatia 2018. For the gini calculation, the program first reads from a csv file containing the income distribution by tenths of population found in Eurostat. Then, creates the coordinates needed to plot Lorenz curve. The actual Lorenz curve is calculated as a polynomial approximation using Lagrange Interpolation Method with calculated coordinates. The program then calculates the gini coefficient by integrating x minus the lorenz function. Two other methods are added to calculate gini coefficient, but only for comparison.

The pdf document also in this repo explains further theory and procedures followed. Its LaTeX source file is NM_SeminarPaper.zip.

Specifications

Python version: Python 3.6.2
Matplotlib version: 2.1.2
Sympy version: 1.5.1
Numpy version: 1.14.1

Usage

  1. Download this repo and store it in your computer.
  2. Go to the folder's directory where the repo is stored.
  3. Run lagrange.py by typing in Powershell: python lagrange.py, once located in the project's directory.

Results

The Lorenz curve polynomial approximation using Lagrange Interpolation Method is the following:

alt text


If we plot a line from point to point (gray line) and compare it to the approximated lorenz curve (red line) we get:

alt text

Further Experiments

Additionally and outside of the projects strict boundaries, the method for integrating the Lorenz curve in order to get the Gini coefficent were three: Sympy's integrate function, Monte Carlo simulation and Riemann Sums. The following plot is the resulting time performance of these three. Interestingly, Monte Carlo simulation showed the most accurate result, with 97.91% of accuracy.

alt text

Monte Carlo Simulation is presented here in order to integrate the Lorenz Curve and get the Gini Coefficient, where the amount of tests increases to show how it works.

alt text

Making this project made me so happy.

lagrange-for-gini-croatia's People

Contributors

the-other-mariana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.