Throwing Coins - Inequality and Tax

Throwing Coins - Inequality and Tax preview image

1 collaborator

Rupertpassphotoneu Rupert Nagler (Author)

Tags

ergodicity 

Tagged by Rupert Nagler 9 months ago

game simulation 

Tagged by Rupert Nagler 9 months ago

gini 

Tagged by Rupert Nagler 9 months ago

inequality 

Tagged by Rupert Nagler 9 months ago

inequality & taxation 

Tagged by Rupert Nagler 9 months ago

wealth distribution 

Tagged by Rupert Nagler 9 months ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.1 • Viewed 67 times • Downloaded 2 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
  clear-all
  ask patches [set pcolor 104]
  setup-turtles
  set coins 0
  set tails 0
  update-lorenz-and-gini
  reset-ticks
end 

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
  ]
end 

to go
  playing
  taxing
  move-turtles
  if not any? turtles [stop]
  update-lorenz-and-gini
  tick
end 

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
  ]
end 

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
end 

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
      ]
    ]
  ]
end 

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
  ]
end 

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)
  ]
end 

There is only one version of this model, created 9 months 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' 9 months ago, by Rupert Nagler Download

This model does not have any ancestors.

This model does not have any descendants.