BBC: UK energy customers ‘overcharged’

25 June, 2009 by Mathew

A story by BBC on reports that UK households are being charged by 1.6 billion pounds.

http://news.bbc.co.uk/1/hi/business/8117962.stm

The report is denied by the Energy Retail Association. Who say they need to hedge their purchases to guarantee supply.

We need to keep an eye on the reported profits of these energy suppliers (Big 6).

Latex Poster/ Modelling Thermal Conductivity

17 June, 2009 by Mathew

Norman Gray and Graeme Stewart at Glasgow have provided useful examples to make posters using Latex.

I used these to make a tex file, which produced a poster using pdflatex. Should also be possible using latex command if you include graphics as eps rather than pdf. Make sure if you convert graphics to pdf or ps that you have a bounding box (use pstoeps command for example), otherwise your poster will break horribly. It was important to convert from eps to pdf using the epstopdf command rather that ps2pdf.

This saved me time by allowing me to use the equations from latex directly, and allowed me to include my graphs at high resolution – it doesn’t make sense to convert to jpg or other bit map to include in a powerpoint presentation file.

You can find the poster here: Poster (best viewed with xpdf)
and the latex file to make it here: Poster source file

Thanks to the people who showed an interest in the poster. I wish I had taken picture at the conference to make this post more dynamic!

My second g++/cpp program – Using a Makefile

17 June, 2009 by Mathew

I downloaded the example files from here:

http://www.cs.bu.edu/teaching/cpp/separate-compilation/

This demonstration explains how to compile using the make file. In this example you split up the program into separate modules, and use a make file to compile. This has the advantage that after making a change, only that part of the program needs to be recompiled.

Read the instructions on the web page, after downloading you need to edit Point.h to prevent it being included twice.

#ifndef POINT_H
#define POINT_H
/*
* File: Point.h
* Last Modified: January 31, 2000
* Topic: Modules, Separate Compilation, Using Make Files
* ----------------------------------------------------------------
*/

#include // one of two
using namespace std; // two of two, yay!

class Point
{
public:
Point();
Point(int xval, int yval);
void move(int dx, int dy);
int get_x() const;
int get_y() const;

private:
int x;
int y;
};

#endif

otherwise you will get the error:
g++ -c -o main.o main.cpp
In file included from Rectangle.h:13,
from main.cpp:9:
Point.h:13: error: redefinition of 'class Point'
Point.h:14: error: previous definition of 'class Point'

The files you download are: main.cpp, Makefile, Point.cpp, Point.h, Rectangle.cpp, Rectangle.h

and the Makefile looks like this:

# Makefile for Separate Compilation Example

# *****************************************************
# Parameters to control Makefile operation

CXX = g++
CXXFLAGS =

# ****************************************************
# Entries to bring the executable up to date

main: main.o Point.o Rectangle.o
$(CXX) $(CXXFLAGS) -o main main.o Point.o Rectangle.o

main.o: Point.h Rectangle.h

Point.o: Point.h

Rectangle.o: Rectangle.h Point.h

after running the make command you will have a bunch of object files (.o) and an executable. If you edit Rectangle.cpp and run make again then only Rectangle.o needs to be made again. The programs fragments of binary are linked by the .h header files.

if you run without preventing the multiple inclusion you get this error:

$ make
g++ -c -o main.o main.cpp
In file included from Rectangle.h:13,
from main.cpp:9:
Point.h:13: error: redefinition of ‘class Point’
Point.h:14: error: previous definition of ‘class Point’
make: *** [main.o] Error 1

After correction you get this:

$ make
g++ -c -o main.o main.cpp
g++ -c -o Point.o Point.cpp
g++ -c -o Rectangle.o Rectangle.cpp
g++ -o main main.o Point.o Rectangle.o

Edit Rectangle.cpp and run again; (e.g. open and save to update time, or just type “touch Rectangle.cpp“.


e$ make
g++ -c -o Rectangle.o Rectangle.cpp
g++ -o main main.o Point.o Rectangle.o

My first g++/cpp program

17 June, 2009 by Mathew

test.cpp is a text file containing:

#include

using namespace std;
int main()
{
cout<<"test test"<<endl;
return 0;
}

This is compiled using the command:
g++ -o test test.cpp

Missile Tests!

1 June, 2009 by Mathew

A quick look at http://www.spacewar.com/ will show the surprising news that North Korea aren’t the only ones testing missiles!

For USA news you can also see here: http://www.mda.mil

Excocet Missile Launch from wikipedia.

With so much news about North Korea launching a few rockets, you might be shocked to know that USA, Britain, France, Israel, India, Pakistan, Russia, China are all testing missiles regularly!

March 29, 2009 Indian tests cruise missile: official (developed with Russia).
Apr 02, 2009 Raytheon Standard Missile-2 Destroys Target
May 07, 2009 Raytheon Develops Anti-Surface Warfare Capability For Tomahawk Block IV Missile More than 1900 Tomahawk missiles launched in combat since 1991.
May 20, 2009 Iran hails successful test of new medium-range missile
May 29, 2009 KMSAM Program Achieves Significant Milestone (USA and South Korea)

May 28, 2009 NKorea blast likely less powerful than hoped: expert

The explosive, while larger than the first test in October 2006, was still far short of the expected yield of a crude Hiroshima-type bomb, according to Jeffrey Park, director of the Yale Institute for Biospheric Studies.

“More than likely this means North Korea tried and failed to get a simple plutonium bomb to detonate correctly,” Park wrote in an article on the website of the Bulletin of the Atomic Scientists.

Pdf from windows prn file, MS Powerpoint, MS Excel, MS Word (On Linux).

31 May, 2009 by Mathew

Having a ps file of your presentation is Dandy for printing, but to send it by email it would be better to reduce the size below 10 MB.

Our mission, to make powerpoint presentation file into reasonably sized pdf. (Note all of this was done on Linux, we tried with MS XPS printed to file and fell at the ps2ps stage).

Print to file to generate a prn file (I think this is microsoft version of a postscript file). Select paper size A4. Landscape mode. Note we used postscript driver in our emulated version of windows. (Using Wine). You may need to install a postscript driver for a printer, and select that printer, before printing to file. This hasn’t been tested by the author of this blog.

Printing to Postscript in MS Office 2003 on Linux using Wine

Printing to Postscript in MS Office 2003 on Linux using Wine

Move to the linux terminal (we tried on debian lenny but these commands are very basic – install psutils if not available).

Try to clean up file by converting to postsript, not sure this is necessary or not.
ps2ps -sPAPERSIZE=a4 file.prn file.ps

If you want to put 2 pages per size use
psnup -l -2 -s.7 file.ps double.ps

convert to pdf – downsize images to make file reasonable size. Other commands to do this automatically seemed not to work (ps2pdf14 -dPDFSETTINGS=/screen)
ps2pdf -dGrayDownsampleType=2 -dAutoFilterColorImages=false -dDownsampleColorImages=true double.ps

Cross over office is a compatibility tool which helps migration away from Microsoft Windows, they provide software to let you run many windows programs on Mac and Linux. Here is a link to the cross over office site:
CodeWeavers

2007 TED lectures and Flu

17 May, 2009 by Mathew

This video from 2007 of a lecture by Barry Schartz, in which he says we may be disappointed due to having too many choices. This leads to higher expectations, which are harder to satisfy. It’s all reasonable except he says that this is something that advertisers don’t know. This is something they really do understand better than anyone.

A very energetic talk also from 2007 talk my Prof. Hans Rosling who presenting statistics about development in different countries, and has made tools available at gapminder.com.

The gap minder website lets you make your own graphs, and the data is also available in the documentation section.

Prof. Rosling gave a warning about the swine flu on 6th May suggesting that it is overhyped in terms of deaths/news report. For this he compared the number of deaths from the flu and tubercolosis in the same peroid against the number of news reports available from searching on google news. The ratio was 8176 vs 0.1.

Flu Pandemic, How worried should we be?

8 May, 2009 by Mathew

Just for a little fun, a model was made for the number of flu cases in the various countries which are reporting data. A neural network was trained which predicts the amount of flu cases given the number of cases the day before. GDP(PPP), size of population and population density were also included as inputs. Obviously living in the UK it is more important to consider the cases in UK first.

Confirmed Flu cases in UK

Confirmed Flu cases in UK

Confirmed cases of flu in Mexico

Confirmed cases of flu in Mexico

Confirmed Flu cases in USA

Confirmed Flu cases in USA

Confirmed flu cases in Canada

Confirmed flu cases in Canada

Here are the predictions for todays flu cases in the various countries, WHO will usually release these data at around 6pm-8pm UK time, so we should be able to see how good is the prediction in about 5 hours time.

Country Predicted Cases Uncertainity in prediction
NewZealand 6 1
Ireland 1 1
CostaRica 1 1
Denmark 1 1
ElSalvador 2 1
HongKong 1 1
Israel 7 1
Switzerland 2 1
Austria 1 1
Portugal 1 1
Netherlands 3 1
Canada 232 23
Colombia 3 1
Spain 101 5
Korea 4 1
Italy 7 1
UK 43 2
France 7 1
Germany 14 1
Mexico 1419 155
US 1207 544
Guatemala 3 2
Sweden 1 1
Poland 2 1

Here are the predictions using the same data, for tomorrow cases (using the number predicted above).

Country Predicted Cases Uncertainity in prediction
NewZealand 6 1
Ireland 2 1
CostaRica 0 1
Denmark 2 1
ElSalvador 2 2
HongKong 2 1
Israel 7 1
Switzerland 2 1
Austria 2 1
Portugal 1 1
Netherlands 4 1
Canada 253 61
Colombia 5 1
Spain 127 8
Korea 6 1
Italy 10 1
UK 57 2
France 10 1
Germany 20 1
Mexico 1910 748
US 1520 643
Guatemala 4 2
Sweden 2 1
Poland 3 1

The model should be improved as more data can be included, as the outbreak proceeds. It is planned to train using the days since the start of reporting, and also the level of Alert set by the WHO. The model shows the number of cases increasing approximately linearly in most cases.

Copy files, preserve dates and permissions in unix

6 April, 2009 by Mathew

tar and feathers

This is a way to copy files in unix and keep the same time stamps, using the tar package:

tar cf – . | (cd wherever; tar -xvf -)

e.g.
change directory to path of USB stick and use:
tar cf – . | (cd /space/BACKUP/UDISK/;tar -xvf -)

kitchen rysnc

This is a another way to make a copy of a directory, the came command can be used later to update the copy with any new files from the target directory:

rsync -va directory ~/BACKUP

e.g.
rsync -va /media/MJP_8GB_Ext2/mathew/ /space/BACKUP/8GB-disk/

Read an rysnc how to.

Thanks for your Patents

31 March, 2009 by Mathew

What is a Patent?
A patent is a monopoly right granted on an invention by a government of a country, allowing the holder the right to prevent the copying of the invention.

Patents are applicable only to particular countries, and for a set time period, and must be applied (and paid) for. Having a patent doesn’t mean you have been granted the right to profit from your invention, someone else might have a patent on something required to make your invention useful. Patent law is naturally different in different countries, although there are some moves to harmonise patent law (European Patent Ofiice and Reforms of Chinese patent law due to WTO).

Patent offices:

Patents are awarded in return for the public disclosure of information sufficient to reproduce the invention. In recognition for the benefit to society from the increased public knowledge, the government gives the right to prevent unwarranted reproduction of the invention. This gives a greater return for their research expenditure, and it meant to act as an added incentive.

The applicant discloses information about the invention, and must pay application and maintenance fees if the application is granted. In return he receives the patent, which is an exclusive right to use his invention, and can have considerable strategic value.

What is an invention?
An invention could be something completely new, or an improvement to an existing invention, an alternative to an existing method, or even a new combination of existing technologies. For a patent to be granted the invention has to be technical in character (rather than just decorative), novel, inventive, and useful.

There are differences as what counts as novel, and inventive between different countries, as this is difficult to generally define.

Olympic Torch Relay Protests 2012.

27 March, 2009 by Mathew

BBC is reporting there will be no torch relay for London Olympics, after protests against the carrying on the torch for the 2008 Beijing Olympics. This must mean that London has looked at it’s human rights record, in light of recent violations, detention without trial, participating in torture, lying about the reasons for the invasion of Iraq, snooping on it’s own citizens, and realised it should be no less controversial than China.

IOC executive director Gilbert Felli said:

“After the (2004) relay in Athens, which was the first international relay, we came to the conclusion it was easier for the torch to stay inside the (host) country… There were difficulties with the NOCs (National Olympic Committees), and we also saw the risk with a torch relay going around the world… Beijing had planned an international torch relay and we accepted it. We saw in the debrief that the risk was there and the IOC decided not to do it… I think when the torch relay is inside the host country there is more control.”

But surely we all know that the Olympic torch has to be carried from Athens to the host country to make the Olympics official. Surely they can’t think it would be difficult to carry the torch across Europe? It seems like London will be trying to organise the first ever ‘low key’ Olympics.

God won’t help says bishop

26 March, 2009 by Mathew

BBC is reporting comments from the archbishop of Canterbury. The archbishop, leader of the church of England (after the Queen), has warned about the destruction of the environment, saying that we can’t expect God to intervene to save the planet.

“I think that to suggest that God might intervene to protect us from the corporate folly of our practices is as unchristian and unbiblical as to suggest that he protects us from the results of our individual folly or sin,” said he.

It’s good to see confirmation from the Church that we should live our lives as if God doesn’t exist. Hopefully one day they will admit he doesn’t, or at least that they know no better than the rest of us.

Tata Nano hits the roads soon.

23 March, 2009 by Mathew

BBC is reporting on the launch of the nano, and asking people is the Nano good for India?. Nay-sayers are complaining about the possible environmental impact of western style development in India. Yay-sayers support the effort to include those unable to purchase a car. Tata nano could have a positive impact upon air pollution in cities if it replaces older two-stroke two-wheelers, since I understand it should run on cleaner burning LPG fuel.

The release of the nano should add around 3% to the earnings of TATA group, which made losses in the last quarter after problems re-financing aquisitions in such as that of Jaguar and range rover from ford, due to the credit crunch. The manufacture of the nano has been delayed by cynical protests against building of the plant, and is currently being made in lower numbers in existing TATA motors plants, while a new facility has had to be relocated.

The world is still waiting to see if TATA can also develop an electric version.

Saving Energy

1 February, 2009 by Mathew
Make Energy Reduction Your New Years Resolution

Energy Reduction

If we all make a small saving it will make a large difference.

No, that will make a small difference :)

Small changes could only make large changes is we thought that Chaos theory could be applied. In that case “making a small saving may make a large difference” could have been used.

For a more rational assessment of energy policy you can look at David MacKays book, in which he uses numbers to examine the problems of supplying sustainable energy to the UK. The book can be found online at http://www.withouthotair.com/.

One way to save a little energy may be to use LED lighting as developed by Prof. Colin Humphreys. Which you can read about in the EPSRC press release
Low–Cost LEDs to Slash Household Electric Bills
. This can save energy in cases where household heating is supplied by Gas, or perhaps by heat exchangers (tungsten filament light bulbs also provide heating which may or may not be regarded as wasteful).

Octocentennial Celebrations

19 January, 2009 by Mathew

Cambridge university began it official octocentennial year on the 17th of January (the beginning of Lent term). This makes the University around 400 years older than America, and 100 years older than Wall-E and the Axiom. We didn’t get cup cakes in a cup, but staff members did get a nifty lapel badge. The highlight of the celebrations so far was the light show projected on to the Universities Senate house.

Cambridge University is the oldest University in the top 3 Universities in the world. That makes it older than Harvard and Stanford. At the same time it is the most modern Oxbridge University in the UK.

1209-2009

1209-2009

Frank Whittle and Aeroengines displayed on Senate house

Frank Whittle and Aeroengines displayed on Senate house

dsc00097

dsc00073

dsc00044

A specially composed bell ringing can be heard playing from the St. Mary’s Church (which featured 800 changes).

Bonus points to any one who can tell me the significance of the dates displayed along with 1209-2009 in the video.

1209-1381-1446-1584-1687-1767-1819

More pictures can be found at the phase transformations web pages: 800 Years of Cambridge University

The university also have a website with footage here: University of Cambridge: 800 Years and here: University of Cambridge 800th Anniversary Light Show. You can even follow the 800 celebrations on twitter at http://twitter.com/cambridge800 .

Emergency Number

18 December, 2008 by Mathew

My department has two emergency numbers, one for office hours (8.45-5.15) and one for the rest of the time. The numbers are 67760 for office hours and 31818 for the rest of the time. In lunch time I’m not sure what we should do.

If we add the number we get 67760 + 31818 = 99578

which is 421 short of 99999. 99999 and 421 are easy to remember. So if you can remember this helpful other numbers and one of the emergency numbers you should easily be able to work out the other one. So now you only have to remember either 31818 or 67760.

Puzzling Socks

18 December, 2008 by Mathew

Maths

Here is a puzzle about socks;

You have a drawer in your bedroom that contains an assortment of black, blue and brown socks. You start randomly taking individual socks out of the drawer, but it’s too dark to see what colour socks you have taken. How many socks do you need to take out in order to guarantee that you have got a matching pair?

The answer is Four socks. Taking out one more than the number of colours of sock in the drawer guarantees at least one pair.

Reality

Unfortunately this doesn’t help me. Each of my socks have one matching sock, so to find a pair I have to remove almost all of them.

BNP Lose data

26 November, 2008 by Mathew

The British National Party attempted to demonstrate they are just as fit to govern as the other parties last week, they are just as capable of losing data as the Labour party.

The loss of a spreadsheet containing members names and addresses may be some embarrassment for them, and many of the members which included policemen and teachers who are not allowed any party affiliation. The data was leaked by a disgruntled party member.

However the current British government is streaks ahead as the conservative opposition has pointed out, the current administration is losing more than one laptop per week. More importantly they have lost personal information from their databases on multiple occasions, compact discs and DVD including containing copies of banking information about DHS claimants, and more recently a memory stick containing a list of members of the armed services.

These loses show the fallacy in the arguments that a national database would improve security. The government relies of multiple third party vendors for the design and maintenance all it’s computer systems. It is necessary to use several vendors to claim you are getting the best deal, these projects need to go through a tender process. Since all of these people have access to the database, perhaps legitimately in some cases, or due to bad design, there are so many security holes. It should not be possible for companies or individuals to have copies of the whole database as happened to the armed services. It should not be necessary to copy all the data to DVD and post.

Tata Steel Professorship

24 November, 2008 by Mathew

Congratulations to Prof. Harry Bhadeshia and to Tata Steel on the endowment of the Tata Steel Professor of Metallurgy at the Department of Materials Science and Metallurgy of the University of Cambridge.

Tata Professor

Details from University of Cambridge News feed.

British scientists make major contribution to space travel

4 November, 2008 by Mathew

It seems like scientists from the UK may have made a major contribution to space travel, with their work to design a magnetic shield capable of protecting against solar radiation and cosmic rays.

Solar Shield just like Star Trek

Conducting experiments in the Lab the scientists (from om the Rutherford Appleton Laboratory (RAL), the Universities of York and Strathclyde, and IST Lisbon) are firing streams of charged particles and deflecting them using simple magnets. It was previously assumed that planetary sized magnets were necessary, but they have shown that is it possible to create a shielded area on a smaller scale.

Such devices may be necessary for us to travel through the Van Allen Radiation belt, as well as protecting delicate humans another obvious application is the protection of electronic devices in space and further miniaturization of satellites. Such devices can also be damaged by the solar radiation, and usually electronics have to be specially hardened against radiation damage.

The Rutherford Laboratory have a page about their work here: http://www.minimagnetosphere.rl.ac.uk/.

You can find a paper here: The interaction of a flowing plasma with a dipole magnetic field: measurements and modelling of a diamagnetic cavity relevant to spacecraft protection. R Bamford et al 2008 Plasma Phys. Control. Fusion 50 124025 (11pp) doi: 10.1088/0741-3335/50/12/124025.