Friday, November 29, 2013

VBA Simulation of Shuffling and Distributing a Deck of Cards

Here's a simple VBA program that simulates shuffling and distributing a standard deck of 52 cards to 4 players. The program outputs the results in cells A1 through D13 of the current Excel spreadsheet, with the 4 rows corresponding to the 4 players' cards.
Sub ShuffleCards()
'This program simulates shuffling of a standard deck of 52 cards to 4 players
'Results are outputted in 4 columns in cells A1:D13

'H: heart, S: spades, D: diamod, C: club
'2 thru 10, J for jack, Q for queen, K for king, A for ace
'2H would be 2 of hearts, KD would be king of diamonds, etc.

'Creating
suits = Array("H", "S", "D", "C")
num = Array("2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A")

Dim cards(0 To 51) As String
For i = 0 To 3
For j = 0 To 12
cards(13 * i + j) = num(j) & suits(i)
Next j
Next i

'Shuffling
For i = 1 To 1000
c1 = Int(52 * Rnd)
c2 = Int(52 * Rnd)
temp = cards(c1)
cards(c1) = cards(c2)
cards(c2) = temp
Next i
'Distributing
For k = 0 To 51
Cells(k Mod 13 + 1, Int(k / 13) + 1) = cards(k)
Next k
End Sub

The shuffling algorithm is to run through 1000 iterations of swapping two randomly chosen cards.

Sunday, November 24, 2013

“Comments on the Interpretations of Game Theory” Digest

In the paper “Comments on the Interpretations of Game Theory,” published in Volume 59, Issue 4 of Econometrica in July 1991, Ariel Rubinstein discusses notions of game theory and strategy that aims to highlight some of the inconsistency between the interpretation and application. Rubinstein argues that equilibrium strategy describes not only a player’s plan of action, but also the considerations that support the optimality of the plans. The paper also argues that models should encompass the perception of a real life situation by the decision makers. Game theory, as Rubinstein writes, is not simply about abstract mathematics but about the real world.

The first half of the paper deals with the notion of strategy. Rubinstein argues that the conventional interpretation is inconsistent with the way it is applied, leading to confusion. In one of the contexts, Rubinstein talks about extensive games with more than one moves. In the game, a player’s strategy is required to specify an action for each node in the game tree corresponding to that player’s movement. However, the incongruence comes when an action must be specified, even after earlier moves that would make the subsequent decision point inconsistent with the earlier moves. The necessity of this specification stems from the need to determine subgame-perfect equilibrium to test the rationality of the plans. In all, a strategy needs to encompass not only the player’s plan, but also the opponents’ belief in the chance that the plan was not followed.

Rubinstein also looks at the interpretation of strategy in mixed strategies. While intuitively problematic, there are clear cases in which players choose random actions, preferring over pure strategies. One interpretation of mixed strategy is to use a large population and having each occurrence take a random draw of the items from the population. Another interpretation is the purification idea, whereby a mixed strategy is dependent on private information not specified in the model. This interpretation argues that ostensibly random behaviors are actually deterministic. Finally, Rubinstein looks at the case of limited memory, which helps to keep modes of behavior simple. When probabilistic nature of doubt is introduced, there may be additional decision points that are unreachable, but added to the game form merely to allow the discussion of reasoning in the state of doubt.

From these discussions, Rubinstein tries to adopt the view that a game is not “a rigid description of the physical rules of the world,” but instead a “comprehensive description of the relevant factors involved in a specific situation as perceived by the players.” Towards that idea, model should include only the factors perceived by the players to be relevant, making the application of game theory “more of an art than a mechanical algorithm.” Finally, Rubinstein talks about regularity, which is necessary for employing game theory as a descriptive science. Game theory, in conclusion, builds models from intuition and from mathematical knowledge uses deductive arguments, which can’t discover the truth alone. Instead, game theory also deals with psychological elements, which help to distinguish humans from machines, which Rubinstein believes is “more exciting and certainly more meaningful.”

Monday, November 18, 2013

San Diego - Tijuana Border and Flight Comparison

A proposed solution to San Diego's crowded airport is to build a pedestrian bridge to Mexico. Tijuana's General Abelardo L. Rodriguez International Airport (TIJ) is located just across the US-Mexico border, and the proposed bridge, about 20 miles away from downtown San Diego, would allow people to cross the border into the airport. Otay-Tijuana Venture, the project's developer, cites that of the "roughly 4 million people who fly into and out of TIJ each year, more than half cross the border one way or the other." However, crossing the San Diego - Tijuana borders on automobile involves notoriously long waiting times. Some prefer to cross by foot and then catch transportation on the other side. San Ysidro crossing between the two cities is the world's busiest port of entry.

How much cheaper is it to fly out of Tijuana instead of the San Diego area airports? The following are the costs of the cheapest flights, for one adult roundtrip, from Expedia retrieved tonight, departing on Monday, December 7th and returning Wednesday, December 9th:

Destination San Diego Tijuana
New York $351.10 $972.59
London $2,214.60 $2,282.60
Tokyo $1,050.50 $3,932.80
Sydney $1,577.80 $3,082.21
Cairo $1,316.68 $3,930.00
Rio de Janeiro $1,269.49 $1,540.55
Panama City $800.40 $938.19
Mexico City $342.59 $291.16
Cancun $400.40 $371.04

For many of these cities, San Diego offers an enormous discount. Even for other Latin American destinations, San Diego offers cost advantage. It is only within Mexico that Tijuana offers cost advantages. The Tijuana flights to rest of Mexico are also more frequent and have fewer stops on average. Looking at just these results then, it would seem as though the pedestrian bridge serves to relieve those in Southern California traveling to various parts of Mexico by air. A positive externality would be slight relieving of the border crossing for those going to the airport.

Sources: