[PYTHON] I checked the gift tax amount

Premise

What i did

At the same time, I also visualized the tax reduction when purchasing my home. https://www.nta.go.jp/taxanswer/sozoku/4508.htm

reference

https://www.nta.go.jp/taxanswer/zoyo/4408.htm

Visualization

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

def before_offset(x):
    return 110

def before_offset_home(x):
    return 110 + 1200

def after_offset(x):
    offset = 0
    if x <= 200:     offset = 0
    elif x <= 400:   offset = 10
    elif x <= 600:   offset = 30
    elif x <= 1000:  offset = 90
    elif x <= 1500:  offset = 190
    elif x <= 3000 : offset = 265
    elif x <= 4500 : offset = 415
    elif x > 4500:   offset = 640
    return offset

def ratio(x):
    r = 0.0
    if x <= 200:     r = 0.1
    elif x <= 400:   r = 0.15
    elif x <= 600:   r = 0.2
    elif x <= 1000:  r = 0.3
    elif x <= 1500:  r = 0.4
    elif x <= 3000 : r = 0.45
    elif x <= 4500 : r = 0.5
    elif x > 4500 :  r = 0.55
    return r

def tax(x):
    before_muliply = x - before_offset(x)
    if before_muliply < 0 : return 0
    after_multiply = before_muliply * ratio(before_muliply)
    return after_multiply - after_offset(before_muliply)

def tax_home(x):
    before_muliply = x - before_offset_home(x)
    if before_muliply < 0 : return 0
    after_multiply = before_muliply * ratio(before_muliply)
    return after_multiply - after_offset(before_muliply)


v_tax = np.vectorize(tax)
v_tax_home = np.vectorize(tax_home)

x = np.linspace(0, 5000, 5001)

y = v_tax(x)
y_home = v_tax_home(x)

fig, ax = plt.subplots()
ax.plot(x,y, color='blue', label='normal')
ax.plot(x,y_home, color='green', label='home')
ax.legend()
ax.set_xlabel('given')
ax.set_ylabel('tax')

tax.png

What I found

Impressions

I wonder if the officials are doing their best in Excel.

I was skeptical about income tax, gift tax, and discretized taxes. It turned out that it was Piecewise linear, and it turned out that it was easy to understand.

Recommended Posts

I checked the gift tax amount
I checked the contents of docker volume
I checked the options of copyMakeBorder of OpenCV
I checked the library for using the Gracenote API
I checked the processing speed of numpy one-dimensionalization
I checked the calendar deleted in Qiita Advent Calendar 2016
I checked the output specifications of PyTorch's Bidirectional LSTM
I checked out the versions of Blender and Python
I counted the grains
I checked the Python package pre-installed in Google Cloud Dataflow
I tweeted from the terminal!
I touched the Qiita API
I tried the changefinder library!
I downloaded the python source
I read the SHAP paper
I checked the distribution of the number of video views of "Flag-chan!" [Python] [Graph]
I checked the usage status of the parking lot from satellite images.
I checked the image of Science University on Twitter with Word2Vec.