287 lines
141 KiB
Plaintext
287 lines
141 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {
|
||
|
"ExecuteTime": {
|
||
|
"end_time": "2022-08-18T09:35:27.540830Z",
|
||
|
"start_time": "2022-08-18T11:35:27.028238+02:00"
|
||
|
},
|
||
|
"execution": {
|
||
|
"iopub.execute_input": "2022-08-20T06:18:30.408Z",
|
||
|
"iopub.status.busy": "2022-08-20T06:18:30.402Z",
|
||
|
"iopub.status.idle": "2022-08-20T06:18:30.968Z",
|
||
|
"shell.execute_reply": "2022-08-20T06:18:30.957Z"
|
||
|
},
|
||
|
"pycharm": {
|
||
|
"name": "#%%\n"
|
||
|
}
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"%matplotlib inline\n",
|
||
|
"\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"\n",
|
||
|
"from walker import create_context_map, next_step_proposal, plot_trajectory, sample_next_step"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"pycharm": {
|
||
|
"name": "#%% md\n"
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"# Examples of how the code works"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nteract": {
|
||
|
"transient": {
|
||
|
"deleting": false
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"The walker code works in the following way:\n",
|
||
|
"\n",
|
||
|
"The function `next_step_proposal` to creates a map of the probability of ending up in any position, given the current position, some map parameters, and the size of the map"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {
|
||
|
"execution": {
|
||
|
"iopub.execute_input": "2022-08-20T06:18:30.980Z",
|
||
|
"iopub.status.busy": "2022-08-20T06:18:30.974Z",
|
||
|
"iopub.status.idle": "2022-08-20T06:18:31.108Z",
|
||
|
"shell.execute_reply": "2022-08-20T06:18:31.138Z"
|
||
|
},
|
||
|
"pycharm": {
|
||
|
"name": "#%%\n"
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.image.AxesImage at 0x7fc6b6844400>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAQsAAAECCAYAAADpWvKaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAFjVJREFUeJzt3UuPJFeZxvH/eyIysy5upt0YWza2GIS8gcW0UAuQGI2MkMB4Y1gwMhsshNQszAcwK1iyQUhIgyUjWTYLYLyx8MJiQL1hxcVIiDFoEBZY0LTlxm43truqMiPivLM4Jy9dXeU+dc2s9POTSlkVlRl1oqvy6fdcIsLcHRGRmwnzboCInAwKCxEporAQkSIKCxEporAQkSIKCxEpMvewMLP7zeyPZvaimT067/YcBjN7ycz+18x+a2bP521nzOxnZvan/HjrvNtZysyeMLPLZvbCzLYdj8eS7+Tf5+/M7MPza3mZXY7vG2b29/w7/K2ZPTDzva/l4/ujmX16Pq0+fnMNCzOrgP8CPgN8EPiCmX1wnm06RJ9w97Pufi5//Shwwd3vBS7kr0+KJ4H7t23b7Xg+A9ybP84Djx1TGw/iSW48PoBv59/hWXd/DiD/fT4EfCi/5rv573jpzbuy+Ajworv/2d1HwI+AB+fcpqPyIPBU/vwp4LNzbMueuPvPgSvbNu92PA8C3/fkF8BpM7vzeFq6P7sc324eBH7k7kN3/wvwIunveO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rv8paGLIRB3QeeHVlncsrtwDwxkrMgUM+hyTt923vwi4yJ1qUJSJFVFmUmpnKHF9X04PhlRFr6PoOvVRZrA1
|
||
|
"text/plain": [
|
||
|
"<Figure size 288x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"proposal = next_step_proposal(current_i=100, current_j=50, sigma_i=10, sigma_j=5, size=200)\n",
|
||
|
"plt.matshow(proposal)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nteract": {
|
||
|
"transient": {
|
||
|
"deleting": false
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"The function `create_context_map` creates a context map that tell us regions in the image with a higher probability of being looked at (e.g., very bright spots in an image)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {
|
||
|
"execution": {
|
||
|
"iopub.execute_input": "2022-08-20T06:18:31.125Z",
|
||
|
"iopub.status.busy": "2022-08-20T06:18:31.119Z",
|
||
|
"iopub.status.idle": "2022-08-20T06:18:31.352Z",
|
||
|
"shell.execute_reply": "2022-08-20T06:18:31.385Z"
|
||
|
},
|
||
|
"pycharm": {
|
||
|
"name": "#%%\n"
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.colorbar.Colorbar at 0x7fc6b68df080>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAASEAAAD0CAYAAADUmZAzAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcm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W5e5E3dkNqWfCuouOKKnT5Y5KY7TqRAeg7SgYDYqROR4mB44GRA2EBHWwKat3Qux7XbU9eAGAUsUBTdt7O1+/XHVrrj38RbwT2f8GNpN0oJ2lbVcHnvbdTtt1605tv1kNfADmCpMik1ImRUSRYr1FBIoDkqQerwFAKmjtZKiu9lnXgi4C3uEpUIuBjYhYJwakCCx2Hp0MiMCuNQO7pElRUmXfwmw3LlmGTX90/aXBqPr7eDX9TdpASSdNg5cDT3GTJv7HAxPvlfZQqWr/vEKU+pHJdHFTqc9xvuc68kyB0DMyO/4kJ3kuiRHTJ0vomQKhNvsW+DA2+/b3HttZBepZYT1zt2uXLSH7DN0SaCZ3M6tpI9oeX9ROEtaQWzbhDlQfxWJEa25Xt4iAZhWFO1F9/7LSXbtsaSVzbMvxdEvI3vcRO1l7c3bHugUU7227ojt3wyYFd8dkrpRJKaVSpkop2qyfUvrYW5IlVFVsgFehVqFWt0onoa6FOilaSrMMVQQtghRBChDuWDEXpxTTVdyj7OKqW5NSw6VN9+fAsxG6C3eM5I7V7JaHTmesvXPaHq7YlCzGcMMms3qkpEZItxQ1m9bVLEaqXX9zWyc1K/BGcnLH4BkCIVVdROQrsRq9E/Btqvreoz8QWO9I5352wrrDeZCtOxYP1b5vT2EkGodGBRmaHvzqrkB2x/xBzmAEDC4aFUpsn7wzqWxAKJ36UhBK7sSc3bG83QC
|
||
|
"text/plain": [
|
||
|
"<Figure size 288x288 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"context_map = create_context_map(size=150, map_type='hills')\n",
|
||
|
"plt.matshow(context_map)\n",
|
||
|
"plt.colorbar()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nteract": {
|
||
|
"transient": {
|
||
|
"deleting": false
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"The function `sample_next_step` calls `next_step_proposal`, combines it with the context map that is passed to it (in `compute_next_step_probability`), and then stochastically selects the next step."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"pycharm": {
|
||
|
"name": "#%% md\n"
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"# How to simulate a trajectory\n",
|
||
|
"\n",
|
||
|
"in order to use the walker, the user has to create a context map. Then, for a number of timesteps, sample a step, always passing along the new position information."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {
|
||
|
"execution": {
|
||
|
"iopub.execute_input": "2022-08-20T06:18:31.369Z",
|
||
|
"iopub.status.busy": "2022-08-20T06:18:31.360Z",
|
||
|
"iopub.status.idle": "2022-08-20T06:18:32.535Z",
|
||
|
"shell.execute_reply": "2022-08-20T06:18:32.542Z"
|
||
|
},
|
||
|
"pycharm": {
|
||
|
"name": "#%%\n"
|
||
|
}
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"i, j = 100, 50 # initial position\n",
|
||
|
"sigma_i, sigma_j = 3, 4 # parameters of the next step map\n",
|
||
|
"size = 200 # size of the image\n",
|
||
|
"context_map = create_context_map(size, 'hills') # fixed context map\n",
|
||
|
"\n",
|
||
|
"# Sample a next step 1000 times\n",
|
||
|
"trajectory = []\n",
|
||
|
"for _ in range(1000):\n",
|
||
|
" i, j = sample_next_step(i, j, sigma_i, sigma_j, context_map)\n",
|
||
|
" trajectory.append((i, j))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {
|
||
|
"execution": {
|
||
|
"iopub.execute_input": "2022-08-20T06:18:32.556Z",
|
||
|
"iopub.status.busy": "2022-08-20T06:18:32.553Z",
|
||
|
"iopub.status.idle": "2022-08-20T06:18:32.670Z",
|
||
|
"shell.execute_reply": "2022-08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HNZ/IWVGwWa7kWLDsdtNY1qCrJKZJhkjI3l1TNtu7TbTBo1NDZGsi4xzu5gAb2hkktyGPjMOYTeGoOxVpggFTiZAYXh1HFV2MU0NadQRb+crTNdbrbdfdmo+CytCVf3IgJGPp26Snhe9tbFZSHUCz+S6yANWDW6iNDAb5KhcKxmlVnuGB41cqQG11t9uy8BZ7CoDsKg2C1EVSwHRgQWCgEYJ1KldokvouohRiOjUwDkKESNOGIWIQKqSKFhwQblaknADFr0wgjZgzIwQA3ql7sxZJfGGYyHKIMiERJmaU1S1hNWgiArI4tRAsX6YabOQooJUOQ3sEwygSwUoWMcCcyr2G2Yp9pvgjL1TwUIISWIx8vYsSIkQoyC5tgsRBNzUPa83lFUSUPVEFbUn/6GiKpOquVLHznbUNK9eNyqIN/oODJzeTlE/DxfYXUAN2eFCGSjEGTMBs1e4FbdzK4uBherM22YWOkqFIEkUnQRIpChfmUUZ8LHVww1PvB5OSdnKFEN/NXBhYLeoq4AxpertgLNR5ElOnYBHCRwymzCgmOsyQAAGFhFzIaKjOACLyRGYhNBLXj37FLCQAjoFlZACxiQIzCASjCnoyinOWaBGzwYM1eAZ64QhY17eZjTFVeXBooDGgFlMsInOWET2AgEoRl6z3wSWwrKCu5+XidlwohCijgNOCSkxehZErm3P7Va2mM/UzwJCfmeibLdswCIbQxNJAVZjF4COJWevIHGT2OxFqMDhFx1vmwAcWDRAIu24K322GzILkILEqLIJwK24RQVxRi0zIAW1ehN0dGLCgJW/QC3eDiiSXie6niXJrIO0E0kKYAC6CminNW7T4Zy0iUS1k8FGC7V+vjMHQEHKLGYBxXzInwFgPvSY4z6rIZTQccSIUpkUnl0k4TxBQBingJ4TuhSxoEKnqIZRVUsMMICcFiofZGRRVsA
|
||
|
"text/plain": [
|
||
|
"<Figure size 288x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plot_trajectory(trajectory, context_map)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"pycharm": {
|
||
|
"name": "#%%\n"
|
||
|
}
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"hide_input": false,
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3 (ipykernel)",
|
||
|
"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.10.11"
|
||
|
},
|
||
|
"nteract": {
|
||
|
"version": "0.28.0"
|
||
|
},
|
||
|
"toc": {
|
||
|
"nav_menu": {
|
||
|
"height": "83px",
|
||
|
"width": "252px"
|
||
|
},
|
||
|
"navigate_menu": true,
|
||
|
"number_sections": true,
|
||
|
"sideBar": true,
|
||
|
"threshold": 4,
|
||
|
"toc_cell": false,
|
||
|
"toc_section_display": "block",
|
||
|
"toc_window_display": false
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 1
|
||
|
}
|