IIabm/test.ipynb

98 lines
1.8 KiB
Plaintext
Raw Normal View History

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": [
{
"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",
"np.random.randint(0.5, 3.5)\n",
2023-03-14 17:51:17 +08:00
"p_remove = 0.9\n",
"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-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",
"version": "3.9.13"
2023-02-27 22:02:46 +08:00
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "bcdafc093860683ffb58d6956591562b7f8ed5d58147d17d71a5d4d6605a08df"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}