Tuesday, November 24, 2009

a simple speed comparison of GSL and Rmath C libraries

Just use the functions in both libraries to generate normal random samples. 
It turns out that Rmath is faster for this simple computing.

build R on ubuntu

Both packages 'libxt-dev' and 'libx11-dev' or one of them are needed before building.

# apt-get insall libxt-dev libx11-dev
# configure
# make

Rmath example

The following is an example of code using stand alone R math library
and the compilation command.

 *  C CODE

#include <Rmath.h>
#include <stdio.h>
#include <stdlib.h>

int main(){
  int i;
  unsigned int SEED1, SEED2;
  double mu, sigma, PHI_X, *X;

  mu = 0;
  sigma = 1;
  SEED1 = 12345;
  SEED2 = 67890;
  set_seed(SEED1, SEED2);

  X = (double *) malloc(10 * sizeof(double));
  for(i = 0; i < 10; i++){
    X[i] = rnorm(mu, sigma);
    PHI_X = pnorm(X[i], mu, sigma, 1, 0);
    printf("X: %f, PHI(X): %f\n", X[i], PHI_X);

 * COMPILATION:  gcc -I/Users/local/lib64/R/include -L/Users/local/lib64 -lRmath -lm tmp2.c

Thursday, November 19, 2009

tsc quit full screen on ubuntu

Re: How to exit Terminal Services fullscreen??

exit the full screen mode with Ctrl-Alt-Enter
annd close the window

Wednesday, November 18, 2009

ubuntu restart network (eth0 dhcp)

restart networking

/etc/init.d/networking restart


# The primary network interface
auto eth0
iface eth0 inet dhcp

root@jqt-laptop:/etc/network# ls
if-down.d if-post-down.d if-pre-up.d if-up.d interfaces interfaces.bak-0

Tuesday, November 10, 2009

latex eps automatically converted to pdf

Copied from http://robjhyndman.com/researchtips/converting-eps-to-pdf/