Tag Archives: computers

Pet Peeve of the Week: Starfield simulations are always wrong, and here’s why…

Ok, if you don’t know what a starfield simulation is, lets sort you now – look at the video below first.

Ok, for those of you without youtube, think then of the screen savers on early windows PC’s – you may recall the screensaver that makes it look like you are flying through space – this “stars flying by” visual is the thing I am talking about. If you are interested, you can presently download this screensaver here.

Now when this screen saver came out, I’ll admit I was still a bit of a nerd – with a thing for both astronomy and for computers, so I set out to make my own. What I learned along the way initially puzzled me then annoyed me and then made me give up in disgust.

Ok, so before I tell you the ‘big secret’ of what annoyed me so, take a look at this animation:

[youtube=http://www.youtube.com/watch?v=KJO88Qhxwv4]

I think you’ll agree it’s quite good – yes the stars are not perhaps as pretty in their distribution as some of the pictures from the Hubble (see below) but that is quite forgiveable.

Despite the boring uniformity of the stars, I want to draw your attention to the complexity involved in creating this animation. Just ‘guessing’ the paths of the stars by having them start small, somewhere near the middle, and then gradually grow and swing to one of the edges will not do. I tried this, trust me, it looked crap.

No, it turns out the only way to make this look decent is to do the honest thing and create a virtual 3-d world and then place the stars in it, then fly the camera through the space and have the computer figure out the paths for all the stars. Sound tricky? Well it bloody well was in 1995 when I tried it, though I reckon it’s easier now. I used POV-Ray to render hundreds of stills and then tried to create a loop to make an animated gif. It was only like 200-200 pixels and it took days to render but it eventually finished and looked – absolutely nothing like the windows screen saver.

You see, I made the school-boy error of distributing stars ‘realistically’ in my 3-D space – I put them proper distances apart, randomly, and I gave them realistic ‘sizes’ (relative to the inter-star distance). Instantly I had my first problem. The stars were all too small to even be detected by the renderer. Ok, so it turns out stars don’t work like normal things, their apparent size is not due to their actual size but a combination of their brightness and their distance. Fine. So I had to make them far bigger so they could be seen (which is utterly wrong wrong wrong to my purist heart).

Ok, so now I had spots. Did we get that sense of flight? No.

The next issue was that you needed only a few stars to create a ‘busy frame’ (say 20 stars), but most of them were stupendously far away and would stubbornly refuse to budge. The only option was the put absolutely bazillions of stars in the field so that at least a few were nearby enough for you to ‘swoosh’ lavishly past. Of course, to get that many stars, the whole view has to be completely plastered with stars – to the point of being a plain white screen. So I had to do another fudge – I had to create a sort of ‘fog’ that filtered distant light. This meant the viewer would only see nearby stars. Wrong wrong wrong again!!!! I happen to know from my own space travels (on spaceship earth) that we can see rather far without trouble, and thus this fog effect is a terrible hash.

However, I was getting somewhere with the sim. It looked like dots moving now. They did not get any bigger as they got closer, but they did move faster and get brighter, due to the fog. But damn, all the ‘nice’ starfield sims did have the stars actually getting bigger, so now I increased the size of the stars again – so big that the stars were literally only a few dozen diameters apart and hey presto, it now looked good.

binary stars

Stars are not happy bedfellows!

Now think about that – the stars were only a few dozen diameters apart. The earth is actually about one-hundred sun-diameters from the sun; so what we are talking about it a super dense space, rammed with stars. Wrong wrong wrong. Stars that close tend to get involved in all-out gravity war (see the picture!)

So it occurs to me that the nerdy folks who have a hand in creating those ‘nice looking’ simulations are probably aware of their dirty little crimes. These simulations are not simulations at all, they are but an ‘artist’s renditions‘. Now that is an insult of great proportion to any red-blooded computer programmer. All I can say is, you should have formatted that floppy when you realised what you were doing and moved on with your life. It’s too late now – I know your crimes and will not let you sleep easy tonight.

===================

Update, 2011…

Ok, I have that out of my system. The question is (it should be burning your lips): what does superfast space flight look like then?

To answer this well, you simply need to put more effort into the simulation – you need to consider the great asymmetries in the star distributions – think how small they really are, then think about their clusters, then spiral arms, then galaxies, then clusters of galaxies, then…

I have referenced this video before and I do it again unashamedly – take a look, because they have already done what I suggest…

[youtube=http://www.youtube.com/watch?v=0fKBhvDjuy0]

I think the makers should get a Nobel prize.

===================

Update 2012…

Ah, I am not alone in my nerd-dom. Now you can fly around in a pretty darn impressive virtual universe and see for yourself how the stars really actaully fly past. Happily, the results are not at all like most starfield simulators. You can fly vast distances with the sky literally ‘unmoved’. It is only once you come near a star or star cluster that those few will move, and only when you are moving stupidly fast yourself (like 2 parsecs per second) in a dense part of a galaxy, will you get anything like the old Windows starfield effect. My inner nerd feels justified. You can run the simulator on your own PC, get it at:

http://en.spaceengine.org/

Or read about it at io9:

http://io9.com/5924776/new-simulation-is-as-close-to-traveling-through-space-as-it-gets

Amazingly, this has been in the works for some time – this video from the sim was uploaded in 2009 already, it gets to the starry stuff in the second half:

[youtube=http://www.youtube.com/watch?v=7qDnoHRBItg]

The Apple Mac: It’s a religion…

It has been explained by writers better than I how our minds are wired in a way that makes them vulnerable to religion.

Whether it is our desire to feel secure or have simple and complete explanations for natural phenomena or simply because we enjoy the social scene at church, there is no doubting the power of the effect. Even in modern times, entire lives, indeed entire civilizations are devoted to the superstitious concept of supernatural Gods.

Although L. Ron Hubbard may have started a religion while knowing it was all a sham, most religions did not need such deliberate action. Our innate need to have faith in things has allowed religious concepts to emerge and evolve freely in our communities as far back as records go.

So why do I bring that up?

It occurred to me today while pondering why people are so defensive about Apple Mac computers – I realised that their behaviour had much in common with religious ‘zeal’.

Then it occurred to me how much the success of Apple relies on perception and conception. If it was just about getting the fastest computer, you would not buy a Mac. If it was about buying something that has wide compatibility, you would not buy a Mac. If it was about cost, you certainly would not buy a Mac.

Some might argue that Macs are more intuitive and ‘easy to use’. These are people whose idea of computing is buying a shiny box, plugging it in and doing exactly what they are expected to do. They are people who just accept it when they are told they need to buy a new printer. Or worse, they blame the printer – what a crappy printer, not compatible! These are people who do not need to set up a complex network, or run a database server.

Anyone who has a Powerbook G4 that cost several grand and is not actually compatible with the latest OSX release, yet needs that OSX release in order to actually work, and still hugs and caresses the machine as it it were a newborn baby while defending its honour and wanting to spend another several grand on a newer shinier one, is, in my opinion, dabbling in a cult.

OK, before you write me off as some sort of anti-mac fanatic, I will admit they are beautiful.

Moving swiftly on, I think it is worth analysing Apple’s success.

How does a company that controls the details of their products so completely compete with a product (the PC) that is made by hundreds of companies all constantly competing, innovating, coming and going, rising and falling? The modular design of the PC allows almost anyone to buy all the bits and assemble the machine themselves; with so many companies making monitors and keyboards and hard drives, some will make bad (fatal) decisions and die, some will make good decisions and thrive and if there are enough upstarts to keep up the supply, the consumer will only ever see the winners, even if their victory was a flook, it was a victory none the less.

You could say that PC is the computer you get from natural selection (survival of the fittest), the Mac is the the computer you get when you try to control the evolution (unnatural selection).

Now a company that tries to make everything itself can capture the value chain, sure, but as it is only one company, it cannot make even one fatal decision, and thus needs to be a little more cautious. This means it is doomed to always lag slightly on the performance vs value curve – so what does it do?

Easy, get the consumer to accept poor value. Make up for performance by buying in high quality technologies (lcd screens, hard disks, etc), and make the customer pay the premium. Then focus on marketing.

Marketing is the art of making people want something. It is unnecessary for products people need.

So what happened at Apple?

Apple, perhaps by good luck, became perceived as a David vs the Goliaths of IBM and Microsoft. For some reason (was it deliberate?) Apple computers gained traction in music recording and graphic design, and gained a sort of bohemian chic that is rather impressive considering that it is essentially “Big Business” and, like most companies, designed to make money.

Clever partnerships, and particularly the inspired partnership with Adobe (think Acrobat PDF’s, think PhotoShop) strengthened their position with journalists, publishers and illustrators establishing the Mac as the creative profession’s computer of choice.

This turned out to be a good thing, as the naughties have been the most art friendly decade yet, as popular culture has come to resent things like ‘work’ and ‘industry’, and a certain sections of society have come to view activities like sport as trivial and meaningless when compared to the value and depth in culture, poetry, good food, yoga, spiritualism and so on.

In other words, the artists have moved up in the world.

Some of the more switched on folk will realise that brands like Gucci/Armani/Christian Dior or Ferrari/Porche/Aston Martin  or Rolex/Michel Herbelin/Patek Philippe are based entirely on massaging the egos of their customers, and in the last case, they probably don’t even keep better time than a black plastic Casio.

But not many of the arty crowd have realised that Apple is using their independent nature against them. The Mac user seems to be infected with the idea that in using a Mac they are somehow being beneficent to the world, will somehow be more creative, they they are part of some loving brotherhood that has exclusive access to the truth and the light.

This is because, by accident or design, the Apple brand has been developed to find that part of our mind that wants to believe and wants to belong, and is easily dazzled; the brand is acting like a religion.

———————

Apple’s alliance with artists continues with U2 and the Black Eyes Peas, both highly credible symbols of free-thinking modernism. But I want you to ask yourself: what is free thinking about this computer company? I’m not sure, but I suspect the only free-thinking thing about Apple is its association with icons of the free-thinking world. It is just an electronics company for Pete’s sake. Like Sony, like Samsung, like Nokia.

If you believe there is any more to it than that, then you are welcome to pay for it.

=======================

PS: Besides the defunct G4 in the drawer, there is also an iPod classic in my home. I like it. I like to hold it. Mmm.

Information: what exactly is it?

I was walking to the tennis courts in Battersea Park a few years back, when I heard something on my Walkman radio. It stuck with me for years, and until tonight I haven’t followed up on it, read about it or written about it. Though I have told everyone at my work, which has resulted, as usual, in groans about how nerdy I am (and genuine amazement at how I could spend valuable time pondering these things).

What I heard was a very short anecdote about someone who wrote a little regarded paper in the 1940’s (see ref below) in which he made an attempt to define a ‘measure’ for information. Although I never read any more about it (until today), what I heard was enough to set me thinking…

————–

Now, if you know lots about this subject then bear with me. Those readers who don’t know what he came up with: I challenge you to this question:

  • what contains more information, a phone-number, a ringtone or a photo?

Are they even comparable?

Bits & Bytes…

In this computer age, we already have some clues. We know that text doesn’t use up much disk space, and that photos & video can fill up the memory stick much quicker.

But what about ZIP files? These are a hint that file-size is not a very accurate measure of information content.

So what is a megabyte? Is it just so many transistors on a microchip? Happily, its not, its something much more intuitive and satisfying.

Information: what is it?

If you go to Wikipedia and try to look up Information Theory, within a few seconds you are overrun with jargon and difficult concepts like Entropy; I hope to avoid that.

Let’s rather think about 20 questions. 20 Questions is the game where you have 20 questions to home in on the ‘secret’ word/phrase/person/etc. The key, however, is that the questions need to elicit a yes/no response.

To define information simply: the more questions you need in order to identify a ‘piece of information’, the more information content is embodied in that piece of information (and its context).

This helps us to answer questions like: “How much information is in my telephone number?”

Let’s play 20 questions on this one. How would you design your questions? (Let’s assume we know it has 7 digits)

You could attack it digit by digit: “is the first digit ‘0’? Is the first digit ‘1’? Then changing to the next digit when you get a yes. If the number is 7 digits long, this may take up 70 questions (though in fact if you think a little you will never need more than 9 per digit, and on average you’ll only need about 5 per digit – averaging ~35 in total).

But can you do better? What is the optimum strategy?

Well let’s break down the problem. How many questions do we really need per digit?

We know that there are 10 choices. You could take pot luck, and you could get the right number first time, or you might get it the 9th time (if you get it wrong 9 times, you don’t need a 10th question). However, this strategy will need on average 5 questions.

What about the divide and conquer method? Is it less than 5? If yes, you have halved the options from 10 to 5. Is it less than three? Now you have either 2 or 3 options left. So you will need 3 or 4 questions, depending on your luck, to ID the number.

Aside for nerds: Note now that if your number system only allowed 8 options (the so-called octal system), you would always be able to get to the answer in 3. If you had 16 options (hexadecimal), you would always need 4.

For the decimal system, you could do a few hundred random digits, and find out that you need, on average 3.3219… questions. This is the same as asking “how many times do you need to halve the options until no more than one option remains?’

Aside 2 for nerds : The mathematicians amongst you will have spotted that 23.3219 = 10

Now, we could use 4 questions (I don’t know how to ask 0.32 questions) on each of the 7 digits, and get the phone number, and we will have improved from 35 questions (though variable) to a certain 28 questions.

But we could take the entire number with the divide and conquer method. There are 107  (100 million) options (assuming you can have any number of leading zeroes). How many times would you need to halve that?

1. 50 00o 000
2. 25 000 000
3. ….

22. 2.38…
23. 1.19…
24. 0.59…

So we only needed 24 questions. Note that calculators (and MS Excel) have a shortcut to calculate this sort of thing: log2(107) = ~23.25…

OK, so we have played 20 questions. Why? How is the number of questions significant? Because it is actually the accepted measure of information content! This is the famous ‘bit‘ of information. Your 7 digit number contains about 24 bits of information!

Epilogue

As you play with concept, you will quickly see that the amount of information in a number (say the number 42), depends hugely on the number of possible numbers the number could have been. If it could have been literally any number (an infinite set) then, technically speaking, it contains infinite information (see, I’ve proven the number 42 is all-knowing!).

But the numbers we use daily all have context, without context they have no practical use. Any system that may, as part of its working, require ‘any’ number from an infinite set would be unworkable, so this doesn’t crop up often.

Computer programmers are constantly under pressure to ‘dimension’ their variables to the smallest size they can get away with. And once a variable is dimensioned, the number of bits available for its storage is set, and it doesn’t matter what number you store in that variable, it will always require all those bits, because it is the number of possibilities that define the information content of a number, not the size of the number itself.

————

I hope that was of interest! Please let me know if I’ve made any errors in my analysis – I do tend to write very late at night 😉

References:

1.  Claude Shannon, “A Mathematical Theory of Communication” 1948