001 int size = 100; Java2html
|
|
Tuesday, 2 September 2014
Conway's Game of Life written in Processing
When I feel a bit "down in the dumps" and I don't fancy getting up to do anything, I program. I think it is because it allows me to cut off from the world and focus on one tiny thing. So I have been meaning to look into Conway's Game-of-Life, but never got around to it. The past few days I have been struggling to focus on writing my thesis and ended up writing one in Processing. It's nothing spectacular, but quite fascinating to watch the different patterns grow (or not). Here is my code:
Wednesday, 23 July 2014
ODEs with Java using the Apache Commons Math library
It drives me nuts when I struggle to get my head around something just to, when I eventually do, discover that it is not really as complicated as the documentation makes it out to be. Simple examples are what I need. Here is an example of how to implement the Lorenz System. Not that I really know much about the Lorenz System but it is always a simple system to use when you want to try out a new way of solving differential equations. More information about the Lorenz System can be found in Wikipedia.
The first thing to do is to create a class containing the equations. The Lorenz system consists of the following three equations:
The next step is to write the code that will call the integrator. There are various integrators. For this application we'll use the ClassicalRungeKuttaIntegrator. You will also need a step handler to capture each step of the integration:
The step handler has to implement the StepHandler class. For the step handler below I created a constructor that takes a filename so that the results can be written to a csv file. Obviously you can do whatever you want with this data:
The first thing to do is to create a class containing the equations. The Lorenz system consists of the following three equations:
Doing this using the Apache Commons Math library means that we have to create a class that implements the FirstOrderDifferentialEquations interface. This interface requires two methods to be implemented, which are computeDerivatives and getDimension:
01 import org.apache.commons.math3.exception.DimensionMismatchException; DimensionMismatchException {
|
Java2html |
The next step is to write the code that will call the integrator. There are various integrators. For this application we'll use the ClassicalRungeKuttaIntegrator. You will also need a step handler to capture each step of the integration:
01 import org.apache.commons.math3.ode.FirstOrderDifferentialEquations; new ClassicalRungeKuttaIntegrator(0.01); WriteToFileStepHandler("lorenz.csv");
|
Java2html |
The step handler has to implement the StepHandler class. For the step handler below I created a constructor that takes a filename so that the results can be written to a csv file. Obviously you can do whatever you want with this data:
01 import java.io.File; 30 new PrintWriter(new File(filename), "UTF-8");
|
Java2html |
Last but not the least I read the file with R and created the graph:
Sunday, 29 September 2013
Motorcyclist having to cope with ignorant idiots on the road.
A message to the bloke in the big black Seat that had a blonde lady next to him in the passenger seat and was driving past St James' Park at about 16.30 on Saturday 28 September 2013.
The reason you wouldn't let me into the traffic stream is not, as you so gracefully tried to sign to me, because I am a wanker. It is because you are a very rude, immature, ignorant and dumb old fart.
Rude, because if you had any sense of decency you would not have tried to push me out of the lane by driving up my left. Considering the traffic at that time, it would have been kind to let me in even if I was, which I wasn't by the way, in the wrong.
You see this is why you are ignorant because if you knew anything, you would have known that motorcycles are allowed to filter up the right of traffic and then merge in again. Mostly, the reason it becomes difficult to merge into traffic, is because immature people like you, apparently, are afraid that some body part is going to shrink or fall off if you let a motorcyclist get in front of you. I can assure you this is not the case. You can ask your doctor if you don't believe me.
You must be dumb or else you would have done something by now to improve you knowledge of driving skills and traffic. You seemed to be about my age, give or take 5 years which means you have had more than enough time to do this.
Lastly you are an old fart just because of all of the above and "old fart" pretty much sums up the whole lot.
The reason you wouldn't let me into the traffic stream is not, as you so gracefully tried to sign to me, because I am a wanker. It is because you are a very rude, immature, ignorant and dumb old fart.
Rude, because if you had any sense of decency you would not have tried to push me out of the lane by driving up my left. Considering the traffic at that time, it would have been kind to let me in even if I was, which I wasn't by the way, in the wrong.
You see this is why you are ignorant because if you knew anything, you would have known that motorcycles are allowed to filter up the right of traffic and then merge in again. Mostly, the reason it becomes difficult to merge into traffic, is because immature people like you, apparently, are afraid that some body part is going to shrink or fall off if you let a motorcyclist get in front of you. I can assure you this is not the case. You can ask your doctor if you don't believe me.
You must be dumb or else you would have done something by now to improve you knowledge of driving skills and traffic. You seemed to be about my age, give or take 5 years which means you have had more than enough time to do this.
Lastly you are an old fart just because of all of the above and "old fart" pretty much sums up the whole lot.
Friday, 31 May 2013
Suzuki Burgman UH200
In June 2009 I bought myself a brand new Sym Symply 125cc scooter for about £1500 to get myself to and from University. 15000 miles later I sold the Symply back to the agent for £200 because it would just cost too much to keep it on the road. However, I still needed something to get to uni and back. So I put the £200 towards buying a second hand Suzuki Burgman. I have been riding the Burgman that last two weeks and it really is such a delight. Despite the horrible weather we have had up here in the north of England I find myself enjoying every minute of the trip.
One of the major advantages of the Burgman is that it has a massive luggage space under the seat. Unlike the Symply my helmet actually fits in there. Apparently it can take two helmets. I haven't tried two helmets but I'm pretty sure it will do it easily. I'm one of those people that are forever carrying myself to death with my backpack that I cart along with me wherever I go. The backpack fits under the seat with all my other goods and gadgets with ease.
The second thing that makes the actual ride such a joy is the seat. It is really comfortable. The seat is nice and wide and it has a little bit of a support behind your back. With more leg space you can stretch your legs out a bit making it much more relaxing. The Burgman is also much lower and I can put both my feet down flat when I stop, again making for a much more relaxed ride (or stop if you please).
The Symply had a little hook onto which one could hang a bag by your feet. When you hung a bag in the footwell though you had to swing your leg over the seat to get onto the scooter. Although, I guess, this kept me supple it was a bit of a drag and a couple of times the hooks on my boot nipped a tear in the seat which was very annoying. With the big luggage compartment on the Burgman this problem does not arise.
I have only filled up the tank twice so I haven't worked out the fuel consumption yet, but the fuel tank on the Burgman is at least double the size of the Symply's. I did at least 120 miles after the first fill-up and the tank wasn't empty yet.
So both thumbs up for the Burgman!
One of the major advantages of the Burgman is that it has a massive luggage space under the seat. Unlike the Symply my helmet actually fits in there. Apparently it can take two helmets. I haven't tried two helmets but I'm pretty sure it will do it easily. I'm one of those people that are forever carrying myself to death with my backpack that I cart along with me wherever I go. The backpack fits under the seat with all my other goods and gadgets with ease.
The second thing that makes the actual ride such a joy is the seat. It is really comfortable. The seat is nice and wide and it has a little bit of a support behind your back. With more leg space you can stretch your legs out a bit making it much more relaxing. The Burgman is also much lower and I can put both my feet down flat when I stop, again making for a much more relaxed ride (or stop if you please).
The Symply had a little hook onto which one could hang a bag by your feet. When you hung a bag in the footwell though you had to swing your leg over the seat to get onto the scooter. Although, I guess, this kept me supple it was a bit of a drag and a couple of times the hooks on my boot nipped a tear in the seat which was very annoying. With the big luggage compartment on the Burgman this problem does not arise.
I have only filled up the tank twice so I haven't worked out the fuel consumption yet, but the fuel tank on the Burgman is at least double the size of the Symply's. I did at least 120 miles after the first fill-up and the tank wasn't empty yet.
So both thumbs up for the Burgman!
![]() |
The Suzuki Burgman UH200 |
![]() |
The Sym Symply 125 when it was new. |
Monday, 18 July 2011
Lack-of-service-BT continues ...
So, about 3 weeks ago someone from BT calls me and offers to put me through to their disputes team. Being in the middle of the day on a Friday while I'm in the lab, I couldn't take the call, so I was told to call back and ask for disputes. Today, after about 3 weeks it was the first time I was home during the day so that I could make the call. As usual I had to venture through an endless maze of menu options before someone answered the phone. Between being put on hold and arguing the fact that I actually want to talk to disputes and not pay extra to get out of a contract that was mis-sold to me, I was cut off after 19 minutes and 55 seconds. Then the first amazing thing happened. I was called back within seconds and offered an apology for being cut off. I was then transfered to someone whom I believe must be in disputes. I had to explain the whole static IP address again and was then transferred to someone to me that they just have to tell me that they are going to investigate the issue and have to inform me that they will be retrieving and listening to the original calls. Amazing! This is what I've been wanting from the beginning. So, hopefully in the next 5 working days I'll hear from them and get this resolved.
Subscribe to:
Posts (Atom)