Monday, September 14, 2009

肯德基爺爺 in Google Street View @ Taipei

最近聽到一個好笑的消息,from HERE
Google街景在台北上路,為了個人隱私權,臉部辨識軟體會選出人臉後,模糊化處理,以保護個人隱私。
但是,肯德基爺爺也被當作一般人處理了,為了證實這件事情,我決定調查台北市內,所有的肯德基爺爺是不是真的被"糊掉"了!

KFC官網上面,地址在台北市的有,
  • 台北三越餐廳 台北市100中正區忠孝西路一段66號B1(新光三越百貨)
  • 在地下室,拍不到。
  • 台北漢口餐廳 台北市100中正區漢口街一段50號
  • 肯德基爺爺沒糊!
  • 台北承德餐廳 台北市103大同區承德路一段38號
  • 肯德基爺爺糊了!
  • 台北中山餐廳 台北市104中山區南京東路三段222號1-4樓
  • 肯德基爺爺糊了!
  • 台北中山北餐廳 台北市104中山區中山北路二段109號1-3樓
  • 這個角度有糊
  • 這個角度沒糊
  • 台北中崙餐廳 台北市104中山區八德路二段306號B1
  • 地下室看不到!
  • 大直愛買餐廳 台北市104中山區敬業三路123號1樓
  • 在賣場裡看不到!
  • 台北南京東餐廳 台北市105松山區南京東路五段82號
  • 糊了!
  • 台北八德餐廳 台北市105松山區松山區八德路四段721號
  • 糊了!
  • 台北仁愛餐廳 台北市106大安區仁愛路四段418號
  • 這個角度糊了!
  • 這個角度沒糊!
  • 台北台大餐廳 台北市106大安區新生南路三段96-1號
  • 小的糊了!
  • 大的沒糊!
  • 台北成都餐廳 台北市108萬華區成都路87號
  • 肯德基爺爺糊了!
  • 台北峨嵋餐廳 台北市108萬華區峨嵋街14-16號2樓
  • 肯德基爺爺沒糊!
  • 台北信義(二)餐廳 台北市110信義區市府路45號B1(台北101大樓)
  • 地下室看不到!
  • 台北士林餐廳 台北市111士林區文林路88號
  • 小的糊了,大的沒糊!
  • 台北天母餐廳 台北市111士林區天母東路6-4號1樓
  • 沒提供Google Street View
  • 北投光明餐廳 台北市112北投區泉源路3之1號
  • 沒糊!
  • 台北內湖餐廳 台北市114內湖區內湖路一段230號
  • 有些有糊,有些沒糊!
  • 台北東湖二餐廳 台北市114內湖區東湖路122-124號
  • 糊了!
  • 台北興隆餐廳 台北市116文山區興隆路三段114號
  • 小的糊了!大的沒糊!
統計結果,總共有20間。
  • 看不到的有5間。
  • 糊了,12間。
  • 沒糊,3間。
另外針對有些有糊,有些沒糊,有兩點推論,
  • 肯德基爺爺所在的高度:太高,人不太可能出現的高度,不會被模糊!
  • 肯德基爺爺臉的大小:太大也不會!
不過都只是推論^^
蠻好玩的,不過好累XD

Sunday, August 30, 2009

免費掃毒軟體

Avast Antivirus
Avira AntiAir
Panda Cloud Antivirus
AVG Free Antivirus
ClamWin Free Antivirus Opensource
至於以上產品的爭測速度,就不野人獻曝了,我不夠專業去比較這些。
網路上有很多類似的比較文章,例如下列,注意更新時間,自行參酌。
如果以Google trends來看看這四個產品,
世界的話,AVG最高,Avast次之,Avira第三。
台灣的話,Avast和AVG伯仲之間,Avast比較高些,Avira仍是第三,
可是我身邊的人比較多人用Avira。

Saturday, August 29, 2009

Asus PL-X31電力網路實測和配置

PLC Power Line Communicattion,電力線通訊自從開始有商業化產品後,我就一直再注意了。
因為一定會有速度更快的,價錢更理想的產品推陳出新,終於200M的出來了。
產考了價錢和許多網友的分享文,
我決定買Asus的PL-X31。
官方介紹

我買了三台PL-X31,分別放在三個房間,我的臥室,客廳,和書房(娛樂間)。
網路來源就透過ADSL modem,再加上一台比較強效的無線路由器,來分配網路位址。
我申請的是一個實體IP加上七個虛擬IP的ADSL網路服務。
客廳需要網路的原因是因為想利用一台一公升電腦當作娛樂中心,透過此電腦可以在電視上欣賞影片,MOD(高畫質電視節目)也可以使用。
另外的好處就是電視遊樂器也可以很方便在客廳連接上網路。(特別是Xbox360和未來會加入的PS3 Slim)
書房是家庭成員使用電腦的地方,所以一定要提供網路。
如果沒有PLC,光是佈線就非常頭大!
那使用者最在乎的速度呢?實測後,PL-X31真的提供了很不錯的效果!應該說200M規格以上的,應該都符合大多人的需求了。

以下是粗糙的連線速率結果,只測一次,沒有做多次取平均,不過基本上都差不多。

在書房的PC,連線速度是8.5Mpbs。

在書房的NB,連線速度是9.7Mpbs

在客廳的一公升電腦,連線速度是8.4Mpbs。

在書房的另一台一公升電腦,連線速度是9.4Mpbs
在臥房的PC,沒透過PLC的連線速度,9.7Mpbs。

在臥房連線臥房內的無線路由器,連線速度是8.9Mpbs。
在臥房連線客廳的無線路由器,連線速度是6.7Mpbs。
沒透過PLC速度是9.7Mbps。
有透過PLC速度分別是8.5Mbps, 9.7Mbps, 8.4Mbps。
無線的速度分別是8.9Mbps, 6.7Mbps。
由此可見,透過PLC甚至跑出沒透過PLC一樣的速度,雖然僅供參考,但是已經表示原本有限網路的100M,已經和PLC 200M有並駕齊驅的表現了。

看似無線效果也不錯,但是其實這是最好的狀況,我也沒特定去找死角來測,有些房間要收到無線訊號其實不是很容易。

我應該會把客廳的無線AP拿到書房去,這樣起碼可以將整個家以無線網路涵蓋起來,另外要使用有線網路的話,有三個地方可以提供,有需要的話,再添購PLC即可。
總之,PLC真是好物啊!

Thursday, August 6, 2009

快來產生自己的Quick Response Code吧!

http://qrcode.kaywa.com/

Quick Response Code 簡稱QR Code,
就像本部落格右側方塊中的一個黑白方塊的圖片,
可參考Wiki的說明,
http://zh.wikipedia.org/wiki/QR%E7%A2%BC

實用性也大於傳統的條碼,因此在日本超級流行,台灣雖然還是少數使用,不過以台灣一向愛學習日本的特性,也有可能會慢慢流行也說不定,只要RFID沒那麼塊普及的話XD

PS: 不過RFID市場大很多,搞不好會跳過QR code也說不定。

Thursday, July 30, 2009

1-of-K representation

Reference from Machine Learning and Pattern Recognition, Bishop

Section 2.2 P.74
A particularly convenient representation is the 1-of-K scheme in which the variable is represented by a K-dimensional vector x in which one of the elements xk equals 1, and all remaining elements equal 0.

Keyword: 1-of-K, representation

Tuesday, July 21, 2009

Generative model and Discriminative model


簡單的名詞解釋上的區別是
discriminative model 估計的是條件概率分布(conditional distribution, posterior class probabilities)
p(class|observed x)
generative model 估計的是聯合機率分布(joint probability distribution)
p(observed x, class),之所以稱為Generative model,就是因為根據Joint probabilities,利用各種sampling方法,就可以產生人工資料(Synthetic data)。

Christoper M. Bishop, Pattern Recognition and Machine Learning Section 1.5.4, p.43有提到這兩者的區別。在這裡作者Bishop也點出了第三種學習方法,discriminative function.
Sampling方法,可在此書的第11章找到各式方法。

在目前的研究上,
有學者研究綜合兩者的優點的Hybrid方法,
  • Hybrid Generative-Discriminative Models for Speech and Speaker Recognition (2002)
  • Multi-Conditional Learning: Generative/Discriminative Training for Clustering and Classfication(2006)
  • Bias-Variance tradeoff in Hybrid Generative-Discriminative models(2007)
  • A hybrid generative/discriminative approach to text classification with additional information(2007)
  • A mixed generative-discriminative framework for pedestrian classification(2008)
  • Combining Evidence from a Generative and a Discriminative Model in Phoneme Recognition(2008)
也有學者提出透過Discriminative model去學習generative model.
  • Learning Generative Models via Discriminative Approaches(2007)
兩者的比較
  • Generative versus discriminative methods for object recognition(2005)

Monday, July 20, 2009

好用免費軟體 - 7zip

7zip免費且支援很多壓縮格式,缺點是介面不太漂亮,也沒辦法double click打開壓縮檔。

教學網站

Sunday, July 19, 2009

Memo: how to type doubledash "--" and underline "_" in LaTex?

How to type double dash in LaTex?
Sometimes we need to type "--" in LaTex, but the parser of Tex will deal with it into one dash.
If you try "- -" a space in two dash, it is not the same with "--".

So you can try
  • \texttt{ }: I think it is good but the format and size of character should be customized.
  • -{}-: Excellent. Nature!
Reference from

Underline is reserved character of LaTex
The reserved characters are
  • $ : dollar sign
  • & :
  • %
  • #
  • _
  • {
  • }
  • ~
  • ^
  • \
If you want to type them, just add a "\" before them.

Wednesday, May 20, 2009

Memo: How to put a character below or under a word?

http://www.gamedev.net/community/forums/topic.asp?topic_id=436284

Use \underset and \overset

%
\begin{equation}\label{Eq:formula3}
    \hat{P} = \underset{P}{\text{argmin}}\{F(P)\},
\end{equation}
%

You will get

Tuesday, May 19, 2009

Memo to use matplotlib.legend

Assume the legend example is like this
  • fig1.legend(E_on, ejection, loc = 7)
E_on is figure vector, ejection is string vector, loc is the location of legend.

You can use append to construct E_on and ejection
  • E_on.append(fig1_on.plot(x[k][j], y[k][j]))
Then you will get a very good legend figure like this.

Memo to use matplotlib.use( )

Just remind myself to use matplotlib.use( ).

If you claim the matplotlib.use( ) to save figure in a given format, just need to define it in your main python file.
Otherwise, you will get a error message about this function.

Thursday, May 14, 2009

Wednesday, May 13, 2009

Conflict problem between IntelProSet and Hcontrol

I have a problem on my laptop (W5g00AE) disrupting me for a long time and it is getting more and more serious.
It's a software conflict problem between IntelProSet Apps and Asus ATK100, actually the problem is hcontrol.
The condition is unstable, sometimes is good, other is not. And it also effect the TKIP protocol to access wireless probably.

ATK100 is included a software called hcontrol which manage the function keys, audio switch, wireless/bluetooth switch, etc.

You can download the lastest version of ATK100 in Asus download service webpage,
Category is Notebook->W5000 Series->W5AE (W5g00AE)->Others

Somone provided a good solution in Chinese.
After all, you can use new driver (9.0.4.17, my old driver version is 9.0.19) with old IntelProSet application.
Don't execute the installer from Asus webstie. Just update your driver by hardware manager. It's much safer.

But I got a problem with conflict on family code of IntelProSet apps, and I cannot use Apps in old version. I think there is a process to check version of driver and version of apps. 
Hope you are more lucky than me. I uninstall the IntelProSet and use the lastest wireless driver now. Of course, hcontrol is working fine now.
Something happened after I reinstall drivers and apps. I can install apps in old version now.
And then I have 2 solutions now.
  • Update driver only and use old veriosn apps
  • Use the lastes apps and driver from IntelProSet
I tried another solution. Direct download from website from IntelProSet,
The driver of wireless is updated to 9.0.4.39 and the apps is still conflicting with hcontrol.

So I copy the lastest driver folder in Program Files/Intel/Wifi/, uninstall all lastest apps and install old apps.

So far, it's stable now. I use the latest driver, 9.0.4.39 without IntelProSet and hcontrol is working.

Thursday, May 7, 2009

Note: matlpotlib - A problem of using set_xlim

There are the same problem of using set_xlim in matplotlib with using legend.

So plotting all data first before customize your figures is much better.

Wednesday, May 6, 2009

Note: matlpotlib - A problem of using legend

http://www.scipy.org/Cookbook/Matplotlib/Legend

legend cannot use before you plot data in figure.
You have to plot, bar, or use any figure command to put data into the target figure object.
And then use legend to label your data.

How to Locate the legend label?
Assign a vaule to "loc=". There are three kinds of assignment.
  1. location string: 'best' or 'upper right'
  2. location code: 0, 1, 2...
  3. (x, y) = x is the percentage from bottom, y is the percentage from left.
For example,
’best’ : 0, (only implemented for axis legends)
’upper right’ : 1,
’upper left’ : 2,
’lower left’ : 3,
’lower right’ : 4,
’right’ : 5,
’center left’ : 6,
’center right’ : 7,
’lower center’ : 8,
’upper center’ : 9,
’center’ : 10,

Wednesday, April 29, 2009

Use append to construct 2-dimension array

How to use array.append to construct or build 2-dimension array?

Here we go! Do it lie following step!
===============================
#create two-dimensional array
arr = []
for line in startfile.readlines():
    littlearr = []
    for letter in line.strip():
        littlearr.append(letter)
    arr.append(littlearr)
===============================

Matplotlib - how to define a size of figure

Users can manually setup the figure size by the 4 attributes when using matplotlib,
Left, Bottom, Width, Height.
This is a example to help users understand how to setup the variables.

Width and Height are easier to image.
They means the width and height of a figure.
Left means the figure(the figure is not including the axes and label) start from left.
Left is 0. You will see the figure is sticked on the left boundary.
Bottom means the figure start from the bottom.
Bottom is 0. You will see the figure is sticked on the bottom line.

Let's see the example figures.

Let's see the different one. You should understand how to control it.
All values of 4 variable is 0~1. Good luck and have fun!


Wednesday, April 8, 2009

Tuesday, April 7, 2009

Boot loader on Ubuntu

How to change the boot sequence if you have multi-OS on your PC?

  1. Open Synaptic Package Manager
  2. Search kgrubeditor, kg is enough. You will see kgrubeditor in your search result.
  3. Install it, then you can modify the default OS.

Or
  1. Open your terminal
  2. Type $ sudo apt-get install kgrubeditor
Or
  1. Open your terminal
  2. Type $ sudo gedit /boot/grub/menu.list
http://www.kde-apps.org/content/show.php?content=75442

Friday, April 3, 2009

LMA on Python

Python, actually Scipy, provides the Levenberg-Marquardt algortihm for solving least-square problem. It's called leastq in scipy.optimize package. There are a lot's optimization algorithms.
http://docs.scipy.org/doc/scipy/reference/optimize.html

Basically, It was coded by fortran. http://www.netlib.org/minpack/
You can download the test code for fortran version form http://www1.fpl.fs.fed.us/minpack.ls.test.html

You can use it directly by calling "scipy.optimize.leastsq" after including "from scipy.optimize import leastsq"

These are good simple examples.


Reminder:
Be careful the arrary usage of input data x and y.

Memo to use Python: optparse

Reference:

This is an simple example of optparse, a command line parser in Python.
You can copy it and modify it free.

# Loading command line parser, this is better.
import optparse
# Loading basic libraries
import sys

# This is command line parser setting
usage = "Usage: #pprog [options] arg"
parser = optparse.OptionParser(usage)
# You can add the options in the following format
parser.add_option('-o', '--output', 
                  dest="output_filename", 
                  default="default.out",
  help="Given a output",
                  )
parser.add_option('-i', '--input',
                  dest="input_filename",
                  default="default.in",
  help="Given a input",
                  )
parser.add_option('-v', '--version',
                  dest="version",
                  default=1.0,
                  type="float",
  help="Show the version",
                  )
parser.add_option('-d', '--debug',
                  dest="debug",
                  default=False,
                  action="store_true",
  help="Debug mode, all information will be printed in debug.out",
                  )  
parser.add_option('-g', '--graphic',
                  dest="graphic",
                  default=False,
                  action="store_true",
  help="Graphic mode, print the result in graphic",
                  )   
options, remainder = parser.parse_args()

# This is main function
# if no option print help()
if len(sys.argv) == 1:
parser.print_help()
# if we have more than one option, print option table
if len(sys.argv) > 1:
print 'ARGV      :', sys.argv[1:]
print 'VERSION   :', options.version
print 'INPUT     :', options.input_filename
print 'OUTPUT    :', options.output_filename
print 'DEBUG     :', options.debug
print 'GRAPHIC   :', options.graphic
# Then you can use the options to setting your variables and parameters

Reminder #1
if you use the function, "defualt", on your options.debug, you won't get the options.debug == None, because options.debug will have a defualt.
So you are impossible to use if statements to get options.debug == None.
If you need the if statements to check options.debug == None, you have to remove the function, options.default.

遺失HAL.dll檔

如果電腦開機後,出現此訊息,
Windows 無法啟動,因為下列檔案遺失或損毀:
Windows\System32\Hal.dll

修復方法有
1. 就想辦法複製一份Hal.dll進去,有曾經修復過,不過我覺得不是正確作法,而且有時候此檔案還在,你可以嘗試複製新的進去,舊的先保留起來。如果還是不能啟動WINXP,就嘗試2。
2. 原版光碟開機,啟動修復管理員,輸入 copy hal.dll C:\Windows\system32\hal.dll。也是要注意如果舊的hal.dll還在,最好先改名稱,備份起來。
3. 若發生原因是如果 Boot.ini 檔遺失、損壞或包含不正確的項目,則可能發生此問題。就用拿原版XP光碟啟動,修復Boot.ini囉!

如果要解決此問題,請從 Windows XP CD 啟動電腦,並啟動「修復主控台」,然後使用 Bootcfg.exe 工具重建 Boot.ini 檔案。如果要執行這項操作,請依照下列步驟執行:

  1. 將電腦設定為從 CD-ROM 光碟機或 DVD-ROM 光碟機啟動。如需有關如何執行這項操作的資訊,請參閱電腦的說明文件,或與您的電腦製造商連絡。
  2. 將 Windows XP 光碟插入 CD-ROM 光碟機或 DVD-ROM 光碟機中,然後重新啟動電腦。
  3. 當您看到 Press any key to boot from CD (請按任意鍵從光碟開機) 訊息時,請按任意鍵,以從 Windows XP 光碟啟動電腦。
  4. 當您看見 Welcome to Setup (歡迎使用安裝程式) 訊息時,請按 R 以啟動「修復主控台」。
  5. 如果您使用雙開機方式或多開機方式的電腦,請從「修復主控台」選取您所必須使用的安裝。
  6. 當系統提示您時,請輸入系統管理員密碼,然後按 ENTER。
  7. 在命令提示處輸入 bootcfg /list(中間有一個空格),再按 ENTER。畫面上會顯示目前 Boot.ini 檔中的項目。 如果顯示沒有檔案,就表示windows真的找不到Boot.ini或是Boot.ini損壞。
  8. 在命令提示處輸入 bootcfg /rebuildt(中間有一個空格),再按 ENTER。此命令會在電腦的硬碟上進行 Windows XP、Microsoft Windows 2000 或 Microsoft Windows NT 安裝的掃描,然後顯示掃描的結果。請依照畫面上的指示將 Windows 安裝程式新增到 Boot.ini 檔案中。

例如,依照這些步驟將 Windows XP 安裝程式新增到 Boot.ini 檔案中:

a. 當您收到類似下列的訊息時,按下 Y:
Total identified Windows installs: (識別的 Windows 安裝總數:)1

[1] C:\Windows
Add installation to boot list? (新增安裝程式到開機清單?)(Yes/No/All) (是/否/全部)


b. 您會收到類似下列的訊息:
Enter Load Identifier (輸入載入識別碼)
此為作業系統的名稱。當您收到這項訊息時,請輸入作業系統的名稱,然後按 ENTER。

  • 此為 Microsoft Windows XP Professional (商用版)
  • 或 Microsoft Windows XP Home Edition (家用版)。

c. 您會收到類似下列的訊息:
Enter OS Load options (輸入 OS 載入選項)
當您收到這項訊息時,請輸入 /fastdetect,然後按 ENTER。


參考
http://60.248.128.85/bbs/dispbbs.asp?boardID=67&ID=18584&page=1
http://blog.yam.com/ajuang/article/1272723
http://tw.myblog.yahoo.com/minicaesar/article?mid=119
http://tw.myblog.yahoo.com/ceyi-udwebs/article?mid=55&prev=-1&next=54
因為我的電腦原本有Ubuntu,所以開機後變成有兩個XP,一個 Ubuntu,反正不管了,以後有時間再處理。

Boot.ini錯誤的原因,應該是因為我用ubuntu玩Gparted的後遺症,不能說Gparted不好,因為我的C槽剩太少空間,重整也沒辦法把檔案整理乾淨,所以可能會使Gparted運作不良吧?或許,我亂猜的。
這次,是用bootcfg /rebuild救回來的。


Windows XP修復主控台的指令請參考如下:
Attrib 變更檔案或目錄的屬性。
Batch 執行文字檔中指定的指令。
Bootcfg開機檔案 (boot.ini) 設定及修復。
Chdir (Cd) 顯示目前目錄的名稱,或變更目前的目錄。
Chkdsk 檢查磁碟並顯示狀態報告。
Cls 清除螢幕。
Copy 將單一檔案複製到其他位置。
Delete (Del) 刪除一個或多個檔案。
Dir 顯示目 ..

參考
http://bbs-mychat.com/reads.php?fsz=b&fid=351&tid=202736&page=e

Wednesday, April 1, 2009

Windows的C槽容量不夠怎麼辦?

The C partition is not enough! How to increase the volume of C???
這個標題應該會是很多人會遇到的問題,不過我想高手都知道怎麼解,純粹寫給自己方便用。

有個軟體是大家比較熟知的,PartitionMagic,不過這要錢,網路上破解的又大多有木馬。

所以我是使用Gparted,Gnome上的免費工具,前提是你要有空間裝Ubuntu,然後使用Gparted來重新調整C槽的大小,例如把D槽縮小,多出來的空間給C槽。
You can use a software, Gparted, free tool of Gnome. First of all, you have to install Ubuntu, you can try Wubi, a windows installer of Ubuntu. It is easy as other installers on windows. 

官方教學已經很清楚了,http://wiki.ubuntu-tw.org/index.php?title=GParted
BTW, I can't find a good instruction in English. Please ask it to Uncle Google. :P

Step1. 安裝Ubuntu,也可以考慮安裝Wubi,http://wubi-installer.org/,就像安裝Windows軟體一樣方便。
  • Install Ubuntu or Wubi

Step2. 重新開機,選擇Ubuntu啟動,進入後,安裝Gparted和ntfsprogs,指令是
  • Reboot, choose Ubuntu and install Gparted and ntfsprogs
  • $ sudo apt-get update
  • $ sudo apt-get install gparted ntfsprogs
Step3.  啟動Gparted後,按照官方教學操作即可。
  • Execute Gparted. Before repartition, please backup your important files and scan and defrage your partition first.

Wednesday, March 25, 2009

mkoctfile Standalone Programs of C/C++

Original article is from
http://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html#Standalone-Programs

If you just cope the code from the webpage. You will have a compiler error.
============================================
$ mkoctfile --link-stand-alone main.cc -o main
main.cc: In function 'int main()':
main.cc:13: error: 'row' was not declared in this scope
main.cc:13: error: 'column' was not declared in this scope
============================================

Modify row and column to i and j,
============================================
 #include
     #include
     int
     main (void)
     {
       std::cout << "Hello Octave world!\n";
       int n = 2;
       Matrix a_matrix = Matrix (n, n);
       for (octave_idx_type i = 0; i <>
         {
           for (octave_idx_type j = 0; j <>
             {
               a_matrix(i,j) = (i+1)*10 + (j+1);
             }
         }
       std::cout <<>
       return 0;
     }
============================================

Then you should get the result,
============================================
$ mkoctfile --link-stand-alone hello.cc -o hello
     $ ./hello
     Hello Octave world!
       11 12
       21 22
     $
============================================
If you have problem to use mkoctfile on Cygwin, you can refer to HERE.

十二星座的時間劃分





星座     日期(公曆)    英文名 
魔羯座 (12/22 - 01/19) Capricorn 
水瓶座 (01/20 - 02/18) Aquarius 
雙鱼座 (02/19 - 03/20) Pisces 
牡羊座 (03/21 - 04/20) Aries 
金牛座 (04/21 - 05/20) Taurus 
雙子座 (05/21 - 06/21) Gemini 
巨蟹座 (06/22 - 07/22) Cancer 
獅子座 (07/23 - 08/22) Leo 
處女座 (08/23 - 09/22) Virgo 
天秤座 (09/23 - 10/22) Libra 
天蝎座 (10/23 - 11/21) Scorpio 
射手座 (11/22 - 12/21) Sagittarius
怎麼記?以終止時間為準,然後以20為單位,所以可改寫成
-1, -2, 0, 0, 0, 1, 2, 2, 2, 2, 1, 1
-1代表20-1,-2代表20-2,然後依序加上月份1,2,3,4,5, ..., 12。
所以就知道第一個星座是1/19結束,所以第二個星座開始是1/20,以此類推。

怎麼記星座順序?
就魔水魚,羊牛子,蟹獅女,秤蝎射。
希望可以一解我老是記不起來的困擾!

參考至

Tuesday, March 24, 2009

HTK in Ubuntu

Reference from http://www.voxforge.org/home/dev/acousticmodels/linux/create/htkjulius/tutorial/download/comments/additional-instructions-to-compile-htk-on-ubuntu-8-hardy

make sure you have gcc, make.
$ gcc -v
$ make -v

If you don't have make
$ sudo apt-get install make
If you don't have gcc
$ sudo apt-get install build-essential
You may need 
$ sudo apt-get install libx11-dev
if make all error

You should be get the right result.

Thursday, March 19, 2009

mkoctfile problem on Cygwin

I tired to use mkoctfile to compile hello.cc, the example of Octave and C/C++.

First, I got the error messages as follows,
==========================================================
$ mkoctfile hello.cc
/usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../../i686-pc-cygwin/bin/ld: cannot find -loctave
collect2: ld returned 1 exit status
==========================================================
I found the solution from
Rename libctave.dll.a to liboctave.dll.a.

Then,
=========================================================
$ mkoctfile hello.cc
/usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../../i686-pc-cygwin/bin/ld: cannot find -lreadline
collect2: ld returned 1 exit status
=========================================================
It seems to be I didn't have library readline.
I tried to install from Cygwin setup program,
libs/libreadline5 4.3-5 GNU readline and history libraries
libs/libreadline6 5.2.13-11 GNU readline and history libraries
But this doesn't solve my problem,
So I manually install the libraries,
Donwload packages,

And then, I got error messages as follows,
=========================================================
$ mkoctfile hello.cc
/usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../../i686-pc-cygwin/bin/ld: cannot find -lgfortranbegin
collect2: ld returned 1 exit status
=========================================================
Go to Cygwin official site to search fortranbegin.
Then I have to install the package, devel/gcc4-fortran: Fortran subpackage.

Finally, I solved my problem ^^

mkoctfile in Ubuntu

We need octave3.0-header first.
$ sudo apt-get install octave3.0-header

After the accomplishment of download and installation,
you can use mkoctfile now.

Do followin the steps.
You can compile hello.cc successfully and run it helloworld (1,2,3)

Install Ocatve on Ubuntu

Update your apt-get first. 
  1. $ sudo apt-get update
  2. $ sudo apt-get install octave
Miss the first step, you may not find octave package when type step 2 command.
After updating, then input command of step 2.
Then system will ask you to agree the download process and upgrade process.
Press "y" and wait.

If you meet a problem, like 
ldconfig deferred processing tkaing place
dpkg: status database area is locked by another process
Just running step 2 again.

At least, I install it successfully.

Thursday, March 12, 2009

Friday, March 6, 2009

Octave and C/C++

Reference for using Octave and C/C++
參考這幾個網站,

Please confirm that Dynamic Linking feature is ont or off.
先確認Octave是否有支援或是開啟Dynamic Linking,
Typing,
輸入
$ octave_config_info ("ENABLE_DYNAMIC_LINKING")
if
ans = true
That means ON.
表示有開啟。

因為Octave要用gcc compiler,所以勢必得換開發環境了。
至少我不知道怎麼用VisualCompiler去使用。

所以我改用Cygwin和Ubuntu,Cygwin因為我缺少了一些packages,所以花了點工夫。請參考HERE
Ubuntu只要安裝好Octave和Octave-header後,就OK了。請參考HERE1 and HERE2

程式要inlcude
然後告訴compile正確的octave library位置,但是通常都會用make來完成compile動作。下載範例Makefile
內容大致如前面連結提供的範例相同,
makefile:
all:test
clean:
-rm test.o test
test: test.o
mkoctfile --link-stand-alone -o test hello.o
test.o: hello.cpp
g++ -c -I /usr/include/octave-3.0.3/ -o hello.o hello.cpp
指令輸入make all,就會完成Makefile裡指定的動作了。

Wednesday, March 4, 2009

The method of solving least-squares problems

Linear least squares problems
  • Newton's Method
Non-Linear least squares problems
  • Gauss-Newton Method
  • Quasi-Newton Method
  • Gauss-Raphson Method
  • Levenberg-Marguardt Method
  • Powell's Dog Leg Method
  • Hybrid Method: L-M and Quasi-Newton
Good references:
  • 1999, Poul E. Frandsen, http://www2.imm.dtu.dk/documents/ftp/publlec/lec2_99.pdf
Descent method
Conjugate Gradient mehod
Newton-based method, included Quasi-Newton
  • 1999, Hans B. Nielsen: http://www2.imm.dtu.dk/documents/ftp/tr99/tr05_99.pdf
Descent method
Gauss-Newton method
Levenberg-Marquardt method
Powell's Dog Leg method
Hybrid: LMA+QN
Newton's Method, NM
Also called Newton-Raphson Method.  It uses the first few terms of the Taylor series (Taylor expansion) of a function  in the vicinity of a suspected root.  
  • http://mathworld.wolfram.com/NewtonsMethod.html
  • http://en.wikipedia.org/wiki/Newton's_method

Relationship between Newton's method, Halley method, and Householder's method.
  • Newton's method is 1st in the class of Householder's method.
  • Halley's method is 2nd in the class of Householder's method.
  • http://en.wikipedia.org/wiki/Householder's_method
  • http://en.wikipedia.org/wiki/Halley's_method

  • Levenberg-Marquardt Algorithm, LMA
  • http://en.wikipedia.org/wiki/Levenberg-Marquardt_algorithm
  • http://mathworld.wolfram.com/Levenberg-MarquardtMethod.html
  • http://homepages.inf.ed.ac.uk/cgi/rbf/CVONLINE/entries.pl?TAG49
  • Nov. 1996, Sam Roweis: http://www.cs.toronto.edu/~roweis/notes/lm.pdf
  • Good Introduction to talk about the LM from Newton's method, modefied by Levenberg, then modefied by Marquardt to become LM algorithm.
1999, Hans B. Nielsen: http://www2.imm.dtu.dk/documents/ftp/tr99/tr05_99.pdf
Apr. 2004, Hans B. Nielsen: http://www.imm.dtu.dk/pubdb/views/edoc_download.php/3215/pdf/imm3215.pdf
  • Above two articles are refered by LEVMAR.
June 2004, Ananth R.: http://www.cc.gatech.edu/~ananth/docs/lmtut.pdf
  • A good article also to talk about the LM from Newton's, Levenberg, and Marquardt to become LMA.
Feb. 2005, Manolis L.: http://www.ics.forth.gr/~lourakis/levmar/levmar.pdf
  • The article talking about source code LEVMAR. A pseudocode provided.
Nov. 2006, Pradit M.: http://cobweb.ecn.purdue.edu/~kak/courses-i-teach/ECE661.08/homework/HW5_LM_handout.pdf
  • Simple example and Matlab code provided.
http://www.cse.ucsd.edu/classes/fa04/cse252c/vrabaud1.pdf
  • Matlab code, thanks for Pradit Mittrapiyanuruk.

Gauss-Newton Method, GNM
  • http://en.wikipedia.org/wiki/Gauss-Newton_algorithm
  • http://reference.wolfram.com/mathematica/tutorial/UnconstrainedOptimizationGaussNewtonMethods.html
  • 1999, Hans B. Nielsen: http://www2.imm.dtu.dk/documents/ftp/tr99/tr05_99.pdf
Gauss-Raphson Method, GRM
Continue..
Quasi-Netwon Method, QNM
  • http://reference.wolfram.com/mathematica/tutorial/UnconstrainedOptimizationQuasiNewtonMethods.html
  • 1999, Poul E. Frandsen, http://www2.imm.dtu.dk/documents/ftp/publlec/lec2_99.pdf
Powell's Dog Leg Method, PDLM
  • 1999, Hans B. Nielsen: http://www2.imm.dtu.dk/documents/ftp/tr99/tr05_99.pdf
Hybrid Method: L-M and Quasi-Newton, H:LM+QN
  • 1999, Hans B. Nielsen: http://www2.imm.dtu.dk/documents/ftp/tr99/tr05_99.pdf
LMA for linear convergence
QN for superlinear convergence
Papers:
  • Yao Jianchao, Chia Tien Chern, COMPARISON OF NEWTON-GAUSS WITH LEVENBERG-MARQUARDT ALGORITHM FOR SPACE RESECTION, Proc. ACRS 2001 - 22nd Asian Conference on Remote Sensing, 5-9 November 2001, Singapore. Vol. 1, pp. 256-261.
  • C. Kanzow, N. Yamashita and M. Fukushima, Levenberg–Marquardt methods with strong local convergence properties for solving nonlinear equations with convex constraints, J. Comput. Appl. Math.172 (2004), pp. 375–397.
  • Kanzow, C., Yamashita, N., and Fukushima, M. 2004. Levenberg-Marquardt methods with strong local convergence properties for solving nonlinear equations with convex constraints. J. Comput. Appl. Math. 172, 2 (Dec. 2004), 375-397. DOI= http://dx.doi.org/10.1016/j.cam.2004.02.013
  • Lourakis, M. I. and Argyros, A. A. 2005. Is Levenberg-Marquardt the Most Efficient Optimization Algorithm for Implementing Bundle Adjustment?. In Proceedings of the Tenth IEEE international Conference on Computer Vision - Volume 2 (October 17 - 20, 2005). ICCV. IEEE Computer Society, Washington, DC, 1526-1531. DOI= http://dx.doi.org/10.1109/ICCV.2005.128

Source codes:
levmar: Levenberg-Marquardt nonlinear least squares algorithms in C/C++
lmfit — a C/C++ routine for Levenberg-Marquardt minimization with wrapper for least-squares curve fitting
lmfit is easy to install it because it is without the dependency problem.
Levenberg-Marquardt for Visual C++ 2005
Levenberg-Marquardt algorithm for multivariate optimization in C#/C++/Delphi/VB6/Zonnon

Continue....

Tuesday, March 3, 2009

Pointer in C

A simple example to using pointer in C.

we claim a pointer in main function, and hope to pass it to subroutin to allocate the memory.
How to use it?
Solution 1, return the address back.
=======================
#include
#include

int array_size =10;


int fill_array( float *ptr)
 {
    int i;
printf("Address %d\n", &ptr);
    ptr = (float *) malloc(array_size *sizeof(float));

    for(i=0; i<>
    {
         
      ptr[i] = (float)i;

    }

    
   for(i=0; i
   {
 printf("In function\n");
 
      printf("%d - %f ", &ptr[i],ptr[i]);
   }
   printf("\n");
   printf("ptr = %d\n", &ptr);
   return(ptr);
 }
main()
{
float *ptr = NULL;
int i;
printf("Address %d\n", &ptr);
ptr=fill_array(&ptr);

printf("Out function\n");
printf("Address %d\n", &ptr);
for(i=0; i
{
printf("Out function\n");
printf("%d - %f ", &ptr[i], ptr[i]);
}
}
=======================
The result will be
-------------------------------------
Address 1245052 //ptr in main( )
Address 1244968 //ptr in fill_array( )
In function
4397824 - 0.000000 In function
4397828 - 1.000000 In function
4397832 - 2.000000 In function
4397836 - 3.000000 In function
4397840 - 4.000000 In function
4397844 - 5.000000 In function
4397848 - 6.000000 In function
4397852 - 7.000000 In function
4397856 - 8.000000 In function
4397860 - 9.000000
ptr = 1244968  //ptr in fill_array( )
Out function
Address 1245052
Out function
4397824 - 0.000000 Out function
4397828 - 1.000000 Out function
4397832 - 2.000000 Out function
4397836 - 3.000000 Out function
4397840 - 4.000000 Out function
4397844 - 5.000000 Out function
4397848 - 6.000000 Out function
4397852 - 7.000000 Out function
4397856 - 8.000000 Out function
4397860 - 9.000000 Press any key to continue
-------------------------------------

Solution 2 , call by address.
=======================
#include
#include

void function(float ** ptrf)
{

int i;
printf("address of *ptrf = %d\n", &*ptrf);
*ptrf = (float *) malloc(5*sizeof(float*));
printf("address of *ptrf = %d\n", &*ptrf);
for(i=0; i<5;>
{
(*ptrf)[i] =i;
}
}

int main()
{
float *ptr=NULL;

int i;
printf("address of *ptr = %d\n", &ptr);
function(&ptr);

for(i=0; i<5;>
{
printf("%f ", ptr[i]);
}
printf("\nAddress ponited to by the ptr out function \nptr=%d, &ptr=%d\n", ptr, &ptr);
}
=======================
The result will be
---------------------------------
address of *ptr = 1245052
address of *ptrf = 1245052
address of *ptrf = 1245052
0.000000 1.000000 2.000000 3.000000 4.000000
Address ponited to by the ptr out function
ptr=4397856, &ptr=1245052
Press any key to continue
---------------------------------

Clicky

Clicky Web Analytics