網頁

2011年8月16日星期二

USB


  • high-speed (USB 2.0) rate of 480 Mbit/s (~57 MB/s) was introduced in 2001. All hi-speed devices are capable of falling back to full-bandwidth operation if necessary; i.e., they are backward compatible with USB 1.1. Connectors are identical for USB 2.0 and USB 1.x.
  • SuperSpeed (USB 3.0) rate of 4.8 Gbit/s (~572 MB/s). The written USB 3.0 specification was released by Intel and partners in August 2008. The first USB 3 controller chips were sampled by NEC May 2009 and products using the 3.0 specification arrived beginning in January 2010. USB 3.0 connectors are generally backwards compatible, but include new wiring and full duplex operation.


2011年8月13日星期六

Ubuntu: dev 檔的安裝

Debian,以及基于 Debian 的系統,如 Ubuntu 等,所使用的包格式為 deb。以下為操作 deb 包的常用 Dpkg 指令表,供初學的朋友參考。


命令
作用
dpkg -i package.deb
安裝包
dpkg -r package
刪除包
dpkg -P package
刪除包(包括配置文件)
dpkg -L package
列出與該包關聯的文件
dpkg -l package
顯示該包的版本
dpkg –unpack package.deb
解開 deb 包的內容
dpkg -S keyword
搜索所屬的包內容
dpkg -l
列出當前已安裝的包
dpkg -c package.deb
列出 deb 包的內容
dpkg –configure package
配置包

注意:更多選項可通過 dpkg -h 查詢,有些指令需要超級用戶權限才能執行。

Ubuntu 右鍵terminal程序

sudo apt-get install nautilus-open-terminal

http://packages.ubuntu.com/

Linux Sky

Ubuntu

2011年8月12日星期五

Model-view-controlled

Model–view–controller (MVC) is a software architecture, currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing and maintenance of each (separation of concerns).




Overview

Though MVC comes in different flavors, control flow is generally as follows:
  • The user interacts with the user interface in some way (for example, by pressing a mouse button).
  • The controller handles the input event from the user interface, often via a registered handler or callback, and converts the event into an appropriate user action, understandable for the model.
  • The controller notifies the model of the user action, possibly resulting in a change in the model's state. (For example, the controller updates the user's shopping cart.)[4]
  • A view queries the model in order to generate an appropriate user interface (for example the view lists the shopping cart's contents). The view gets its own data from the model. In some implementations, the controller may issue a general instruction to the view to render itself. In others, the view is automatically notified by the model of changes in state (Observer) that require a screen update.
  • The user interface waits for further user interactions, which restarts the control flow cycle.
  • Some implementations such as the W3C XForms also use the concept of a dependency graph to automate the updating of views when data in the model changes.
The goal of MVC is, by decoupling models and views, to reduce the complexity in architectural design and to increase flexibility and maintainability of code. MVC has also been used to simplify the design of Autonomic and Self-Managed systems

Concepts

The model manages the behaviour and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). In event-driven systems, the model notifies observers (usually views) when the information changes so that they can react.
The view renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes. A viewport typically has a one to one correspondence with a display surface and knows how to render to it.
The controller receives user input and initiates a response by making calls on model objects. A controller accepts input from the user and instructs the model and viewport to perform actions based on that input.
An MVC application may be a collection of model/view/controller triads, each responsible for a different UI element. The Swing GUI system, for example, models almost all interface components as individual MVC systems.
MVC is often seen in web applications where the view is the HTML or XHTML generated by the app. The controller receives GET or POST input and decides what to do with it, handing over to domain objects (i.e. the model) that contain the business rules and know how to carry out specific tasks such as processing a new subscription, and which hand control to (X)HTML-generating components such as templating engines, XML pipelines, Ajax callbacks, etc.
The model is not necessarily merely a database; the 'model' in MVC is both the data and the business/domain logic needed to manipulate the data in the application. Many applications use a persistent storage mechanism such as a database to store data. MVC does not specifically mention the data access layer because it is understood to be underneath or encapsulated by the model. Models are not data access objects; however, in very simple apps that have little domain logic there is no real distinction to be made. Active Record is an accepted design pattern that merges domain logic and data access code — a model which knows how to persist itself.

Architecture vs. frameworks

Although MVC is typically associated with frameworks, it is essentially an architecture.[6] This means that it can be implemented even without an object-oriented language or a specific class hierarchy. For example, using as little as jQuery's trigger() and bind(), it is possible to build robust MVC applications in a browser using Javascript. The key is simply to divide up the responsibilities of the MVC components into clearly defined sections of code. As stated in the overview, the code that embodies the model takes care of state, business logic, persistence, and notifications. The persistence can be implemented via cookies or AJAX. The notifications can be taken care of by the jQuery.trigger(). The code that embodies the view takes care of querying the model and rendering the view. The view code can be implemented in a variety of ways, including inserting HTML DOM nodes or changing CSS styles. The code that embodies the controller takes care of initialization of the model and wiring up the events between the view's HTML DOM elements and controller and between the model and the view code, using jQuery.bind().

Example

Model
The model is a collection of Java classes that form a software application intended to store, and optionally separate, data. A single front end class that can communicate with any user interface (for example: a console, a graphical user interface, or a web application).
View
The view is represented by a JavaServer Page, with data being transported to the page in the HttpServletRequest or HttpSession.
Controller
The Controller servlet communicates with the front end of the model and loads the HttpServletRequest or HttpSession with appropriate data, before forwarding the HttpServletRequest and Response to the JSP using a RequestDispatcher.

Implementations of MVC as GUI frameworks
  • GNUstep, also based on OpenStep, encourages MVC as well.
  • GTK+ provides models (as both interfaces and as concrete implementations) and views, while clients implement the controllers through signals.
  • JFace.
  • Qt since Qt4 release.
  • Java Swing.
  • Apache Pivot.
  • Adobe Flex with the Cairngorm Framework.


















2011年8月11日星期四

Python: datetime

The datetime module supplies classes for manipulating dates and times in both simple and complex ways.

Available Types

class datetime.date
An idealized naive date, assuming the current Gregorian calendar always was, and always will be, in effect. Attributes: year, month, and day.

class datetime.time
An idealized time, independent of any particular day, assuming that every day has exactly 24*60*60 seconds (there is no notion of “leap seconds” here). Attributes: hour, minute, second, microsecond, and tzinfo.

class datetime.datetime
A combination of a date and a time. Attributes: year, month, day, hour, minute, second, microsecond, and tzinfo.

class datetime.timedelta
A duration expressing the difference between two date, time, or datetime instances to microsecond resolution.

class datetime.tzinfo
An abstract base class for time zone information objects. These are used by the datetime and time classes to provide a customizable notion of time adjustment (for example, to account for time zone and/or daylight saving time).

timedelta Objects
class datetime.timedelta([days[, seconds[, microseconds[, milliseconds[, minutes[, hours[, weeks]]]]]]])

>>> from datetime import timedelta
>>> d = timedelta(microseconds=-1)
>>> (d.days, d.seconds, d.microseconds)
(-1, 86399, 999999)



AttributeValue
daysBetween -999999999 and 999999999 inclusive
secondsBetween 0 and 86399 inclusive
microsecondsBetween 0 and 999999 inclusive


date Objects
class datetime.date(year, month, day)

datetime Objects
class datetime.datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])


Supported operations:
OperationResult
datetime2 = datetime1 + timedelta(1)
datetime2 = datetime1 - timedelta(2)
timedelta = datetime1 - datetime2(3)
datetime1 < datetime2Compares datetime to datetime. (4)


Some class methos:

datetime.strftime(format)
Return a string representing the date and time, controlled by an explicit format string. See section strftime() and strptime() Behavior.

The following is a list of all the format codes that the C standard (1989 version) requires, and these work on all platforms with a standard C implementation. Note that the 1999 version of the C standard added additional format codes.

DirectiveMeaningNotes
%aLocale’s abbreviated weekday name.
%ALocale’s full weekday name.
%bLocale’s abbreviated month name.
%BLocale’s full month name.
%cLocale’s appropriate date and time representation.
%dDay of the month as a decimal number [01,31].
%fMicrosecond as a decimal number [0,999999], zero-padded on the left(1)
%HHour (24-hour clock) as a decimal number [00,23].
%IHour (12-hour clock) as a decimal number [01,12].
%jDay of the year as a decimal number [001,366].
%mMonth as a decimal number [01,12].
%MMinute as a decimal number [00,59].
%pLocale’s equivalent of either AM or PM.(2)
%SSecond as a decimal number [00,61].(3)
%UWeek number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.(4)
%wWeekday as a decimal number [0(Sunday),6].
%WWeek number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday are considered to be in week 0.(4)
%xLocale’s appropriate date representation.
%XLocale’s appropriate time representation.
%yYear without century as a decimal number [00,99].
%YYear with century as a decimal number.
%zUTC offset in the form +HHMM or -HHMM (empty string if the the object is naive).(5)
%ZTime zone name (empty string if the object is naive).
%%A literal '%' character.









技術分析

技術分析是指研究過去金融市場的資訊(主要是經由使用圖表)來預測價格的趨勢與決定投資的策略。純理論上,技術分析只考慮市場或金融工具真實的價格行為,在假設其價格會反應所有在投資者經由其他管道得知前的所有相關因素的前提之下。

技術分析的基本信仰建立在「歷史會不斷重演」,並試圖藉由大量的統計資料來預測行情走勢。 技術分析被交易者和金融專家們廣為使用,且有些研究表示,在外匯市場裡,技術分析的使用要比「基本」分析要來得廣泛。

一般描述

技術分析師會辨別金融市場上的非隨機價格圖樣和趨勢,並企圖利用這些圖樣。在技術分析師所使用的各種方法和工具之中,價格圖表是最主要的一種。技術分析師特別會去尋找所謂的原型圖樣,例如知名的頭肩反轉型態,以及研究此類型的指標,如價格、成交量與價格的移動平均等。許多的技術分析師亦會依著投資者心理(市場氛圍)的指標來操作。

技術分析師尋求著預測價格趨勢的方法,以期從成功的交易中所得到的巨大獲利能勝過較多但較少損失的失敗交易,好讓獲利在長期中能經由風險控制和金錢管理得到正值。

技術分析有許多個學派。每個學派(如K線、道氏理論和艾略特波浪理論)的擁護者或許會忽略其他的理論,但許多交易者會同時使用一個學派以上的理論來做分析。技術分析師使用經由經驗所得到的判斷依據來決定特定的工具在一定時間內所顯示的圖樣,以及圖樣的解譯為何。技術分析師可能會不同意他們之間對一特定圖樣的解譯。

技術分析經常會和「基本分析」(研究一些分析師說能影響金融市場價格的經濟因素的理論)相衝突。純粹的技術分析表示,價格在投資者認知到它們之前就已經反應了所有的影響因素,因此只需研究價格本身的作用。有些交易者只使用技術分析或只使用基本分析,而有些人則同時使用這兩者來做決定如何交易。

原理

技術分析師認為市場價格會反應出所有的相關資訊,所以其分析比起在如新聞事件等「外部」,更偏向於在「內部」分析。價格行為亦會慣於重複其本身的模式,因為投資者會集體地頃向某個制式的行為-因此,技術分析師主要專注在趨勢和形態的認定上。

市場行為會將任何東西都給打折

基於所有相關資訊都已經反應在價格上的前提之下,技術分析師相信基本分析是多餘的-他們說新聞和新聞事件從來不會嚴重地去影響價格,且庫特勒、波特巴和薩莫斯所著的《What Moves Stock Prices?》這篇研究也支持此一論點。

在大多數巨幅回檔的日子裡,被指為是市場價格移動原因的資訊一般都不是特別地重要。相連數天的新聞報導亦無法對獲利或折現率為何會如此改變提出任何一種可信的看法。對於認定對重大的市場價格移動的基本因素,我們無能的地方在於,難以跟此類的因素和其他大部份在股市回檔中的變異量相一致。

 隨著趨勢移動的價格

技術分析師相信有所謂的價格趨勢。技術分析師說市場會上漲、下跌或盤整。對價格趨勢的基本定義是道氏理論所提出的一個基礎。其中一個例子是,時代華納從2001年11月到2003年8月間的股票價格,可以看得出來有很明顯的趨勢。一個認定此一趨勢的技術分析師或交易者便會尋找賣出這支股票的機會。時代華納的股價持續地下探。每當股價有一點回升時,賣家就會進場並賣出股票;因此形成了鋸齒狀的價格移動。一連串的「較低高點」和「較低低點」可以說是下跌趨勢的一個很童話式般的信號。換句話說,每當股價開始下探時,它都會跌破它之前的相對低點。而當股價開始探高時,它卻都無法突破它之前的相對高點。

要注意的是,這一連串的較低低點和較低高點從8月後不再出現。然後,時代華納的低價在這個月並沒有低於之前的相對低點。同一月份,高點亦等同於之前的相對高點。在技術分析師的眼裡,這是個很強的訊息,代表著下跌趨勢至少會稍微暫停,且有可能會停止,因此會在這時主動地停止再賣出這支股票。

歷史慣於重複

技術分析師相信,投資者會集體地重複他們之前的投資者的行為。「每個人都想要參與下一代的微軟」、「若股價又再次地回到50元,我就會去買它」、這家公司的技術將會使整個產業界掀起一波革命,所以它的股價將會一飛沖天」-這些都是投資者們重複不斷的觀點。對一個技術分析師來說,市場上的情緒也許是不理性的,但它們確定存在。因為投資者通常會重複他們的行為,所以技術分析師相信可以找到一些可確認(且可預測)的價格圖樣,並繪製出一個圖表來。

技術分析師不一定侷限在圖表中,也不總是只關心價格的趨勢而已。舉個例子,許多的技術分析師會監看投資者心理的報告。這些報當會估測出市場參與者們的態度,尤其是看空或看多。技術分析師利用這些報告來幫助他們判斷一個趨勢是將會持續下去,或會將會開始反轉;他們最能預測出會有一個改變的是在報告顯示出了一個極端的投資者心理時。例如,若報告顯示出絕大多數的人都看多時,上漲的趨勢就有可能會反轉-前提是看多的投資者都已經買進了股票(預測會有較高的價格)。而因為大多數的投資者都看多且已經下場投資,可以假設只剩少數一些的買家而已。其他則是多於這些買家的潛在型賣家,儘管市場上濃厚的看多氛圍。這一推論猜測股價將會開始下跌。此即為反向投資法的一個例子。

系統交易和技術分析

神經網路

從第一個可實用的型式於90年代初期出現之後,人工神經網路即迅速地普及了起來,並以模擬生物的神經網路製造出了適應人工智慧的軟體系統。它們因為可以學習偵測資料裡的複雜模式而流行了起來。以數學的語言來說,它們是一般非線性函數逼近器,意指若給與正確的資料且將其正確地派置,就可以獲到並模擬任何的輸入/輸出關係。這不只是移除了人類解釋圖表或一串產生輸入/輸出訊息的規則的需要而已,亦提供了通往基本分析的一個橋樑,因為其中的輸入可以換成基本分析中的變數。

另外,當人工神經網路是一個真正的非線性統計模型時,其精確性和預測能力便可以經由數學和經濟兩方面來測試。在許多的研究中,用來產生交易訊息的神經網路的效利大幅地超越買持策略,以及傳統的線性技術分析方法。

因為此類系統深奧的數學本性,使得用於金融分析的神經網路大多都還停留在學術界裡。但最近幾年,已經有越來越多對使用者友善的神經網路軟體開始出現。

循規交易

循規交易是指以嚴謹且明確的規則來訂定交易計畫的過程。不同於其他的一些技術分析方法或是大部份的基本分析,循規交易定義了一組決定整場交易的規則,只留下最少的人為決策。

例如,一個交易者可能訂下一個規則:當某一投資工具的價格收在50天移動平均之上時,即做多;若在其之下的話,則做空。

圖表及指數
下表為較廣為人所知的技術分析概念:

累積/分佈指數
真實波動幅度均值
布林帶
突破
商品通道指數
艾略特波浪理論和斐波那契回調
引掛模式
MACD
動量
金錢流
移動平均
OBV
拋物轉向系統
軸點分析
點線圖
相對強弱指數
支撐線和壓力線
隨機指標
趨勢線
Trix指標

2011年8月9日星期二

Linux Permission

Users and Group
每個檔案的擁有者、群組與 others 的示意圖

Linux file properties

To change the file properties and permission

  • chgrp
    • change group
  • chown
    • change owner
  • chmod
    • change permission




From: http://linux.vbird.org/linux_basic/0210filepermission.php

Normalization

Numpy

matplotlib

matplotlib is a python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms.


plotting commands


FunctionDescription
acorrplot the autocorrelation function
annotateannotate something in the figure
arrowadd an arrow to the axes
axescreate a new axes
axhlinedraw a horizontal line across axes
axvlinedraw a vertical line across axes
axhspandraw a horizontal bar across axes
axvspandraw a vertical bar across axes
axisset or return the current axis limits
barbsa (wind) barb plot
barmake a bar chart
barha horizontal bar chart
broken_barha set of horizontal bars with gaps
boxset the axes frame on/off state
boxplotmake a box and whisker plot
claclear current axes
clabellabel a contour plot
clfclear a figure window
climadjust the color limits of the current image
closeclose a figure window
colorbaradd a colorbar to the current figure
coheremake a plot of coherence
contourmake a contour plot
contourfmake a filled contour plot
csdmake a plot of cross spectral density
delaxesdelete an axes from the current figure
drawForce a redraw of the current figure
errorbarmake an errorbar graph
figlegendmake legend on the figure rather than the axes
figimagemake a figure image
figtextadd text in figure coords
figurecreate or change active figure
fillmake filled polygons
fill_betweenmake filled polygons between two curves
findobjrecursively find all objects matching some criteria
gcareturn the current axes
gcfreturn the current figure
gciget the current image, or None
getpget a graphics property
gridset whether gridding is on
hexbinmake a 2D hexagonal binning plot
histmake a histogram
holdset the axes hold state
ioffturn interaction mode off
ionturn interaction mode on
isinteractivereturn True if interaction mode is on
imreadload image file into array
imsavesave array as an image file
imshowplot image data
isholdreturn the hold state of the current axes
legendmake an axes legend
locator_paramsadjust parameters used in locating axis ticks
logloga log log plot
matshowdisplay a matrix in a new figure preserving aspect
marginsset margins used in autoscaling
pcolormake a pseudocolor plot
pcolormeshmake a pseudocolor plot using a quadrilateral mesh
piemake a pie chart
plotmake a line plot
plot_dateplot dates
plotfileplot column data from an ASCII tab/space/comma delimited file
piepie charts
polarmake a polar plot on a PolarAxes
psdmake a plot of power spectral density
quivermake a direction field (arrows) plot
rccontrol the default params
rgridscustomize the radial grids and labels for polar
savefigsave the current figure
scattermake a scatter plot
setpset a graphics property
semilogxlog x axis
semilogylog y axis
showshow the figures
specgrama spectrogram plot
spyplot sparsity pattern using markers or image
stemmake a stem plot
subplotmake a subplot (numrows, numcols, axesnum)
subplots_adjustchange the params controlling the subplot positions of current figure
subplot_toollaunch the subplot configuration tool
suptitleadd a figure title
tableadd a table to the plot
textadd some text at location x,y to the current axes
thetagridscustomize the radial theta grids and labels for polar
tick_paramscontrol the appearance of ticks and tick labels
ticklabel_formatcontrol the format of tick labels
titleadd a title to the current axes
tricontourmake a contour plot on a triangular grid
tricontourfmake a filled contour plot on a triangular grid
tripcolormake a pseudocolor plot on a triangular grid
triplotplot a triangular grid
xcorrplot the autocorrelation function of x and y
xlimset/get the xlimits
ylimset/get the ylimits
xticksset/get the xticks
yticksset/get the yticks
xlabeladd an xlabel to the current axes
ylabeladd a ylabel to the current axes
autumnset the default colormap to autumn
boneset the default colormap to bone
coolset the default colormap to cool
copperset the default colormap to copper
flagset the default colormap to flag
grayset the default colormap to gray
hotset the default colormap to hot
hsvset the default colormap to hsv
jetset the default colormap to jet
pinkset the default colormap to pink
prismset the default colormap to prism
springset the default colormap to spring
summerset the default colormap to summer
winterset the default colormap to winter
spectralset the default colormap to spectral





pyplot
 provides a Matlab-like plotting framework.





import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0, 5, 0.1);
y = np.sin(x)
plt.plot(x, y)



 From: http://matplotlib.sourceforge.net/index.html