{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "$nCycles$ - number of simulation cycles\n", "\n", "$nBuyers$ - number of the buyers\n", "\n", "$nSellers$ - number of the sellers\n", "\n", "$seed$ - the seed of the random numbers\n", "\n", "$d_{1a}$ - the lower bound for random uniform numbers, for the buyers\n", "\n", "$d_{1b}$ - the upper bound for random uniform numbers for the buyers\n", "\n", "$d_{2a}$ - the lower bound for random uniform numbers, for the sellers\n", "\n", "$d_{2b}$ - the upper bound for random uniform numbers for the sellers\n", "\n", "initial buyer $i$ reservation price, different for each buyer: $p_{b,i}=\\frac{1} {1 + u_i}$ with $u_i\\sim\\mathcal{U}(d_{1a},d_{1b})$\n", "\n", "initial seller j reservation price, different for each seller: $p_{s,j}=1 + u_j$ with $u_j\\sim\\mathcal{U}(d_{2a},d_{2b})$\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "levels of gray\n", "https://en.wikipedia.org/wiki/Shades_of_gray" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "%pylab inline\n", "import numpy as np\n", "import pylab as plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "def plotCurves(d1a,d1b,d2a,d2b):\n", "\n", " nBuyers= 10000\n", " nSellers=10\n", "\n", "\n", " seed=111\n", " np.random.seed(seed)\n", "\n", " buyerPriceList=[]\n", " sellerPriceList=[]\n", "\n", " for i in range(nBuyers):\n", " eps=np.random.uniform(d1a,d1b)\n", " if eps < 0:\n", " buyerPriceList.append(1/(1+abs(eps)))\n", " else:\n", " buyerPriceList.append(1+eps)\n", " for j in range(nSellers):\n", " eps=np.random.uniform(d2a,d2b)\n", " if eps < 0:\n", " sellerPriceList.append(1/(1+abs(eps)))\n", " else:\n", " sellerPriceList.append(1+eps)\n", " \n", " fig =plt.figure(0)\n", " ax1 = fig.add_subplot(111)\n", " ax1.plot(sorted(buyerPriceList,reverse=True),color=\"black\");\n", " plt.title(\"Demand curve in black, offer curve in gray\",y=1.1)\n", " xlabel(\"the agents (buyers in the bottom scale, sellers in the top one)\");\n", " ylabel(\"agents' reservation prices\"); \n", " ax2 = ax1.twiny()\n", " ax2.plot(sorted(sellerPriceList),\"silver\");" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "plotCurves(-0.09,0.01,-0.01,0.09)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plotCurves(-0.11,-0.01,0.01,0.11)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plotCurves(-0.05,0.05,-0.05,0.05)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plotCurves(-0.10,0.10,-0.10,0.10)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.0" } }, "nbformat": 4, "nbformat_minor": 2 }