time

A Brief Look At Car-Following Models

Recently I posted a short introduction to recurrence relations – what they are and how they can be used for mathematical modeling. This post expands on the topic as car-following models are a nice example of recurrence relations applied to the real-world.

Suppose a car is traveling on the road at the speed u(t) at time t. Another car approaches this car from behind and starts following it. Obviously the driver of the car that is following cannot choose his speed freely. Rather, his speed v(t) at time t will be a result of whatever the driver in the leading car is doing.

The most basic car-following model assumes that the acceleration a(t) at time t of the follower is determined by the difference in speeds. If the leader is faster than the follower, the follower accelerates. If the leader is slower than the follower, the follower decelerates. The follower assumes a constant speed if there’s no speed difference. In mathematical form, this statement looks like this:

a(t) = λ * (u(t) – v(t))

The factor λ (sensitivity) determines how strongly the follower accelerates in response to a speed difference. To be more specific: it is the acceleration that results from a speed difference of one unit.

——————————————

Before we go on: how is this a recurrence relation? In a recurrence relation we determine a quantity from its values at an earlier time. This seems to be missing here. But remember that the acceleration is given by:

a(t) = (v(t+h) – v(t)) / h

with h being a time span. Inserted into the above car-following equation, we can see that it indeed implies a recurrence relation.

——————————————

Our model is still very crude. Here’s the biggest problem: The response of the driver is instantaneous. He picks up the speed difference at time t and turns this information into an acceleration also at time t. But more realistically, there will be a time lag. His response at time t will be a result of the speed difference at an earlier time t – Λ, with Λ being the reaction time.

a(t) = λ * (u(t – Λ) – v(t – Λ))

The reaction time is usually in the order of one second and consist of the time needed to process the information as well as the time it takes to move the muscles and press the pedal. There are several things we can do to make the model even more realistic. First of all, studies show that the speed difference is not the only factor. The distance d(t) between the leader and follower also plays an important role. The smaller it is, the stronger the follower will react. We can take this into account by putting the distance in the denominator:

a(t) = (λ / d(t)) * (u(t – Λ) – v(t – Λ))

You can also interpret this as making the sensitivity distance-dependent. There’s still one adjustment we need to make. The above model allows any value of acceleration, but we know that we can only reach certain maximum values in a car. Let’s symbolize the maximum acceleration by a(acc) and the maximum deceleration by a(dec). The latter will be a number smaller than zero since deceleration is by definition negative acceleration. We can write:

a(t) = a(acc) if (λ / d(t)) * (u(t – Λ) – v(t – Λ)) > a(acc)
a(t) = a(dec) if (λ / d(t)) * (u(t – Λ) – v(t – Λ)) < a(dec)
a(t) = (λ / d(t)) * (u(t – Λ) – v(t – Λ)) else

It probably looks simpler using an if-statement:

a(t) = (λ / d(t)) * (u(t – Λ) – v(t – Λ))

IF a(t) > a(acc) THEN
a(t) = a(acc)
ELSEIF a(t) < a(dec) THEN
a(t) = a(dec)
END IF

This model already catches a lot of nuances of car traffic. I hope I was able to give you some  insight into what car-following models are and how you can fine-tune them to satisfy certain conditions.

Einstein’s Special Relativity – The Core Idea

It might surprise you that a huge part of Einstein’s Special Theory of Relativity can be summed up in just one simple sentence. Here it is:

“The speed of light is the same in all frames of references”

In other words: no matter what your location or speed is, you will always measure the speed of light to be c = 300,000,000 m/s (approximate value). Not really that fascinating you say? Think of the implications. This sentence not only includes the doom of classical physics, it also forces us to give up our notions of time. How so?

Suppose you watch a train driving off into the distance with v = 30 m/s relative to you. Now someone on the train throws a tennis ball forward with u = 10 m/s relative to the train. How fast do you perceive the ball to be? Intuitively, we simply add the velocities. If the train drives off with 30 m/s and the ball adds another 10 m/s to that, it should have the speed w = 40 m/s relative to you. Any measurement would confirm this and all is well.

Now imagine (and I mean really imagine) said train is driving off into the distance with half the light speed, or v = 0.5 * c. Someone on the train shines a flashlight forwards. Obviously, this light is going at light speed relative to the train, or u = c. How fast do you perceive the light to be? We have the train at 0.5 * c and the light photons at the speed c on top of that, so according to our intuition we should measure the light at a velocity of v = 1.5 * c. But now think back to the above sentence:

“The speed of light is the same in all frames of references”

No matter how fast the train goes, we will always measure light coming from it at the same speed, period. Here, our intiution differs from physical reality. This becomes even clearer when we take it a step further. Let’s have the train drive off with almost light speed and have someone on the train shine a flashlight forwards. We know the light photons to go at light speed, so from our perspective the train is almost able to keep up with the light. An observer on the train would strongly disagree. For him the light beam is moving away as it always does and the train is not keeping up with the light in any way.

How is this possible? Both you and the observer on the train describe the same physical reality, but the perception of it is fundamentally different. There is only one way to make the disagreement go away and that is by giving up the idea that one second for you is the same as one second on the train. If you make the intervals of time dependent on speed in just the right fashion, all is well.

Suppose that one second for you is only one microsecond on the train. In your one second the distance between the train and the light beam grows by 300 meter. So you say: the light is going 300 m / 1 s = 300 m/s faster than the train.

However, for the people in the train, this same 300 meter distance arises in just one microsecond, so they say: the light is going 300 m / 1 µs = 300 m / 0.000,001 s  = 300,000,000 m/s faster than the train – as fast as it always does.

Note that this is a case of either / or. If the speed of light is the same in all frames of references, then we must give up our notions of time. If the light speed depends on your location and speed, then we get to keep our intiutive image of time. So what do the experiments say? All experiments regarding this agree that the speed of light is indeed the same in all frames of references and thus our everyday perception of time is just a first approximation to reality.

Analysis: Size and Loading Times of WordPress.com Blogs

In the fast paced online world people are not so patient as in real life. Accordingly, having a large home page size and loading time can negatively affect your blog traffic. Studies have shown that the greater the loading time, the higher the bounce rate. To find out how well my blog performs with respect to this (feel free to use the results for your benefits as well), I did a analysis of 70 WordPress.com blogs. I used iWEBTOOLS’s Website Speed Test and OriginPro for that. With the tool you can analyze ten webpages at once, but note that after ten queries you have to wait a full day (not an hour as the website claims) to do more analysis.

The average size of a WordPress.com blog according to the analysis is 65.3 KB with a standard error SE = 3.0 KB. Here’s how the size is distributed:

WPSize

The average loading time at my internet speed (circa 600 KB/s) is 0.66 s with the standard error SE = 0.10 s. Here’s the corresponding distribution:

WPLoading2

Note that the graph obviously depends on your internet speed. If you have faster internet, the whole distribution will shift to the left. My blog has a home page size of 81.6 KB. From the first graph I can deduce that only about 24 % of home pages are larger in size. My loading time is 0.86 s, here only about 22 % top that. So it looks like I really have to throw off some weight.

Here’s the loading time plotted against the home page size:

WPLoadingSize

In a very rough approximation we have the relation:

loading time = 0.009 * size

In other words: getting rid of 10 KB should lower the loading time by about 0.1 seconds. Now feel free to check your own blog and see where it fits in. If you got the time, post your results (if possible including URL, size, loading time, internet speed) in the comments. I’d greatly appreciate the additional data. For a reliable result regarding loading time it’s best to check the same page three times and do the average.

Inflation: How long does it take for prices to double?

A question that often comes up is how long it would take for prices to double if the rate of inflation remained constant. It also helps to turn an abstract percentage number into a value that is easier to grasp and interpret.

If we start at a certain value for the consumer price index CPI0 and apply a constant annual inflation factor f (which is just the annual inflation rate expressed in decimals plus one), the CPI would grow exponentially according to this formula:

CPIn = CPI0 · f n

where CPIn symbolizes the Consumer Price Index for year n. The prices have doubled when CPIn equals 2 · CPI0. So we get:

2 · CPI0 = CPI0 · f n

Or, after solving this equation for n:

n = ln(2) / ln(f)

with ln being the natural logarithm. Using this formula, we can calculate how many years it would take for prices to double given a constant inflation rate (and thus inflation factor). Let’s look at some examples.

——————–

In 1918, the end of World War I and the beginning of the Spanish Flu, the inflation rate in the US rose to a frightening r = 0.204 = 20.4 %. The corresponding inflation factor is f = 1.204. How long would it take for prices to double if it remained constant?

Applying the formula, we get:

n = ln(2) / ln(1.204) = ca. 4 years

More typical values for the annual inflation rate are in the region several percent. Let’s see how long it takes for prices to double under normal circumstances. We will use r = 0.025 = 2.5 % for the constant inflation rate.

n = ln(2) / ln(1.025) = ca. 28 years

Which is approximately one generation.

One of the highest inflation rates ever measured occurred during the Hyperinflation in the Weimar Republic, a democratic ancestor of the Federal Republic of Germany. The monthly (!) inflation rate reached a fantastical value of r = 295 = 29500 %. To grasp this, it is certainly helpful to express it in form of the doubling time.

n = ln(2) / ln(296) = ca. 0.12 months = ca. 4 days

Note that since we used the monthly inflation rate as the input, we got the result in months as well. Even worse was the inflation at the beginning of the nineties in Yugoslavia, with a daily (!) inflation rate of r = 0.65 = 65 %, meaning prices doubled every 33 hours.

——————–

This was an excerpt from “Business Math Basics – Practical and Simple”. I hope you enjoyed it. For more on inflation check out my post about the Time Value of Money.