According to chapter 41 of the Book of Genesis, the Pharaoh had two dreams. In one, seven lean and ugly cows that emerged from the Nile killed and ate up seven fat and well-fed cows that also emerged from the Nile. In another, seven thin ears of corn ate up seven fat and well-formed ears.

To interpret this dream for him, the Pharaoh called on Joseph, who interpreted them as seven years of flooding of the Nile (resulting in abundance) followed by seven years of drought (and famine). During the seven years of floods and abundance that followed, the Pharaoh stocked up the granaries. When the drought happened (as predicted by Joseph), the Pharaoh sold the grain, turning a profit and averting the famine.

The story shows how important the flooding of the Nile has been to Egypt since biblical times. For a long time, this remained an unpredictable phenomenon, with none of the standard forecasting models being able to predict it. In the early 20th century, the colonial British government decided to construct a reservoir on the great river, but the big problem was to decide the size of this reservoir. Around this time, in 1906, hydrologist Harold Edwin Hurst joined the project.

Hurst was to remain in Egypt and be associated with the Nile for 62 years (the Egyptian government retained his services after the country’s independence). Looking through 847 years of Nile overflow data (existence of this data tells us much about the farsightedness of the Mameluke and Ottoman rulers of Egypt), Hurst managed to crack the puzzle. The model he built was one of long-range dependence. It is a model that has far-reaching effects, most importantly in the financial markets.

Standard models of stock markets assume that they follow a so-called random walk, or Brownian motion. They assume movement of the markets in two adjacent time periods are independent of each other, and this is true irrespective of the size of these time periods. The question sometimes arises if markets do indeed follow a random walk, and if they don’t, how far away from this assumption are they.

This question is pertinent now given the movement of the Nifty index on the National Stock Exchange over the past three-four months. The index has shown remarkable serial correlation in this time period—an up day results in a series of up days and similarly with down days (see figure 1). Thus, we can hypothesize that the Nifty currently has positive long-range dependence. How can we test the hypothesis?

This is where Hurst’s work on the Nile comes in, further developed and improved upon by mathematician Benoit B. Mandelbrot (more famous for his work on fractals). The fundamental concept is what is known as rescaled range.

If a quantity were to follow a random pattern, the range of values it can take (defined as maximum minus minimum) over N time periods (what the time period is doesn’t matter) is proportional to the standard deviation of values, and proportional to the square root of N. Putting it differently, the ratio of the range of prices to the standard deviation of prices (which is known as rescaled range, represented as R/S, with R for Range and S for Standard Deviation) is proportional to the square root of the number of time periods.

If the time series has positive long-range dependence (or an upward move today more likely to cause an upward rather than downward move tomorrow), the potential range it can achieve in N time periods is going to be higher than that of a random walk (this is not hard to see. If an up movement results in further up movements, it is likely to go much farther from the origin). On the other hand, if the series has negative long-range time dependence (an example of this is a mean reverting series where any movements away from normal are likely to cause a bounce-back), then the potential range the series can achieve in N time periods is much less than that of a random walk.

Turning this around, analysing the rescaled range of a time series as a function of number of time periods will tell us about its long-range dependence. All we need to do is to find the exponent of N, according to which the rescaled range grows. If this exponent is half (in which case the rescaled range grows with the square root of N), we have a regular random walk (or Brownian motion). If the exponent is greater than half, we have positive long-range time dependence, and the value of the exponent tells us the degree of such dependence. Similarly, if the exponent is less than half, we have negative long-range time dependence, which is known as fraction Brownian motion.

Mandelbrot chose to call this exponent after Hurst. He abbreviated it as H, and declared that the said H could stand for either Hurst or German mathematician Otto Hölder. Algorithms for calculating this exponent are available online. The Matlab code can be found here (mintne.ws/1CqqkEt), and I’ve translated the same code into R and uploaded it here (http://mintne.ws/1CqqkEt). Using this code, we can determine whether the Nifty has long-range dependence.

The Hurst exponent depends upon the time period under consideration. If we look at the Nifty over a five-year horizon, we get a Hurst exponent of 0.53, which means there is positive long-range dependence. Looking at it for just the past year, though, we find that the Hurst exponent is just under 0.46. If we look at the Hurst coefficient since 1 March, it drops lower, to 0.43. In other words, the Nifty is actually mean reverting.

How could this be the case when the short-term time-dependence is apparent? We don’t need to dig too deep for the answer. While the Nifty is positively serially correlated over the very short term, if we look at slightly longer time periods, we find that the index is actually mean reverting. This mean reversion on longer time periods overrides the serial correlation in shorter time periods to give us a Hurst exponent lower than 0.5.

How does this compare with other indices? Other Indian indices are closer to following random walks than the Nifty (see figure 2). Interestingly, the benchmark Sensex follows almost a perfect random walk, indicating the possibility of a trade on the difference in Hurst exponents of India’s two flagship indices.

Most major global indices are also closer to the random walk than the Nifty, with one notable exception; the S&P 500 has a Hurst coefficient of 0.43, indicating that it is much more highly mean reverting (see figure 3). Considering that some global indices have positive long-range dependence and some negative, the possibility of existence of a trade cannot be ruled out.

When Harold Edwin Hurst modelled the flooding of the Nile based on more than eight centuries of data, the Hurst exponent (as it came to be called) turned out to be a whopping 0.73. The Nile code, so to say, had been cracked. This finding by Hurst allowed engineers to construct a reservoir large enough to hold enough water to hedge the vagaries of the Nile. In recognition of his services, Hurst earned the moniker Abu Nil, or Father of the Nile.