Experiment – Auction Theory

After I finished writing the last blog-post about auction theory, I decided to prove our mathematical way with a little experiment. The Experiment is based on a program I wrote. The programming language is python.

The source code looks like following:

import random
import numpy as np

#Set number of potential buyers
buyers = 30

##############################################
#         Posted Price                       #
##############################################

#calculate optimal price
optimal_price = (1/(buyers + 1))**(1/buyers)
pp_expectation = ((1/(buyers + 1))**(1/buyers))*(buyers/(buyers + 1))


##############################################
#         Auction                            #
##############################################

au_expectation = (buyers - 1)/(buyers + 1)

##############################################
#         Experiment                         #
##############################################

pp_list = []
au_list =[]

#Run Experiment 100 time calculate the mean and compare to expected value
for i in range (1000):
    #Let their valuation uniform [0,1] distributed
    valuations = [random.uniform(0,1) for i in range(buyers)]
    # check if posted price would have sold
    pp = 0
    for v in valuations:
        if optimal_price <= v:
            pp = optimal_price
            break
    pp_list.append(pp)
    #get second highest valuation for sell price of the auction
    valuations = sorted(valuations, reverse=True)
    au_list.append(valuations[1])


#Calculate means and print the outcomes
pp_mean = np.mean(pp_list)
au_mean = np.mean(au_list)

print ('''###################################################################
>Posted Price... \nBuyers: {},   \nOptimal Price: {},    \nExpected Profit: {},     \nExperiment Profit: {}
\n>Auction... \nBuyers: {},   \nExpeted Profit: {},    \nExperiment Profit: {}'''.format(buyers, optimal_price, pp_expectation, pp_mean, buyers, au_expectation, au_mean))

I first calculated the expected profit for the posted price (pp_expectation) and the auction (au_expectation) based on what we’ve calculated in the last post. I then run an experiment 100 times and took the average of these 100 outcomes. Based on the Law of Large Numbers, our experiment mean should converge to the real expected value or in our case our expected profit, either pp_expectation or au_expectation. I’ve run the experiment with different numbers of buyers:

au_th_5au_th_10au_th_30

We can see that the larger the number of buyers got the closer was our experiment profit to the expected profit. I observed the same when I increased the number of experiments. Instead of 100 times I know did 1000 times and the experiment profit converged to the expected profit even more:

au_1000_5au_1000_10au_1000_30

The experiment therefore not just proved our calculations from last time but also that the Law of Large Numbers indeed holds.

In case any questions come up, no matter if it’s about the modelling, the source code or whatever, feel free to leave a comment.

Some more experiments will follow int the future. I will continue to include my sourcecode so you can try it yourself or modify some things or even point out if I made a mistake.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s