Monday, 26 November 2012

Scatter Plot for Temperature vs Humidity in my Loft over 24 hours

Following a comment on my previous blog post by Asher on the relationship between temperature and relative humidity (see my temperature/humidity sensing project using a Raspberry Pi), I decided to check this out using my data. First I reduced my data set to a single 24 hour period and then replotted a timeseries of temperature, then time vs humidity, then a scatter plot of temperature vs humidity. I can see that there is some relationship between temperature and humidity in my data but it's more complicated than a simple correlation. I wonder if part of the problem is the presence of people in our house. Do we create extra humidity irrespective of the rise of temperature caused by the central heating system? This could be humidity in the form of sweat or the form of cooking. Food for thought definitely ...

Tuesday, 20 November 2012

Using R to plot my kitchen temperature and humidity

I've had my Raspberry Pi temperature and humidity sensor running in my kitchen for over 24 hours and I thought it would be useful to import the data into a proper stats package so I installed R on my MacBook and imported my data. You can see two plots, one of time versus temperature and the other of time versus humidity. You can see from the temperature plot when we have our central heating system on at various times during the day.
The humidity data looks a bit less clean than the temperature plot. I don't know why the humidity is rising from midnight onwards. Perhaps this is due to the ambient humidity from outside the house? I'm imagining that the variations in humidity during the day are due to cooking in the kitchen. It would be interesting to see what its like when we are on holiday.

So next we need to start doing some statistical operations with the data ...

Saturday, 17 November 2012

A small contribution to the Internet of Things: My Kitchen Temperature using a Raspberry Pi

Today I took a second step in my Raspberry Pi journey and did some instrumentation of my home. For those that haven't yet heard about the Raspberry Pi, it is a small, cheap hobbyist computer that has captured the imagination of young and old. Check out the Raspberry Pi Foundation for all the details and how to get your own.

I got my Raspberry Pi a while ago now and the first thing I did was create an XBMC media centre for my TV. This was one of the reasons why I wanted a Pi and it was really straight forward to set it up. I didn't really use it much because to be honest, my harddisk recorder on Freeview had more than enough TV for me to digest and if I wanted to catch a TED talk or check out Khan Academy I would use the iPad. So the Pi lay behind the TV for a good few weeks undisturbed until today.

A few weeks ago I started planning to make my first homebrew craft beer at home and I wanted to find out what the temperature would be in my kitchen overnight. I understood that you need to keep beer fermenting between about 20 and 25 degrees Celsius and I didn't want to come down in the middle of the night once the central heating had gone off to find out what the ambient temperature of the kitchen was.

That was when I discovered the awesome Adafruit website. I imagined that someone had already built a temperature sensor on a Raspberry Pi and as if by magic I found this DHT humidity and temperature project created by LadaAda! I ordered the breadboard, Cobbler kit, sensor and a pack of resistors and then days later (i.e. today) it all turned up in the mail.

After soldering the cobbler kit together I assembled the kit, downloaded a fresh Debian Linux image for my SD card, then plugged everything in and started on the software. I didn't have to write anything but I had a lot of trouble getting the C code to work until I realised I hadn't followed the full instructions and compiled the code! There is also a Python program that takes the output from the C Program and uploads a record into a Google spreadsheet for me.

I now have a lovely Google Spreadsheet which gets updated every 3 seconds with the temperature and humidity in my kitchen. I took a sample of the log and copied into a lovely little website called Datawrapper which is like an online version of Excel charts but you can embed the charts in your blog as I have done! You might notice a discontinuity in the humidity figures. This is because I stopped logging for a while during making dinner. The humidity was rising in the kitchen due to the cooking but I wasn't measuring it!

So, what have I learned and what's next? Well I've learned that despite the simplicity of the project there are always little challenges along the way. I thought I would need to become a blackbelt in Python as well as brushing up on my C. As it happened I just needed to follow the instructions more clearly. Secondly it got me thinking about how instrumenting our world and sharing the results online is going to become a really big thing in the future. The Internet of Things is definitely going to be a reality. When it does, we will need a lot more than Google Spreadsheets and Datawrapper to make sense of it all but that is where Big Data comes into its own ...

Monday, 3 September 2012

Oh Internet, I have questions - Find me the answers

Library Word Find Puzzle #2

Inspired by the blog post "What Is Search Now? Disjoined" it got me thinking about my own journey into the world of Internet searching.

I'm actually trying to remember a time 20 years ago before Internet 'search' was a reality and I can just about remember it. I remember when I got my first PC at work, an IBM ps/2 with no Microsoft Windows. I had not experienced the delights of Mac at this time. My Personal computer had a quaint textual menu system called AutoMaxx for accessing things like WordPerfect 5.1. It was a long time before the Internet was popular. It was a while before I got Windows but that is another story. It was a time when 'search' had little meaning to me on a daily basis. I wasn't a mainframe user. And then the Internet happened and now I 'search' every day without thinking about it. It has become part of my amygdala, my dinosaur brain. It has disappeared from my conscious thought processes to something I do daily without thinking. But what if it wasn't like this? What if the history of computing and the history of 'search' had been different?

What if we didn't have search as a concept in its current form? I'm thinking about the current concept of textual search using keywords to drive Google to find web pages on the Internet. What if we thought about the ultimate purposes of 'search' on the Internet and asked these questions instead? Imagine if a different world without search as we know it but with answers to your questions.

What if we called the thing we do when we search 'answering' instead? We use search often to find out information. Another way of looking at this is to see the activity of searching on the Internet as answering a question. The information is the answer to the question. So for me here are some of the questions I ask when I am searching Google: 

1. What will the weather be like in Cheltenham tomorrow as I want to cycle to work and not get wet? 
2. Is there anymore genealogical source information related to my ancestor Henry Derby who was born in Ireland? 3. What is the origin of the word 'mufti' (we used the phrase at mealtime and the children wanted to know where it came from. I had a hunch that it was of Arabic origin and had come into the English language via the military. I was right). 4. Is there any interesting news for me to read? (or perhaps I should say, given my interests, is there any relevant news for me?) Am I asking too much to want an answering service more than a search service on the Internet? Can I do some of this already by judicious use of an RSS reader or is this a possible future of search? Is this where Apple's Siri service hopes to take us in the future? Maybe the question I would like to ask my computer is this, "What will the future of search be on the Inernet?"

Wednesday, 9 May 2012

An unusual place to find the Perfect IT Company

Imagine a company when you join they give you a MacBook Pro and an iPhone ...
Imagine a company that is serious about users, serious about design ...
Imagine a company that lives on the Internet ...
Imagine a company that uses only open source software, open standards …
Imagine a company that has no infrastructure apart from wifi, broadband and the Cloud ...
Imagine a company that creates an environment where technology leaders flourish ...
Imagine a company that is fun and serious all at the same time …
Imgaine a company that is going to change UK government IT forever …

 … welcome to the Cabinet Office!

WHAT, I hear you say. Did you say the Cabinet Office in Whitehall? Don’t you mean some cool design agency or Internet startup company in Palo Alto or maybe even the Tech Hub in London?

No. This is the Cabinet Office. Well actually the Government Digital Service to be precise, a small but perfectly formed group within the Cabinet Office that is literally changing government IT for the better. I was lucky enough to visit the Gov Digital Service yesterday and take in the whole experience for real. I didn’t know whether to shout for joy or weep like a baby as I’ve never seen another other government department like it. Who would have thought that cool Britannia would turn up in the Civil Service? I could wax lyrical about their agile software development or their design principles but you can read that on their website. Why not experience the fruit of their labours on the Beta site

The key takeaways from my visit were:

• Government can be the best at agile, delivering products in 6 weeks or less.
• It is possible to put users first, problems second.
• Design really matters and works!
• Iterate. Then iterate some more. Then iterate again ...
• Robust conversations are needed about risk.
• Government can use webscale technology e.g. MongoDB, AWS, Ruby, Scala etc.
• Gov can do open standards, API based services, open source software etc
• Tech leaders can flourish in government.
• MacBooks and iPhones as the default desktop ...
Inspirational Leadership works ... 
Don't just talk. Just get on with it. Don't wait for perfection. Take action.

Monday, 23 April 2012

US Craft Beer, Beer Exchange and Innovation

Growlers craft beer & ales
Photo By Beaufort's TheDigitel

What has beer got to do with innovation? It turns out quite a lot as I discovered from listening to the Food Programme on Radio 4 yesterday.

A few years ago if you had asked me what I thought about American beer, I would have said not much. Maybe a few well known brands would have come to mind, bland lagers like water with little flavour and in fact probably all tasting the same. Last year I had the huge fortune to visit the Cambridge Brewing Company when I was in Boston and this changed my view for ever. I was reminded of this experience yesterday as I listened to the Food Programme.

The US once had an incredible diversity of beer brewing in every city and every town. This can be explained given the number of immigrants from Europe who had brought their local brewing traditions with them to the new world and had continued to nurture them at a local level uninhibited. But this was all set to change.

In the early part of the 20th century the diversity of brewing declined due to a number of factors. Many of the brewing communities who kept the brewing traditions alive spoke German and held their meetings in German. Understandably these meetings declined after the 1st World War because of the anti-German sentiment in the wider population. Possibly a bigger reason was the rise of industrial lager brewing.

Lager hit a 'sweet spot' in the US even though it was more expensive to produce because it could be produced at industrial scale and had a long shelf life, good things if you want to make a lot of money. After the prohibition era the stage was set for a few big companies to hog the market and we have the popular image of US beers today.

However this all started to change a few decades ago when the ban on home-brewing was lifted and airline taxes were reduced enabling middle income families to travel to Britain and continental Europe. More US tourists began to experience the diversity of beers we have to offer this side of the Atlantic and when they returned back home they said, "why don't we have anything like this?" And so, the Craft Beer movement took root. People began to brew their own beers and micro-breweries started to spring up all over the place.

Given the rich heritage of the US people and the spirit of innovation (remember the Cambridge Brewing Company is down the road from that other centre of innovation MIT), the craft beer movement started to produce some amazing and wonderful beers, a true renaissance of beer making has occurred.

But of course it didn't stop there. The US Craft Beer scene has started to impact the UK market and of course UK micro brewing. It turns out that we love what US craft brewers are doing and pubs in the UK are starting to stock some of these beers. The craft beers are even influencing the way brewers are brewing beer in England. It's what is called "Beer Exchange". I love this term. This for me is a key part of any innovation. It's about a shift in attitude. It's about meeting other people and developing new communities. It's a way of promoting diversity and getting a whole lot of interesting products as a result. In both the US and in Europe we are seeing a renaissance in beer brewing where wild yeasts are being released into the brewing process combined with interesting hops, herbs, and spices, replacing the mono-culture that has dominated for so long.Innovation is definitely happening in the beer industry and about time too.

But what can this story tell us about innovation more generally? Well, for me innovation doesn't start with technology. It starts with travel. Travel in one's own mind, travelling from one's own usual circumstances, whether that's from America to Europe, or maybe even the next village, and meeting people who are different to ourselves. Secondly it's about using your senses and experiencing what these people have to offer that is different. This is the diversity thing. And in order to embrace diversity it requires an openness to new ideas and a willingness to take action, to go back home and to start changing the way you do things.

You may not like beer. You may be tee-total. That's OK. That's not the point. Whatever is your 'beer', there's something that you like, that you care about, that you make or consume or think about. So, go somewhere on a journey and find out how other people are doing the thing you care about. Keep an open mind. Do some "Beer Exchange". Look for new ways of doing the thing that you like and get excited about it. Enjoy it. Bring that thing back home and make it happen. Change it. You'll love it and you'll make the world a better, more interesting place to be. Cheers!

Sunday, 4 March 2012

Obesity, Calories & Science: Correlation is not Causation

sourced from XKCD
Creative Commons Attribution-NonCommercial 2.5 License.

It's just over a year since I embarked on a new style of eating after reading Timothy Ferriss' book 'The 4-Hour Body'. This has resulted in me going from 14 to 12 stone, shedding 2 stone (that's 28 pounds or 12.7kg) in the last 12 months. I had reduced two waist sizes from 36 to 32 inches and now buy small t-shirts and tops. I haven't yet put the weight back on, and I don't think I will given what I know now. I had tried dieting before and had lost some weight in previous years, but I put it all back on again so wasn't really looking for another diet.

It all started for me serendipitously when I read an article about Tim Ferris in Wired UK magazine back in November 2010, and had been intrigued by his experimental lifestyle and his claims of losing weight forever without feeling hungry. Then in January 2011 I saw his book in Waterstones and decided to buy it and read it and follow at least some of his advice. This involved reducing the quantity of (mainly processed) carbohydrates as a percentage of my diet and having a binge day on a Saturday, as well as introducing a measuring regime that involved a set of bathroom scales, a tape measure, my waist, hips, triceps and thighs.

My journey was not without difficulty. I never felt hungry but it did require some planning and some changes to my eating habits. This required me to persuade the rest of my family and friends that I was not on some loony Atkins protein fetish diet that was going to kill me in several months time. I swapped my normal cereal and milk breakfast for 2 or 3 eggs either scrambled or omelette. For lunch I took a while experimenting with various combinations, but settled on a can of mixed beans in water (no sugar) mixed with a tin of mackerel and some balsamic vinegar and seasoning. For my main meal I had to persuade my wife to make a low carb version, e.g. lasagne without the pasta, or shepherd's pie without the mash. This was difficult at first but after a few months it's become a habit.

Now even my wife is eating fewer processed carbs and is looking thinner too! I don't get hungry during the day time, and I snack on cheese or nuts in the evening if I have to. I drink plenty of tea, coffee, water and Pepsi Max. I guess the artificial sweetners aren't doing me much good but I didn't say I was an ideological dieter. On Saturdays I go mad for carbs, usually starting with a couple of bagels and chocolate spread, and lots of bread at lunchtime. Evening meal could be a curry or fish & chips or macaroni cheese or pizza. Fruit and fruit juice too. Get the idea? I snack on chocolate, biscuits and ice-cream during the day and have a couple of Belgian Beers in the evening, hopefully without being sick. On Saturdays I also do high intensity exercise for a couple of minutes in between meals, which apparently helps to minimise the storing of fat during my binge day. I don't know the science behind this theory but I do it anyway. Certainly the binge day means that I don't miss my treats during the rest of the week. It all seems to work like clockwork or at least it has worked for the last 12 months. So why the blog post?

Well, you can imagine that my appearance and strange eating habits have had quite an impact on me personally, as well as on those around me. Over the past few months I've been searching for answers to why it seems to be working. I started reading some of the popular literature and blogs on low carb dieting, and that's when I felt like I had entered a war zone or maybe a religious battle. I couldn't believe how contentious the ideas of reduced carbohydrate diets were and how little evidence there seems to be for the received wisdom that passes for scientific advice on a healthy diet. I've been particularly impressed with Zoe Harcombe's book 'The Obesity Epidemic' as it seems to be well argued and full of relevant academic references. I'm not a medical researcher in obesity so I don't really know what I'm talking about when it comes to triglycerides and insulin, but I have a science background and her work appears credible. However after making a few Google searches, you'll find out that Zoe Harcombe seems to have a death wish when you read what other people are saying about her, mainly ad hominem attacks which I suppose is a perverted form of flattery.

Zoe challenges the fundamental doctrine of weight loss in the Western world, that '1lb = 3500 calories' and 'to lose 1lb of fat you need to create a deficit of 3500 calories'. She asks a really simple and obvious question but one that most people never ask - How do we know that to lose fat we need to eat less and/or exercise more? The 'calorie equation' appears to be based on an assertion in a US diet book from the early twentieth century with no scientific basis, at least that's the way it appears from reading Zoe's book.

There are other food heretics writing iconoclastic books that challenge the received wisdom too. For example Gary Taubes is a food journalist in the US who has written a detailed and closely argued book on why we get fat. Both Harcombe and Taubes show how the 'calorie equation' has become the bedrock of advice for health professionals dispensing guidance on how to reduce excess bodily weight, but much of the advice is rubbish in my opinion. The 'calorie equation' is such an obvious result that no-one challenges it, even when the evidence is pointing elsewhere. So why is this advice not working?

The populations of the western world continue to become more obese year on year, and yet for thousands of years, up until the Second World War, there wasn't a major problem with obesity. Are we just not trying hard enough to lose weight by dieting or are we not getting enough exercise? Are we just plain lazy? Maybe there is another reason. Maybe the advice we are receiving is wrong. Maybe the human body is more complicated than a bunsen burner. Maybe we store fat as a result of hormone behaviour as regulated by carbohydrate intake that stimulates the production of insulin in the body. There is a widely held assumption that saturated fat and cholesterol ingested into the body will make you fat, so we are encouraged to reduce our fat intake and eat carbohydrates instead, alongside protein and vegetables.

Changing the question, why are we still generating new diets and diet books each year? Surely if any diet had been truly effective in the last 20 to 30 years we would all have switched to this diet and we would not need the latest book. What would happen if we were to bin all the diet books and 'scientific' nutritional advice, and eat natural food that included saturated fats and cholesterol? What if we reduced our intake of processed carbohydrates, such as sugar, white flour and corn syrup? Well that's exactly what I've done over the last 12 months and I've lost 2 stone in weight without feeling hungry. OK, I did read a couple of books on diet and fitness, but I'm definitely eating a lot more 'natural' food. Maybe we need to re-examine the science to find out the true causes of weight gain.

This is where the XKCD cartoon above comes in. Every good statistician knows that correlation is not causation. Just because I observe two things occuring together regularly doesn't mean that one of these things causes the other to happen. For example, just because I lost weight when I reduced my carbohydrate intake, doesn't mean there is a causal relationship between weight loss and reduction in carbs. This needs to be examined, scientifically. Perhaps there is something else more complicated going on. The only way to find out the science behind dieting is to do some proper scientific research. (Is this a tautology?) Welcome to the war zone ...

I couldn't quite believe how such a simple thing as the 'calorie equation' could be so contentious, but it is. It doesn't take much reading around the subject to realise that scientists and health professionals are as human as the rest of us. They have reputations and careers to protect. Who decides on the funding of particular scientific research? Who funds the public advice that we receive from government and non-government agencies? What role do the food industry and supermarkets play in promoting healthy eating?

I got really exercised (no pun intended) at lunchtime today as I listened to Radio 4's Food Programme which happened to be covering the wider topic of what food we should be eating. This was while I was reading my Zoe Harcombe book. Spooky! Remember correlation does not mean causation, so I don't think there was a higher power at work. Why have we settled for bad advice that causes our population to become obese and develop a number of related diseases such as diabetes and heart disease? The same thing is now happening in China as they become wealthier as a nation and aspire to western lifestyles and western diets. They are exhibiting all the diseases that were formerly restricted to the west. Why has science not fixed obesity yet? In the words of Thomas Kuhn it seems we need a paradigm shift in our thinking so that scientists can ask the right questions and do the necessary research to help us manage our weight.

Perhaps in the meantime we can look to traditional ways of dealing with food. World class food writers such as Joanna Blythman and Michael Pollan certainly think so. They were on The Food Programme promoting their new books, as well as encouraging us to eat 'natural' food, reducing the amount of processed food we eat and reducing the intake of processed carbohydrates. Maybe the paradigm shift is coming. I'm hoping science will catch up. In the meantime thousands of generations of traditional foodies might be right. Out with processed carbs. More protein. More fat. More veg. More nuts etc...