$nCycles$ - number of simulation cycles
$nBuyers$ - number of the buyers
$nSellers$ - number of the sellers
$seed$ - the seed of the random numbers
$d_{1a}$ - the lower bound for random uniform numbers, for the buyers
$d_{1b}$ - the upper bound for random uniform numbers for the buyers
$d_{2a}$ - the lower bound for random uniform numbers, for the sellers
$d_{2b}$ - the upper bound for random uniform numbers for the sellers
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})$
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})$
levels of gray https://en.wikipedia.org/wiki/Shades_of_gray
%pylab inline
import numpy as np
import pylab as plt
def plotCurves(d1a,d1b,d2a,d2b):
nBuyers= 10000
nSellers=10
seed=111
np.random.seed(seed)
buyerPriceList=[]
sellerPriceList=[]
for i in range(nBuyers):
eps=np.random.uniform(d1a,d1b)
if eps < 0:
buyerPriceList.append(1/(1+abs(eps)))
else:
buyerPriceList.append(1+eps)
for j in range(nSellers):
eps=np.random.uniform(d2a,d2b)
if eps < 0:
sellerPriceList.append(1/(1+abs(eps)))
else:
sellerPriceList.append(1+eps)
fig =plt.figure(0)
ax1 = fig.add_subplot(111)
ax1.plot(sorted(buyerPriceList,reverse=True),color="black");
plt.title("Demand curve in black, offer curve in gray",y=1.1)
xlabel("the agents (buyers in the bottom scale, sellers in the top one)");
ylabel("agents' reservation prices");
ax2 = ax1.twiny()
ax2.plot(sorted(sellerPriceList),"silver");
plotCurves(-0.09,0.01,-0.01,0.09)
plotCurves(-0.11,-0.01,0.01,0.11)
plotCurves(-0.05,0.05,-0.05,0.05)
plotCurves(-0.10,0.10,-0.10,0.10)