In [1]:
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
In [2]:
filename = "901101-910131-SOD"
resultsFilename = "results/"+filename+".csv"
results = pd.read_csv(resultsFilename)
results['Optimal market size'] = (results['Optimal buyers']+results['Optimal sellers']) / 2
results['Normalized market size'] = results['Optimal units'] / (results['stddev']*np.sqrt(np.log(4*results['stddev'])))
print(len(results), " auctions")
results = results[results['Optimal gain']>0]
print(len(results), " auctions with positive optimal gain")
#results = results[results['Normalized market size']<200]
results['Asymptotic guarantee 3'] = 1 - 9 / results['Normalized market size']
results.loc[results['Asymptotic guarantee 3']<0, 'Asymptotic guarantee 3'] = 0
In [46]:
ax = plt.subplot(1, 1, 1)
results.plot(kind='scatter', x='Normalized market size',y='Asymptotic guarantee 3', color='b', ax=ax)
results.plot(kind='scatter', x='Normalized market size',y='Competitive ratio', color='r', ax=ax)
#plt.show()
Out[46]:
In [52]:
results_bins = results.groupby(pd.cut(results['Normalized market size'],150)).mean()
ax = plt.subplot(1, 1, 1)
results_bins.plot(kind='line', x='Normalized market size',y='Asymptotic guarantee 3', color='b', ax=ax)
results_bins.plot(kind='scatter', x='Normalized market size',y='Competitive ratio', color='r', ax=ax)
ax.legend().set_visible(False)
#plt.show()
In [59]:
from statistics import *
import numpy as np
t1 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 101, 103, 113, 122, 129, 136, 145, 150, 150, 150, 150, 150, 151, 168, 181, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 213, 229, 250, 250, 250, 252, 298, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 310, 337, 350, 361, 400, 400, 400, 400, 400, 400, 400, 400, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 516, 519, 700, 900, 900, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1012, 1012, 1100, 1100, 1169, 1176, 1200, 1300, 1300, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1525, 1600, 1600, 1800, 1975, 1975, 1975, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2300, 2300, 2300, 2300, 2300, 2490, 2900, 2900, 2900, 3000, 3000, 3000, 3000, 3000, 3300, 3430, 3430, 3500, 5000, 5000, 5000, 5000, 5000, 10000, 10000]
print (mean(t1))
print(pstdev(t1))
t2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 145, 150, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 229, 250, 300, 300, 300, 300, 300, 300, 300, 350, 350, 400, 500, 500, 560, 603, 652, 800, 1000, 1087, 1100, 1222, 1300, 1355, 1500, 1800, 1925, 2000, 2200, 2200, 2590, 3000, 3400, 6000, 10444, 13213, 78500, 98678]
print (mean(t2))
print(pstdev(t2))
a=4
a**2
Out[59]:
In [22]:
filename = "901101-910131-IBM-SOD"
datasetFilename = "datasets/"+filename+".CSV"
pricesFilename = "datasets/"+filename+"-PRICES.CSV"
dataset = pd.read_csv(datasetFilename)
dataset
Out[22]:
In [19]:
prices[prices['Date']==901102]
Out[19]:
In [36]:
results = pd.merge(dataset, prices, on=['Symbol','Date'], how='outer')
results
Out[36]:
In [37]:
results.drop(["Walrasian Price","Unnamed: 0_x","Unnamed: 0_y"], axis=1, inplace=True)
results
Out[37]:
In [ ]: