Cutting Edge

July 28, 2006

今天真的很煩,我不知道自己為如何此手癢。

我升到Edgy,果然是Cutting edge, 有夠利,弄得我快中風了,拜托各位contributor們,請確定你的package沒問題再丢上來,好嗎?

Advertisements

July 24, 2006

I have tried convert the Java code of Gardening to C++ in the “simple factory method” chapter of 閻宏’s Java與模式理論, the following is what I have done. This told me why C++ is so “awesome”.
Garden.hxx:

#include <iostream>
#include <string>
#include <map>
#include <cmath>
#include <exception>
 
class Fruit {

public:

  void grow() { std::cout << "Something growed" << std::endl; }

  void harvest() { std::cout << "Something harvested" << std::endl; }

  void plant() { std::cout << "Something planted" << std::endl; }
};


class Apple : public Fruit {

public:

  Apple() { std::cout << "Now you have an apple." << std::endl; }

  void grow() { std::cout << "Apple is growing" << std::endl; }

  void harvest() {std::cout << "You have apples now" << std::endl; }

  void plant() {std::cout << "Apples are planted" << std::endl; }

  int getFreeAge() { return age; }

private:

  int age;
};

class Grape : public Fruit {

public:

  Grape() { std::cout << "Now you have a grape." << std::endl; }

  void grow() { std::cout << "Grape is growing" << std::endl; }

  void harvest() { std::cout << "You have Grape now" << std::endl; }

  void plant() { std::cout << "Grape are planted" << std::endl; }

private:

  bool seedLess;
};


class Strawberry : public Fruit {

public:

  Strawberry() { std::cout << "Now you have a strawberry." << std::endl; }

  void grow() { std::cout << "Strawberry is growing" << std::endl; }

  void harvest() { std::cout << "You have strawberry now" << std::endl; }

  void plant() { std::cout << "Strawberry are planted" << std::endl; }
};

 
class FruitGardener {

public:

  FruitGardener() {}

  Fruit* factory(std::string which) {
   
    Fruit* fruit = new Fruit();

    if (which == "Apple") {
     
      Apple* apple = new Apple();
     
      fruit = apple;
   
    } else if (which == "Grape") {

      Grape* grape = new Grape();

      fruit = grape;

    } else if (which == "Strawberry") {

      Strawberry* strawberry = new Strawberry();

      fruit = strawberry;

    } else {
     
      throw std::bad_exception();
    }

    return(fruit);
  }
};

Garden.cxx:
#include "Garden.hxx"

int main(int argc, char **argv) {

  FruitGardener* gardener = new FruitGardener();

  int i = 0;

  while (i factory("Apple");

      gardener->factory("Grape");
     
      gardener->factory("Strawberry");

      gardener->factory("Moon");

    } catch (std::bad_exception& be) {

      std::cerr << "Error!" << std::endl;
    }
   
    i++;
  }
 
  delete(gardener);

  return 0;
}

Central limit theroem

July 16, 2006

I found a quite interesting result attained with R that

A <- rmvnorm(1, as.vector(rep(0,10)), diag(10))
for ( i in 1:1000) 
{ 
  A <- rmvnorm(1, as.vector(rep(0,10))
  t(A)%*%A; print(A)
}

finally, A becomes zero vector, that is , the coviance of A becomes zero matrix.
There’re some theorems about this, keep trying.

I have tried several ” as-complex-as-possible Hello World” Programming last night, the most strange one is the following:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gtk/gtk.h>


void gtk_hello(int argc, char **argv) {

  gtk_init (&argc, &argv);

  GtkWidget *window;

  GtkWidget *button;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  button = gtk_button_new_with_label ("Hello World!\n");

  g_signal_connect (G_OBJECT (button), "clicked",
            G_CALLBACK (gtk_main_quit), NULL);

  g_signal_connect_swapped (G_OBJECT (button), "clicked",
                G_CALLBACK (gtk_widget_destroy),
                G_OBJECT (window));

  gtk_container_add (GTK_CONTAINER(window), button);

  gtk_widget_show (button);

  gtk_widget_show(window);

  gtk_main();

}
 


int main (int argc, char **argv) {

  char yesorno;

  gtk_hello (argc, argv);

  printf ("Do you real want to quit? ");

  scanf ("%c", &yesorno);

  while (yesorno != 'y') {
   
    if (yesorno == 'n') {
     
      gtk_hello(argc, argv);

      printf ("%c", yesorno);
     
      printf ("Do you real want to quit? ");

      scanf ("%c", &yesorno);

      if (yesorno == 'y') break;
   
    } else {
   
      printf ("please answer \"y\" or \"n\". ");
     
      scanf ("%c", &yesorno);
   
    }
  }

  printf ("Goodbye!\n");

  return 0;

}

I have no idea about the output:

Do you real want to quit? please answer "y" or "n". y


the part of else control block is always executed.

Today, a wonderful talk given by Jserv, told me the complex underlaying framework on the GNU/Linux platform. It is quite amazing, I never think of that before.

Mr. Jserv is a greart engineer that contrib his own vacation devoting to the Open/Free Software community, his talk helps me a lot for numerical progamming for the staitsitical computing.

Thank you, Mr. Jserv!

I spend 2 hours to read this paper tonight , which is an application of Prof. Pourahmadi’s 1999 joint modelling idea with penalized MLE.

This article is quite interesting that the authors provided several kinds covariance matrix strustrure for benchmarking the performance of this method and Two penality
L1 and L2 for comparison.

語音辨識

July 13, 2006

今天在試一些語音辨識軟體的時候,突然想起了我的高中同學邵一凡,在那網路還是算很稀罕的年代裡,我曾在他家中測試了一些網路電話,那真的是很新鮮的經驗,雖然品質差強人意,每次通話總是在狂吼中結束,不過,那還是一個很美好的經驗。

同學們,希望你們人人安好。

數學正進退兩難

This article described some problems that I have encountered. As a perspective to the PhD level studies of applied mathematics, I was troubled with that. I need some more wider vision to find the way for my academic career.

How to shutdown?

July 9, 2006

On M$’s product, You have to choose “Start” to shutdown your box
On GNOME, you have to choose “System”
On KDE , you have to choose the “wheel”
With a sucking window manager, you have yo click “ctl-alt-backspace” and a following command line “sudo halt”

Weather forecasting

This pedantic guy demostrate a fancy way of present — and very sucessful, this knew paradigm is quite attractive, statistical nerd should take this as new inspriation!