<style>
.markdown-body b {
font-weight: 700;
}
.markdown-body code,
code,
pre
{
max-height:80% !important;
font-size: 14px;
line-height: 115%;
/* color: #99999 !important; */
background-color: #ffe9e5;
}
.reveal {
font-size: 20px;
}
</style>
# math model :population
---
## 人口金字塔
<style>
image{
margin-top: 0px;
margin-bottom: 0px;
}
h3{
margin-bottom: 0px;
}
</style>

### ⬇️

---
## 模擬方法
將整個社會分成不同種人群,不同族群有不同的屬性,不同屬性會影響的生育能理和死亡率和狀態
---
## data format
<style>
.ss{
margin-left: auto;
margin-right: auto;
text-align: center
}
th,td{
border-bottom: 1px solid !important;
border-right: 1px solid!important;
border-left: 1px solid!important;
border-top: 1px solid!important;
text-align: center
}
</style>
[國家發展委員會](https://pop-proj.ndc.gov.tw/pyramid.aspx?uid=64&pid=60)
<table class="ss">
<tr>
<th>index</th>
<th >age</th>
<th >sex</th>
<th >religion</th>
<th >density</th>
<tr style="border=10px">
<td>0</td>
<td rowspan="4">5</td>
<td rowspan="2">0</td>
<td>0</td>
<td>0.4</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>0.3</td>
</tr>
<tr>
<td>2</td>
<td rowspan="2">1</td>
<td>0</td>
<td>0.2</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
<td>0.1</td>
</tr>
</table>
---
## age
shift people every 5 year
<table class="ss">
<tr>
<th>index</th>
<th >age</th>
<th >sex</th>
<th >religion</th>
<th >density</th>
<th>every 5 year</th>
<th >density</th>
<tr style="border=10px">
<td>0</td>
<td rowspan="4">5</td>
<td rowspan="2">0</td>
<td>0</td>
<td>0.4</td>
<td rowspan="8">➡️</td>
<td >0</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>0.3</td>
<td>0</td>
</tr>
<tr>
<td>2</td>
<td rowspan="2">1</td>
<td>0</td>
<td>0.2</td>
<td>0</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
<td>0.1</td>
<td>0</td>
</tr>
<tr style="border=10px">
<td>4</td>
<td rowspan="4">10</td>
<td rowspan="2">0</td>
<td>0</td>
<td>0.1</td>
<td>0.4</td>
</tr>
<tr>
<td>5</td>
<td>1</td>
<td>0.1</td>
<td>0.3</td>
</tr>
<tr>
<td>6</td>
<td rowspan="2">1</td>
<td>0</td>
<td>0.1</td>
<td>0.2</td>
</tr>
<tr>
<td>7</td>
<td>1</td>
<td>0.1</td>
<td>0.1</td>
</tr>
</table>
---
## born algothm data
$$
A=\begin{bmatrix}
0.4\\
0.3\\
0.2\\
0.1\\
\vdots\\
\end{bmatrix}
A^T=\begin{bmatrix}
0.4&
0.3&
0.2&
0.1&
\cdots\\
\end{bmatrix}
$$
---
## born algothm matrix
在兩人相遇為獨立式事件的前提下
$$A\cdot A^T=
\begin{bmatrix}
0.4\\
0.3\\
0.2\\
0.1\\
\vdots\\
\end{bmatrix}\cdot
{\begin{bmatrix}
0.4&
0.3&
0.2&
0.1&
\cdots\\
\end{bmatrix}}\\=\begin{bmatrix}
0.4*0.4 & 0.4*0.3 & 0.4*0.2 & 0.4*0.1 &\cdots\\
0.3*0.4 & 0.3*0.3 & 0.3*0.2 & 0.3*0.1 &\cdots\\
0.2*0.4 & 0.2*0.3 & 0.2*0.2 & 0.2*0.1 &\cdots\\\
0.1*0.4 & 0.1*0.3 & 0.1*0.2 & 0.1*0.1 &\cdots\\\
\vdots & \vdots& \vdots& \vdots& \ddots\\
\end{bmatrix}$$
---
## born mask
男男 或 女女 無法生育
$$
\begin{bmatrix}
0.4*0.4 & 0.4*0.3 & 0.4*0.2 & 0.4*0.1 &\cdots\\
0.3*0.4 & 0.3*0.3 & 0.3*0.2 & 0.3*0.1 &\cdots\\
0.2*0.4 & 0.2*0.3 & 0.2*0.2 & 0.2*0.1 &\cdots\\\
0.1*0.4 & 0.1*0.3 & 0.1*0.2 & 0.1*0.1 &\cdots\\\
\vdots & \vdots& \vdots& \vdots& \ddots\\
\end{bmatrix}\times \begin{bmatrix}
0& 0& 1& 1&\cdots\\
0& 0& 1& 1&\cdots\\
1& 1& 0& 0&\cdots\\
1& 1& 0& 0&\cdots\\
\vdots& \vdots& \vdots& \vdots& \ddots\\
\end{bmatrix}\\=\begin{bmatrix}
0 & 0 & 0.4*0.2 & 0.4*0.1 &\cdots\\
0 & 0 & 0.3*0.2 & 0.3*0.1 &\cdots\\
0.2*0.4 & 0.2*0.3 & 0 & 0 &\cdots\\\
0.1*0.4 & 0.1*0.3 & 0 & 0 &\cdots\\\
\vdots & \vdots& \vdots& \vdots& \ddots\\
\end{bmatrix}$$
---
### 特徵影響生育
同宗教生育率較高
$$\begin{bmatrix}
0 & 0 & 0.08 & 0.04 &\cdots\\
0 & 0 & 0.06 & 0.03 &\cdots\\
0.08 & 0.06 & 0 & 0 &\cdots\\\
0.04 & 0.03 & 0 & 0 &\cdots\\\
\vdots & \vdots& \vdots& \vdots& \ddots\\
\end{bmatrix} \times \begin{bmatrix}
0.9& 0.5& 0.9& 0.5&\cdots\\
0.5& 0.9& 0.5& 0.9&\cdots\\
0.9& 0.5& 0.9& 0.5&\cdots\\
0.5& 0.9& 0.5& 0.9&\cdots\\
\vdots& \vdots& \vdots& \vdots& \ddots\\
\end{bmatrix}$$
---
### 特徵混合
```graphviz
digraph google{
// layout=neato;
// layout=circo;
// layout=twopi;
fontname="Helvetica,Arial,sans-serif"
fontcolor=white
bgcolor="black"
//bgcolor="transparent"
node[shape=re,style=filled,color=white,colorscheme=ylgnbu7]
edge[color=white,fontcolor=white]
"0.01"->"男 0.005"[label="0.5"]
"0.01"->"女 0.005"[label="0.5"]
"男 0.005"->"男 父親宗教 0.0025"[label="0.5"]
"男 0.005"->"男 母親宗教 0.0025"[label="0.5"]
"女 0.005"->"女 父親宗教 0.0025"[label="0.5"]
"女 0.005"->"女 母親宗教 0.0025"[label="0.5"]
}
```
---
## dead?
$$
\begin{bmatrix}
0.4\\
0.3\\
0.2\\
0.1\\
\vdots\\
\end{bmatrix}\times\begin{bmatrix}
1-0.05\\
1-0.05\\
1-0.02\\
1-0.02\\
\vdots\\
\end{bmatrix}=
\begin{bmatrix}
0.380\\
0.285\\
0.196\\
0.980 \\
\vdots\\
\end{bmatrix}
$$
---
## overview?
$t$: 當前時間
$x_t$: 在t時的所有組群向量
$D_t$: 在t時的組群死亡權重向量
$W_t$: 在t時的組群生育權重向量
### $$x_{t+1} = (1-D_t) x_t+W_t(x_t\cdot x_t^T)$$
優點:可以擴展族群
缺點:非線性
---
## 結果比較
* 基督教:生育率降低
* 伊斯蘭教:生育率提高
* 佛教:死亡率降低
|  |  |  |
| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| |  | |
---
## 結果比較

{"title":"math model :population","breaks":true,"description":"View the slide with \"Slide Mode\".","metaMigratedAt":"2023-06-20T08:27:13.897Z","metaMigratedFrom":"YAML","contributors":"[{\"id\":\"88becfca-8111-457c-985b-2a052473a787\",\"add\":12168,\"del\":5867},{\"id\":\"b95999dd-326f-4f6a-938c-61b2fdeac18b\",\"add\":186,\"del\":271}]"}
math model :population 人口金字塔 ⬇️ 模擬方法 data format age born algothm data born algothm matrix born mask 特徵影響生育 特徵混合 dead? overview? 結果比較
結果比較