Tuesday 18 January 2011

Fractal dimension of curves - How Long Is the Coast of Britain?

Benoit Mandelbrot (20 November 1924 – 14 October 2010) wrote a paper in 1967, which advocated a fractal concept to measurements of phenomena in nature such as geographical features. He further developed on the idea and published a book The Fractal Geometry of Nature (readers may wish to click here to buy it). Now, the main focus of this post. Practical applications abound for this concept, which I will go into straightaway.

Given a random curve in 2D space, there are 2 simple ways to measure its length. First method is by varying the length of straight lines used to measure the fractal dimension of a curve. This method is simple to implement if there is only one curve, but the situation gets complicated if there are many random curves. In this case, it is recommended that the other method, the box counting method, is used instead.

The problem is simplified by using a unit circle with centre at origin, in order for ease of understanding this concept. Let n be the number of equal line segments used to calculate the perimeter of this circle. Each segment will have length s. Total length measured in each case is u. Given a self similarity dimension D, these are related by



where b is the intercept of the resulting log-log graph. Note that log can be to any base, and is kept to base 10 in this case. Simply by varying s and calculating u, then plotting a graph, it is possible to get the fractal dimension D by adding 1 to the gradient of the log-log graph. These results are shown in the image below.


As can be seen in the graph above, the gradient is zero, which means self similarity dimension D is 1. This concept can be applied to any curve that has known (measured) coordinates, by varying s and measuring u, then plotting the log-log graph to get its self similarity dimension D.

Now we move on to the box counting method. Using squares of side s in length, define N(s) as the number of squares that contain the curve. This can be illustrated in the picture below, where the domain is split into squares of varying sizes. The red boxes are the boxes that contain the circle. N(s) is simply the sum of the red boxes for each value of s.


Again, by varying the length of s, and calculating respective values of N(s), and plotting a log-log graph, it is possible to find the self similarity dimension D. Note that in this case (see graph below), D is the gradient obtained from the log-log graph.



 From the above graph, the gradient is 1. This means that the self similarity dimension D is 1, which is the same as that found using the line segment method.

That is as simple as it gets. Do leave a comment if you need help using these methods and I will try to get back to you as soon as possible.

Friday 14 January 2011

Apple Magic Mouse and Wireless Keyboard

To be honest, I am no fan of Apple. Still, I must admit that these accessories do have their strong points, despite some of the shortcomings that I am about to reveal.
Magic Mouse has a great look and feel to it, and there is a multitouch ability on its surface that allows for many commands and multidirectional scroll functions that work brilliantly on a Mac.
However, it has quite a few drawbacks that I feel I should reveal to potential buyers. It uses Bluetooth technology to hook up with a Mac, which is, in my opinion, a poor design option. The effective range of Bluetooth is about 5 metres, which is not fantastic. Often, it gets disconnected from the Mac, possibly because it drains batteries really quickly, and possibly due to interference from nearby workstations using the Magic Mouse. The supplied batteries ran out of juice after one month of normal use, possibly because of Bluetooth being less efficient compared to wireless in terms of power consumption. If you are a die-hard Apple fan, it is quite a nice accessory to have, as long as you have a bunch of rechargeable batteries ready at any time. Also, it can be a real pain to disconnect often from the Mac and lose the scroll function upon reconnection, which is probably an inherent driver problem as well.
My advice - get it if you do not mind the hassle of changing batteries often, or wait for the wireless version, if there are any plans from Apple.
As for the wireless (bluetooth) keyboard, it has a nice feel and is very compact. The battery life on it is decent. After about 5 months' use it has about 18 % left on its batteries. Which probably suggests that the inherent design of Magic Mouse is not energy efficient, possibly because of the multitouch functionality. Perhaps I should try to switch off that functionality and monitor its power consumption (not sure if I can though). The keyboard is incredibly silent despite the fact that I am constantly typing away most of the day. The tactile feedback is excellent as well. Also, it is so compact that I have space for other stuff on my desk. Despite the compact layout, the size of the keys are decent, even though I have really fat fingers, and even though it takes some getting used to, the layout is kind of intuitive. Will be great if Apple can sacrifice a bit of space to add a number pad to it, for hammering in the numbers for some people. Also, the UK version does not have a # symbol printed on it (use Alt + 3 - a simple google search will do). Somehow, using gedit with this keyboard just means that there is no way to key in # and you have to cut and paste, as (Alt + 3) is a shortcut in gedit. A pain in the neck for people who program in C or C++, unless they use another editor.
Overall recommendation - get this keyboard as it is the slimmest available, and works with an iPad as well. Definitely a must have for Apple lovers.

Thursday 13 January 2011

Hello, world!

Ok. This is easier than writing a program in any language, but would,be nice to have a means of posting directly from a mobile app.

trying to mod and see how it responds.