Throwing Coins - Inequality and Tax

Throwing Coins - Inequality and Tax preview image

1 collaborator

Rupertpassphotoneu Rupert Nagler (Author)



Tagged by Rupert Nagler about 4 years ago

game simulation 

Tagged by Rupert Nagler about 4 years ago


Tagged by Rupert Nagler about 4 years ago


Tagged by Rupert Nagler about 4 years ago

inequality & taxation 

Tagged by Rupert Nagler about 4 years ago

wealth distribution 

Tagged by Rupert Nagler about 4 years ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.1 • Viewed 208 times • Downloaded 14 times • Run 0 times
Download the 'Throwing Coins - Inequality and Tax' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

Info tab cannot be displayed because of an encoding error

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

; Throwing Coins - Inequality and Tax.nlogo; Rupert Nagler Jan 2020

globals [
  gini-index-reserve ; actual Gini %
  lorenz-points ; list of Lorenz points
  coins ; number of thrown coins
  tails ; number of tails - results

turtles-own [
  wealth ; actual wealth of turtle
  tax ; actual amount of wealth tax turtle has payed

to setup
  ask patches [set pcolor 104]
  set coins 0
  set tails 0

to setup-turtles
  create-turtles num-turtles [
    set heading 0
    set color yellow
    set shape "circle"
    ifelse random-init-wealth? [; random distributuion
      set wealth random-float init-wealth
    ][; equal distribution
      set wealth init-wealth
    set tax 0
    ; place turtle on plain according id(own) on x-axsis and wealth on y-axsis
    setxy (who / num-turtles * 100) wealth

to go
  if not any? turtles [stop]

to playing ; each turtle throws coin
  ask turtles [ ; leverage is the fraction of wealth to bet
    set wealth win (wealth * leverage) + wealth * (1 - leverage); compute new wealth on thrown coin

to-report win [stake] ; function to compute new wealth according to coin throw with multiplicative and additive win
  let m mult-heads ; initialise with win factors
  let a add-heads
  set coins coins + 1
  if one-of list false true [ ; throw coin, in case loose change to loose factors
    set m mult-tails
    set a add-tails
    set tails tails + 1
  report (stake * m) + a

to taxing
  if tax-factor > 0 [ ; do we have to compute taxes?
    let notax-turtles [self] of no-turtles ; empty unsorted list of turtles
    let sumtax 0
    ask turtles [ ; pay wealth tax
      ifelse wealth > tax-limit [ ; is there a tax to pay?
          set tax wealth * tax-factor
          set wealth wealth - tax ; turtle pays tax
          set sumtax sumtax + tax ; add to total tax collected
        ] [
          set tax 0
          set notax-turtles lput self notax-turtles ; add to list of notax-turtles
    let count-notax-turtles length notax-turtles ; number of notax-turtles
    ifelse redist-all? or (count-notax-turtles <= 0) [ ; do we have to redistribute to all turtles?
      let mtax (sumtax / count turtles) ; divide total tax between all turtles
      ask turtles [ ; redistribute tax to all turtles
        set wealth wealth + mtax ; redistribute
    ] [; divide total tax between all no-tax-turtles
      let mtax (sumtax / count-notax-turtles)
      ask turtle-set notax-turtles [ ; changes list into agentset
        set wealth wealth + mtax ; redistribute

to move-turtles ; according to new wealth
  ask turtles [
    if turtles-die? [ ; should bancrupt turtles die?
      if wealth < 1.0E-10 [die]
    set ycor (wealth + min [wealth] of turtles) / max [wealth] of turtles * 100

to update-lorenz-and-gini
  ; recompute value of gini-index-reserve and the points in lorenz-points for the Lorenz and Gini-Index plots
  let sorted-wealths sort [wealth] of turtles
  let total-wealth sum sorted-wealths
  let wealth-sum-so-far 0
  let index 0
  let c-turtles count turtles
  set gini-index-reserve 0
  set lorenz-points []
  ; now actually plot the Lorenz curve -- along the way, we also calculate the Gini index
  repeat c-turtles [
    set wealth-sum-so-far (wealth-sum-so-far + item index sorted-wealths)
    set lorenz-points lput ((wealth-sum-so-far / total-wealth) * 100) lorenz-points
    set index (index + 1)
    set gini-index-reserve gini-index-reserve + (index / c-turtles) - (wealth-sum-so-far / total-wealth)

There is only one version of this model, created about 4 years ago by Rupert Nagler.

Attached files

File Type Description Last updated
Throwing Coins - Inequality and Tax.png preview Preview for 'Throwing Coins - Inequality and Tax' about 4 years ago, by Rupert Nagler Download

This model does not have any ancestors.

This model does not have any descendants.