Thursday, August 29, 2013

Syrian Solace

Much news from Syria has been depressing. Below is a bright poem from a living Syrian poet.


Celebrating Childhood

Even the wind wants
to become a cart
pulled by butterflies.
I remember madness
leaning for the first time
on the mind’s pillow.
I was talking to my body then
and my body was an idea
I wrote in red.
Red is the sun’s most beautiful throne
and all the other colors
worship on red rugs.
Night is another candle.
In every branch, an arm,
a message carried in space
echoed by the body of the wind.
The sun insists on dressing itself in fog
when it meets me:
Am I being scolded by the light?
Oh, my past days—
they used to walk in their sleep
and I used to lean on them.
Love and dreams are two parentheses.
Between them I place my body
and discover the world.
Many times
I saw the air fly with two grass feet
and the road dance with feet made of air.
My wishes are flowers
staining my days.
I was wounded early,
and early I learned
that wounds made me.
I still follow the child
who still walks inside me.
Now he stands at a staircase made of light
searching for a corner to rest in
and to read the face of night again.
If the moon were a house,
my feet would refuse to touch its doorstep.
They are taken by dust
carrying me to the air of seasons.
I walk,
one hand in the air,
the other caressing tresses
that I imagine.
A star is also
a pebble in the field of space.
He alone
who is joined to the horizon
can build new roads.
A moon, an old man,
his seat is night
and light is his walking stick.
What shall I say to the body I abandoned
in the rubble of the house
in which I was born?
No one can narrate my childhood
except those stars that flicker above it
and that leave footprints
on the evening’s path.
My childhood is still
being born in the palms of a light
whose name I do not know
and who names me.
Out of that river he made a mirror
and asked it about his sorrow.
He made rain out of his grief
and imitated the clouds.
Your childhood is a village.
You will never cross its boundaries
no matter how far you go.
His days are lakes,
his memories floating bodies.
You who are descending
from the mountains of the past,
how can you climb them again,
and why?
Time is a door
I cannot open.
My magic is worn,
my chants asleep.
I was born in a village,
small and secretive like a womb.
I never left it.
I love the ocean not the shores.

Soccer English

European soccer leagues have started their seasons and there are more opportunities than ever for watching games from America. Since English words can have different meanings across the Atlantic, here are a few common terms and their American-English equivalent. Any more to add?
  • Football = Soccer
  • Fixture = Game
  • Match = Game
  • Tie = Match
  • Table = Standings
  • Draw = Tie
  • Euro = NIT Tournament
  • Champions League = NCAA Tournament
  • Pitch = Field
  • Mario Balotelli = Dennis Rodman

Tuesday, August 27, 2013

NFL General Manager, You Had One Job!

The National Football League is touted as having parity. Any Given Sunday. Free agency, salary caps, and revenue-sharing are some of the means whereby the better teams are reined in so that anything can happen on any given Sunday. Even teams with poor records are rarely blown-out consistently. Advantages from innovation are short-lived due to copy-catting. You would expect an NFL team's success to resemble other generally random functions, replete with mini streaks and constant reversals of fortune.

Deviations from random should correlate with protected attributes such as rookie mandatory salaries. Since 2002, a team should win the Super Bowl every 32 years, its conference every 16 years, its division every 4 years. But, other teams may concentrate their resources in a certain year so that your team is not up against a similarly random-quality team. So a season might not be the best interval since a general manager can optimize over several years with salary cap considerations. In this case, an NFL general manager would be wise to pick a certain year or maybe two year range, then time the team's resources to hit on all cylinders. This strategy is at the cost of having some down years since the team would be rearranging the timing of its strengths.

Bottom line: a general manager's main objective is to identify the best season to peak, based on what other teams are likely to do; balancing talent over each year is a recipe for mediocrity when it comes to winning titles.

Wednesday, August 14, 2013

Golf Scramble Simulation in R

Golf Scramble Simulation

Golf Scramble Simulation

This is a simulation of a standard best-ball golf scramble. Conventional wisdom has it that the best golfer (A) should hit last, the idea being that one of the lesser golfers may have a decent shot already so the best golfer can take a risky shot. This simulation suggests that the worst golfer should indeed go first, but after that the order should be best on down (D, A, B, C). Perhaps a rationale is that golfer A will likely make a decent safe shot, which allows the other two medium skilled golfers a chance at a risky shot.

This is one of my first cracks at a sports simulation in R, so I welcome any comments about errors or constructive criticism.

## Attaching package: 'combinat'
## The following object is masked from 'package:utils':
## combn
n <- 10000
Create golfer attributes
safe.attributes <- data.frame(golfer = c("a", "b", "c", "d"), mean = c(8, 7, 
    6, 5), sd = c(1.5, 1.5, 1.5, 1.5))
risk.attributes <- data.frame(golfer = c("a", "b", "c", "d"), mean = c(7, 6, 
    5, 4), sd = c(3, 3, 3, 3))

safe.densities <- apply(safe.attributes[, -1], 1, function(x) sort(rnorm(n = 1000, 
    mean = x[1], sd = x[2])))
colnames(safe.densities) <- safe.attributes$golfer
safe.df <- data.frame(safe.densities)

risk.densities <- apply(risk.attributes[, -1], 1, function(x) sort(rnorm(n = 1000, 
    mean = x[1], sd = x[2])))
colnames(risk.densities) <- risk.attributes$golfer
risk.df <- data.frame(risk.densities)
Plot golfer attributes
par(mfrow = c(2, 2))
par(mar = rep(2, 4))

plot(density(safe.df$a), col = "blue", xlim = c(0, 16), ylim = c(0, 0.3), main = "Golfer A", 
    col.main = "black", font.main = 4)
lines(density(risk.df$a), col = "red")
legend("topright", c("safe", "risk"), cex = 0.8, col = c("blue", "red"), lty = 1)

plot(density(safe.df$b), col = "blue", xlim = c(0, 16), ylim = c(0, 0.3), main = "Golfer B", 
    col.main = "black", font.main = 4)
lines(density(risk.df$b), col = "red")
legend("topright", c("safe", "risk"), cex = 0.8, col = c("blue", "red"), lty = 1)

plot(density(safe.df$c), col = "blue", xlim = c(0, 16), ylim = c(0, 0.3), main = "Golfer C", 
    col.main = "black", font.main = 4)
lines(density(risk.df$c), col = "red")
legend("topright", c("safe", "risk"), cex = 0.8, col = c("blue", "red"), lty = 1)

plot(density(safe.df$d), col = "blue", xlim = c(0, 16), ylim = c(0, 0.3), main = "Golfer D", 
    col.main = "black", font.main = 4)
lines(density(risk.df$d), col = "red")
legend("topright", c("safe", "risk"), cex = 0.8, col = c("blue", "red"), lty = 1)
plot of chunk unnamed-chunk-3
Create holes dataframe
golfPerms <- permn(letters[1:4])
holes <- data.frame(matrix(NA, nrow = n, length(golfPerms)))

for (i in 1:length(golfPerms)) {
    colnames(holes)[i] <- paste0(golfPerms[[i]][1], golfPerms[[i]][2], golfPerms[[i]][3], 
for (j in 1:n) {
    for (i in 1:length(golfPerms)) {
        shot1 <- sample(safe.df[, substr(golfPerms[[i]][1], 1, 1)], 1, T)

        if (shot1 >= 6) {
            shot2 <- max(shot1, sample(risk.df[, substr(golfPerms[[i]][2], 1, 
                1)], 1, T))
        } else {
            shot2 <- max(shot1, sample(safe.df[, substr(golfPerms[[i]][2], 1, 
                1)], 1, T))

        if (shot2 >= 6) {
            shot3 <- max(shot2, sample(risk.df[, substr(golfPerms[[i]][3], 1, 
                1)], 1, T))
        } else {
            shot3 <- max(shot2, sample(safe.df[, substr(golfPerms[[i]][3], 1, 
                1)], 1, T))

        if (shot3 >= 6) {
            shot4 <- max(shot3, sample(risk.df[, substr(golfPerms[[i]][4], 1, 
                1)], 1, T))
        } else {
            shot4 <- max(shot3, sample(safe.df[, substr(golfPerms[[i]][4], 1, 
                1)], 1, T))

        holes[j, i] <- shot4
Find winning order per hole
winners <- data.frame(matrix(NA, nrow = n, ncol = 1))
names(winners) <- "winner"
for (k in 1:n) {
    winners[k, 1] <- colnames(holes)[(which.max(holes[k, ]))]
winnerCounts <- data.frame(table(winners))
winnerCounts$winners <- reorder(winnerCounts$winners, -winnerCounts$Freq)
Plot results
par(mfrow = c(1, 1))
ggplot(data = winnerCounts, aes(x = winners, y = Freq)) + geom_bar(colour = "black", 
    fill = "#DD8888", width = 0.7, stat = "identity") + guides(fill = FALSE) + 
    xlab("Order") + ylab("Wins") + ggtitle("Golf Scramble Simulation")
plot of chunk unnamed-chunk-7
ddunn801 at gmail dot com

Monday, August 12, 2013

The Double Buzzsaw Problem

The Double Buzzsaw Problem:
Allocating the Impact from
Simultaneous Percentage Decreases

Link to PDF