2023-02-27 22:02:46 +08:00
|
|
|
{
|
|
|
|
"cells": [
|
2023-02-28 16:56:12 +08:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-03-14 17:51:17 +08:00
|
|
|
"execution_count": 14,
|
2023-02-28 16:56:12 +08:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
2023-03-14 12:53:49 +08:00
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"85\n",
|
|
|
|
"63\n",
|
|
|
|
"51\n",
|
|
|
|
"26\n",
|
|
|
|
"30\n",
|
|
|
|
"4\n",
|
|
|
|
"7\n",
|
|
|
|
"1\n",
|
|
|
|
"17\n",
|
|
|
|
"81\n"
|
|
|
|
]
|
2023-03-14 17:51:17 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([2, 2])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 14,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
2023-02-28 16:56:12 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"import numpy as np\n",
|
|
|
|
"\n",
|
2023-03-14 12:53:49 +08:00
|
|
|
"np.random.randint(0.5, 3.5)\n",
|
2023-03-14 17:51:17 +08:00
|
|
|
"p_remove = 0.9\n",
|
2023-03-14 12:53:49 +08:00
|
|
|
"np.random.choice([True, False], p=[p_remove, 1-p_remove])\n",
|
|
|
|
"rng = np.random.default_rng(0)\n",
|
|
|
|
"for _ in range(10):\n",
|
2023-03-14 17:51:17 +08:00
|
|
|
" print(rng.integers(0,100))\n",
|
|
|
|
"np.random.choice([1, 2, 3], 2, p=[0.4, 0.4, 0.2])\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 19,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"2"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 19,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"share = 0.8\n",
|
|
|
|
"list_succ_firms = [1, 1]\n",
|
|
|
|
"round(share * len(list_succ_firms)) if round(share * len(list_succ_firms)) > 0 else 1"
|
2023-02-28 16:56:12 +08:00
|
|
|
]
|
2023-05-15 10:42:16 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 4,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"[0.17307692307692307, 0.19230769230769232, 0.20192307692307693, 0.21153846153846154, 0.22115384615384615]\n",
|
|
|
|
"[0.14899116146026878, 0.1819782155490595, 0.20111703154812216, 0.22226869439668717, 0.24564489704586234]\n",
|
|
|
|
"[0.10801741721030356, 0.16114305076975205, 0.19682056666851946, 0.2403971829915773, 0.29362178235984765]\n",
|
|
|
|
"[0.07643198434626533, 0.13926815562848321, 0.18799234648997357, 0.25376312466637047, 0.34254438886890737]\n"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"import math\n",
|
|
|
|
"size = [18,20,21,22,23]\n",
|
|
|
|
"p = [s / sum(size) for s in size]\n",
|
|
|
|
"print(p)\n",
|
|
|
|
"for beta in [0.1, 0.2, 0.3]:\n",
|
|
|
|
" damp_size = [math.exp(beta*s) for s in size]\n",
|
|
|
|
" print([s / sum(damp_size) for s in damp_size])\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 10,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"[0.16666666666666666, 0.5, 0.6666666666666666, 0.8333333333333334, 1.0]\n",
|
|
|
|
"[0.8359588020779368, 0.9330329915368074, 0.960264500792218, 0.9819330445619127, 1.0]\n",
|
|
|
|
"[0.408248290463863, 0.7071067811865476, 0.816496580927726, 0.9128709291752769, 1.0]\n",
|
|
|
|
"[0.23849484685087588, 0.5743491774985174, 0.7229811807984657, 0.8642810744472068, 1.0]\n"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"import math\n",
|
|
|
|
"size = [18,20,21,22,23]\n",
|
|
|
|
"p = [(s - min(size) + 1)/(max(size)-min(size)+1) for s in size]\n",
|
|
|
|
"print(p)\n",
|
|
|
|
"for beta in [0.1, 0.5, 0.8]:\n",
|
|
|
|
" p = [((s - min(size) + 1)/(max(size)-min(size)+1))**beta for s in size]\n",
|
|
|
|
" print(p)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 1,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"32\n"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"import multiprocess as mp\n",
|
|
|
|
"\n",
|
|
|
|
"print(mp.cpu_count())"
|
|
|
|
]
|
2023-02-27 22:02:46 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "base",
|
|
|
|
"language": "python",
|
|
|
|
"name": "python3"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 3
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython3",
|
2023-05-15 10:42:16 +08:00
|
|
|
"version": "3.8.8"
|
2023-02-27 22:02:46 +08:00
|
|
|
},
|
|
|
|
"orig_nbformat": 4,
|
|
|
|
"vscode": {
|
|
|
|
"interpreter": {
|
|
|
|
"hash": "bcdafc093860683ffb58d6956591562b7f8ed5d58147d17d71a5d4d6605a08df"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 2
|
|
|
|
}
|