Friday, October 14, 2011

Enabling proxy under Debian



In order to enabled a proxy, there's two main places (at least for my use this did the trick, there's probably are others). The first one is simple defining the following variables:
export http_proxy="http://your.proxy.com:your_port"
export ftp_proxy="http://your.proxy.com:your_port"

Secondly in order to have apt-get work through proxy, you need to update /etc/apt/apt.conf.d/proxy (or create it):
Acquire::http::Proxy "http:///your.proxy.com:your_port";



VirtualBox: Creating new VM by duplicating existing one

The other day i tried to create a new VM by duplicating an existing one. Everything worked perfectly ... except all network interface were disable. And it was impossible to mount up those network interfaces.

If you duplicated a new VM from an existing one, you have to do a couple of things. First MAC addresses should be changed in new VM.

Then once the VM is created, disabled all network interface and boot it up. Once the machine is started, there's a couple of files to update for the hostname. I'm using a Debian squeeze, so path may change in other distributions:

/etc/hosts 
/etc/hostname

Then you need to need to edit  /etc/udev/rules.d/.  What happens is it maps the "new" mac address to a new interface. You just need to remove the old one and rename the new one (thanks to the solution from this forum: https://forums.virtualbox.org/viewtopic.php?t=7749)







Thursday, June 9, 2011

Using Eclipse as your R IDE


There's a bunch of possible IDE which are R specific, amongst which to name a few:
  • RKWard
  • R Studio (my personal favorite)
  • Rattle
  • ...
There's a very long list each with their own pros and cons, which I  don't intend to discuss in this post.

What i do want to discuss is the usage of Eclipse as a R IDE. Why use it compared to other. Well being a developer during the day, I rather like the idea of using the same tool at night so to speak. Another added bonus on top of syntax completion, object inspection, is the integration with an which ever SCM you like to use. For me that's the icing on the cake. Time being of the essence I don't want to look anything and relying on a SCM is a perfect way to do that.

Now enough talk. In order to have that integration working you need a couple of things:
  • StatET: that's the eclipse plugin (see here)
  • rj : that's the "other side of StatET (see here)
  • rJava: that's a java binder with R (see here)

Then follow the excellent step by step guide here on how to setup Eclipse itself in order to work with R.

Enjoy

Monday, May 23, 2011

Mercurial integration with SVN.

I've recently been evaluating integration of SVN with some other distributed source control systems, mainly Git and Mercurial. The idea is to have a distributed source control system that would integrate seamlessly with a central SVN repository (very slow and painfull access over internet). That allows a certain number of things, amongst which there is fast access to commit history, cheap branches to experiment...

At some point I had both Mercurial and Git installed, and decided it was time to do a bit of cleanup. I have a bias towards Mercurial because it has a better integration in Windows explorer through TortoiseHG (you can call that lazyness).

After uninstalling everything I started clean, installed the latest TortoiseHG version (which btw has a very nice GUI), as well as hgsubversion as explained here: Getting started with HGSubversion


Mercurial was working fine but I was running into the following error each time I tried to clone our repo:

hg clone svn+ssh://myuser@myrepo.com/someotherpath
destination directory: someotherpath
abort: Can't create tunnel: The system cannot find the file specified.

That error message has been driving me nuts for a while, and after trying a lot of things (uninstalling everything, installing Git again, checking library versions ...), I stumbled upon the solution :

set SVN_SSH="C:\\Program Files\\PuTTY\\plink.exe"


As simple as that... Just define that variable SVN_SSH and it worked flowlessly. After that I justed defined it in my user environment to make it persist.

Hopefully this will help someone else.

Saturday, May 7, 2011

K-means clustering using R

I'm trying to learn R, and I'm a firm believer that there's not better way to learn than by getting your hands dirty. After reading an excellent post on Intelligent Trading blog, it got me thinking how you would do a clustering analysis with R, using K-means.

In the rest of this post I will try to detail the different steps that I followed, in hope that it can be useful to others. In this post I will be using a couple of R packages, namely quantmod, fpc and a few others. The most crucial is quantmod. You can install it with:



They are used for:

  • quantmod: this is your bread and butter to ease time series analysis
  • graphics, scatterplot3d, gplots RColorBrewer are used for plotting
  • fpc: this packages is package dedicated to clustering 


First this article supposes that you already have your data handy in a xts object used by quantmot. If it's not the case have a look at this article.

In the details below, "x" is the name of the object that contains my timeserie. Now let dig into it.

The first thing you need to do is create matrix with the different criteria you want to use for the clustering. In my case I'm going to use three normalized ratios, Close / Open, High / Open,  Low / Open , and then stuff them into a matrix. Then you want to process the actual cluster and display it:



The result looks like:
This works pretty well, except you have to specify a number of cluster you're looking for. Another may to do this is through the pamk function from the fpc package, for for which you don't specify the actual number of cluster, it will be calculated (you provide a range of value though):

Note the difference with kmeans method, the cluster information is packed into a pam object. That why you access the cluster details through zpamk$pamobject.

Enjoy.