Posts

Probability riddle

Image
A probability question that seems to be quite common in quant interviews is the airplane boarding problem. Imagine that there are \(100\) people in a queue waiting to board a plane with \(100\) seats numbered seats. The first passenger takes a random seat. Passenger \(n>1\) will either take seat \(n\) if it is not already taken or take a random available seat. What is the probability that the last passenger is seated? You are typically expected to answer such a question in \(2\)-\(5\) minutes. Take some time if you want to try this problem on your own.  Passengers queueing to board a plane Without much thinking, many would expect the probability of such an event to be rather small. Perhaps in the order of \(1/100\)? In this problem intuition can be misleading. Let's consider simple cases. Instead of boarding \(100\) people, consider \(2\) instead. If there are \(2\) seats, the probability that the second passenger takes the second seat is the probability that the first passenger

Image Colourisation

Image
You might have already used some AI Picture Colourizer software (such as Vance AI). Such software is being used for the reconstruction of old B&W photographs or films of historical and cultural significance or of sentimental value to the user of the application software. But how does this software work? Is it really possible to recover all lost colour information? B&W Reconstructed Coloured Unfortunately, most algorithms can only make informed guesses about the colour content of an image and frequently fail in the complete absence of any colour information. Using Vance AI to reproduce the colour content of those B&W peppers, we see that many colours are not identified correctly. There have been multiple cases of image colourising that provoked anxiety about the authenticity of photography in the digital era as covered in  this article . A simple remedy to this may be to simplify the problem by adding some colour information to the image. Perhap

Genetic Algorithm on TSP

Image
In the previous blog post  we discussed how Simulated Annealing can tackle the Travelling Salesperson Problem of connecting \(n\) cities with the shortest path (with every city visited exactly once). In this blog post we investigate another method, inspired by biology and Darwin's theory of evolution.  We introduce some evolutionary terms and how they relate to the optimization task;  an individual  is a given solution/route,  a population \(N\) of individuals is the set of \(N\) solutions/routes,  a generation is the iteration count of the algorithm,  the fitness of an individual is determined by the objective value (the lower the total distance of a route, the fitter that route is), the reproductive   selection process, where individuals are stochastically chosen to become parents and reproduce to give offspring , the chromosome/gene  of a solution is an encoding of that solution, the mutation of a chromosome is an elementary stochastic transformation of that solution that occu

Simulated Annealing on TSP

Image
The traveling salesperson problem (TSP) is a well-studied optimization problem which finds the shortest  path connecting \(n\) cities so that each city is visited exactly once. This is a minimization problem where the objective value to be minimized is the total distance travelled. A solution of TSP with \(4\) cities Using the formulation of  Dantzig–Fulkerson–Johnson, the problem can be tackled with integer programming. Indeed branch and bound algorithms provide exact solutions to TSP, but since it is an NP-hard problem they can only process small problems containing only 40-60 cities.  Heuristic approaches provide a faster alternative. The simplest method proposed is the nearest neighbour heuristic which takes the salesperson to the nearest unvisited city at each step of the algorithm. Despite its simplicity the output solution is often sub-optimal, as you can see in figure below. Black and blue nodes are current and nearest unvisited cities respectively. In the last step, the last v

Volatility Indices and VIX

Image
 Volatility as a measure of expected or realised deviation in asset returns over a specified period is thoroughly studied in the financial literature. Investors with long market exposure use volatility as a risk gauge, fearing periods of high volatility, since they are historically associated with sudden drops in returns. Historical volatility is a measure of past volatility and despite being conceptually simple and easy to compute, it doesn’t have explanatory power on future volatility. We need to use current market information to infer market expectations of future volatility. Financial models can come to rescue. Financial models attempt to predict future volatility based on the current market’s knowledge/data. In the options market, products such as call/put options allow one to buy/sell a stock on some expiration date \(T\) in the future (measured in years) at some price \(K\) called the strike price. Since stock price at expiration may deviate significantly from the strike pr