Saturday, October 28, 2023

Leontief Model Simulation with Python Part 1: Simulating "Dynamic Input-Output Model" by RCD Sir with Python

I have simulated "Dynamic Input-Output Model" by RCD Sir shown in the following YouTube with Python.


This is my first step to experiment simulating Leontief's Input-Output econometric model: The first one is the basic model utilising the inverse matrix to find the output level.

The output is derived from the final demand multiplied by the inverse matrix of an identity matrix minus the coefficient matrix and the capital matrix.

A list of my Python code based on the mathematical modelling is as follows:

# importing necessary tools
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy.linalg

print('Simulating the example https://www.youtube.com/watch?v=KmVfmISjayA&t=134s')

Sctrs=['Sec1','Sec2','Sec3']

# A: Input Coefficient Matrix
A = np.array([[0.2, 0.3, 0.2],[0.4,0.1,0.2],[0.1,0.3,0.2]])
Pdf_A = pd.DataFrame(data = A,index = Sctrs,columns = Sctrs)
display('A: Input Coefficient Matrix',Pdf_A)

# B: Capital Coefficient Matrix
B = np.array([[0.1,0.2,0.1],[0.2,0.1,0.2],[0.1,0.2,0.1]])
Pdf_B = pd.DataFrame(data = B,index = Sctrs,columns = Sctrs)
display('B: Capital Coefficient Matrix',Pdf_B)

# G: Diagonal matrix of sector growth rates
G = np.array([[0.2,0,0],[0,0.2,0],[0,0,0.1]])
Pdf_G = pd.DataFrame(data = G,index = Sctrs,columns = Sctrs)
display('G: Diagonal matrix of sector growth rates',Pdf_G)

# F: Final Demand Vector
d = np.array([400,300,500])
Pdf_d = pd.DataFrame(data = d,index = Sctrs)
display('d: Final Demand Vector',Pdf_d)

# Identity Matrix
I=np.identity(len(A))
Pdf_I = pd.DataFrame(data = I,index = Sctrs)
display(f'I: {len(A)} by {len(A)} identity matrix',Pdf_I)


BG=np.dot(B,G)
Pdf_BG = pd.DataFrame(data = BG,index = Sctrs,columns = Sctrs)
display('BG is',Pdf_BG)

print('When the output vector is x \n x = Ax + BGx + d \n and therefore \n (I - A - BG)x = d .')

I_A_BG=I-A-BG
Pdf_I_A_BG = pd.DataFrame(data = I_A_BG,index = Sctrs,columns = Sctrs)
display('(I-A-BG) is',Pdf_I_A_BG)

print('Then \n x = (I - A - BG)^-1 d .')

Inv_I_A_BG=np.linalg.inv(I_A_BG)
Pdf_Inv_I_A_BG = pd.DataFrame(data = Inv_I_A_BG,index = Sctrs,columns = Sctrs)
display('(I-A-BG)^-1 is',Pdf_Inv_I_A_BG)

x= np.dot(Inv_I_A_BG,d)
Pdf_x = pd.DataFrame(data = x,index = Sctrs)
display('x = (I - A - BG)^-1 d =',Pdf_x)




Friday, October 20, 2023

Libertarian Remilia (Touhou Project)


Libertarian Remilia Scarlet (Touhou project (Touhou 東方 project )), Cause against Determinism! Freedom of will shall prevail!!

Remilia's say to Keine "You cannot change destiny while merely observing history." I recognise Sister Remilia retains the great philosophy of Metaphysical Libertarianism
 
Tool used: Clip Studio Paint Pro
 
These illustrations are posted in my Pixiv page so please visit https://www.pixiv.net/en/users/32334195!  





Monday, October 09, 2023

Younu Konpaku (Myon-chan) as an adorable idol

 


Youmu Konpaku 「魂魄 妖夢」 みょんちゃん(Myon-chan) posing as an adorable idol.

Tool used: Clip Studio Paint Pro

These illustrations are posted in my Pixiv page so please visit https://www.pixiv.net/en/users/32334195





 

 

 

 

Saturday, October 07, 2023

Youmu Konpaku 「魂魄 妖夢」 みょんちゃん(Myon-chan) with 白桜剣(Hakurouken) & 楼観剣(Roukanken)

 

Youmu Konpaku 「魂魄 妖夢」 みょんちゃん(Myon-chan) with 白桜剣(Hakurouken) & 楼観剣(Roukanken)

Tool used: Clip Studio Paint Pro

These illustrations are posted in my Pixiv page so please visit https://www.pixiv.net/en/users/32334195!  

One of the reasons why I am fond of her is being familiar with her personality. Her diligent, deterministic, humble, and caring personality together with her attractive appearance capture my heart. Also, her girly characteristic unexpectedly appears on some occasions where her adorability is emphasised.

 





Tuesday, October 03, 2023