## On the costs of mutual exclusion in C++

Disruptor [1] is a software component that implements lock-free message passing between different threads of control. Disruptor is open source; its way of operation and its advantages over traditional message passing are described in [2], [3] and [4].

The motivation for building the Disruptor was the search for the most efficient ways to pass messages from one thread to another. That, in turn, requires some synchronisation between the threads: the producing thread must be able to inform the consumer that the next message is ready to be processed. In [1], the authors experiment with different ways of synchronising threads in Java. I decided to perform similar tests in C++ to see if there is a substantial language dependency in the results.

## Investing in movies

Fitting the distribution of ticket sales yields unexpected results

The movie business is risky, but the returns can be high. Better yet, the movie industry performance is only loosely correlated to that of the rest of the economy, which makes it an attractive diversification option.

In the Netherlands, investing in motion picture production is especially good because of the favourable tax regulation. To put it simply, if the movie flops, the losses of the private investors are deduced from the tax they have to pay in that year. The production company usually agrees that beforehand with the tax office. Thanks to that, potential loss of a private investor is limited to a small fraction of the investment, while potential returns are high.

Recently I got an offer to invest in a new movie. However attractive this seems at the first sight, I need to do my homework before deciding to invest. I have to calculate the  expected return and variance and compare these to other investment options. The movie production company published the projected returns contingent on the movie’s gross box office earnings in the Netherlands, so if I can estimate the box office, I will know the distribution of the investment’s returns. In this blog post I will analyse the historical distribution of the movies’ earnings.

Existing research [1] shows that the gross earnings of the movies released in the US  each year follow a power law distribution with Pareto exponent $\alpha \approx 2$. To estimate the box office of a Dutch movie, I will need the statistics of the movies’ earnings in the Netherlands.

If I had limited the statistics to the Dutch-language movies released in a single year, I would have got hopelessly little data. To remedy the situation, I assumed that

1. The distribution of movies earnings is the same every year.
2. Movies have equal chances of success regardless of the language.

I do not have any evidence to support these claims, but they sound reasonable. Besides, I cannot get much further without any of them. Together, they allow me to use the complete movie-going statistics of several years, which provides a sufficient number of data points.

Ticket prices change, so instead of looking at gross earnings, I considered the number of tickets sold; this would give equal weight to each year’s results. Luckily, the ticket sales data for the top 1000 movies released from 1991 to 2012 are available from the Dutch Film Distributors’ Association (NVF); the pdf can be downloaded here.

As I was looking for a power law distribution, I plotted the logarithm of the film’s rank versus the logarithm of the number of sold tickets. The data (blue dots) are shown on Figure 1 below.

Figure 1

I expected the dots to lie close to a straight line; that is what a power law distribution looks like on a log-log plot. The best linear fit to the data is shown by the black line. This fit is rather poor; $R^2=0.9375$. The Pareto exponent implied by the linear fit is $\alpha=1.51$.

Surprisingly, a quadratic fit (red line) is very good; $R^2=0.998$. This contradicts the findings in [1], but the data points lie remarkably close to a parabola! I have no explanation for this; I would be curious to know if anyone got similar results from the analysis of the movie earnings distribution elsewhere.

Finally, I have to reiterate that the fit was done for the top 1000 movies released from 1991 to 2012. According to the data published on boxofficenl.net, the total of 5846 movies were released in the Netherlands during these 22 years. The top thousand represents $1000/5846 \approx 17\%$ of all released movies.

References

1. Blockbusters, Bombs and Sleepers: The income distribution of movies. Sitabhra Sinha and Raj Kumar Pan, 2005. Available at http://arxiv.org/abs/physics/0504198.

Disclaimer

This is not an offer, solicitation or advice to invest. Past performance offers no guarantee for the future.

Posted in Uncategorized | Tagged , , , , | Leave a comment

## Monte Carlo on a graphics card

Recently I wrote an experience report on running Monte Carlo simulation on a GPU for the newsletter of TopQuants. My piece is here.

## Units of measurement

Recently I had to familiarise myself with commodity futures. One thing that surprised me was the common unit of measurement for natural gas. It is used in MMBtu, which is a short for a million of British thermal units. It is perfectly logical to measure gas in the amount of heat that it can produce (rather than weight or volume), for obvious reasons. What surprised me was the definition of the Btu: it is defined as amount of heat required to raise the temperature of 1 pound (0.454 kg) of liquid water by 1 °F (0.56 °C) at a constant pressure of one atmosphere. I thought that most people had switched to SI long ago, and measures like pounds, cups and Fahrenheits remained only in grandmothers’ cookbooks. I was wrong, apparently.

By all means there can be reasons to stick to good old measures. One is convenience. It might be that the usual SI units are inconvenient for being used in finance. It took me some time to come up with an example of a SI measure that is utterly unfit for everyday use in our trade.

Consider interest rate. It has the dimension of frequency (1/time). Let me see if the SI unit of frequency, hertz (Hz), is convenient for expressing commonly used rates.

Take the interest rate of 1% per annum, simply compounded, quoted according to the Actual/365 day counting convention. How much is it in SI?

1 year = 365 days (by the day count convention) = 365*24*3600 seconds.
$\frac{0.01}{365*24*3600}\approx 3.1709792*10^{-10}$
Imagine yourself quoting a rate of .317 nanohertz to a customer.

Originally I planned to post this on 1 April, but something distracted me… Late is better than never, anyway.

## Bitcoin

This is not so much of a post, just a collection of bitcoin-related links:

https://bitcointalk.org/index.php?PHPSESSID=309cf9027c5144b5cf3eef31f09866d0&topic=35812.0

https://bitcointalk.org/

http://bitcoinmagazine.net

http://bitcoincard.org/

https://bitpay.com/

https://localbitcoins.com/

http://acceptbit.com/

https://github.com/kangasbros/django-bitcoin

## A crash course in CVA calculation

Recently I was asked by a student to give some guidance on using Monte Carlo method for CVA calculation. Here is what I came up with.

Posted in Finance | 5 Comments

## Global Derivatives Trading & Risk Management 2012

In April I was lucky to get a place at the Global Derivatives conference.

Here is the blog post about it that I wrote for the Global Risk community.

## Software functionality is not copyrightable

Great news.

The EU Court of Justice has ruled that one can’t copyright a computer program’s functionality. Further, they state: “The purchaser of a licence for a program is entitled, as a rule, to observe, study or test its functioning so as to determine the ideas and principles which underlie that program.”

Here is the article on Groklaw:
http://www.groklaw.net/article.php?story=20120502083035371

## Why companies should not outsource IT support

Most big companies do not maintain their IT infrastructure by themselves. Instead, they outsource this job to another company, which usually calls itself a solution provider. A single solution provider can take care of IT resources of many different companies.

The outsourcing company usually claims that keeping their own IT support team would be more expensive than outsourcing. I believe this is a fallacy, and here is why.