Subscribe to my RSS feed RSS
01月 6, 2010

主成份分析(PCA:Principal Components Analysis)(翻译)

原文地址

主成份分析介绍:

第一部分:介绍

本介绍主要是为了给读者一个主成分的基本介绍。主成份分析是一种非常有用的统计方法,他在人脸识别和图像压缩领域都有应用,他是一直常用的从高维的数据空间寻找特征的方法。

在我们开始介绍主成份分析之前,我们介绍一下主成份分析所用到的数学基础内容。,其中包括标准差,协方差,特征向量,特征值。这些基础知识可以使得主成分分析更加直观。如果你已经对这些基础非常熟悉,请直接跳过这个部分。
为了把我们讨论的问题说明更加清楚,有许多例子贯穿在本介绍中。如果你需要进一步的内容,请参考书籍:《Elementary Linear Algebra 5e》 …

第二部分:数学基础(这是大学的基础知识,如果不知道的话自己回去好好看看)

(1)数理统计:

标准差(平均值,方差(Variance),标准差),

协方差(协方差矩阵)

(2)线性代数

特征向量

特征值

第三部分:主特征分析

最后我们来说主特征分析,他是确定数据中的模式,同事通过主特征来表示数据能够突出相似和差异的一种方法。因为在高维空间很难找到数据所包含的模式,因为在高维空间很难用图像化表示数据,因此主特征分析是一种非常有用的方法。

主特征分析另外的一个优点是一旦你找出数据的模式,你就可以压缩信息,例如降低数据的维度,却不丢失信息。这项技术在图片压缩中使用,稍候我们会介绍。

本节我们会一步一步深入在数据集上做主特性分析。在介绍中,将不会介绍为什么这项技术是可行,但是在你使用这些技术时需要做出重要决策的地方我们会着重介绍。

(1)方法

第一步:获取数据

在下面的例子里面。我们将使用我们自己的数据集。这个数据集只有二维,因为我们可以图像话的方法表示出主特征分析的每一步做了什么事情。

第二步:减去平均值

第三步: 计算协方差矩阵

第四步:计算协方差矩阵的特征值和特征向量

第五步:特征选取组成特征向量

第六步:把数字转换到新的空间里面

01月 2, 2010

ice 读书笔记001

Idempotent Operations

Some operations, such as getTime on page 111, do not modify the state of the object they operate on. They are the conceptual equivalent of C++ const member functions. Similary, setTime does modify the state of the object, but is idempotent. You can indicate this in Slice as follows:
interface Clock {
idempotent TimeOfDay getTime();
idempotent void setTime(TimeOfDay time);
};
This marks the getTime and setTime operations as idempotent. An operation is idempotent if two successive invocations of the operation have the same effect as a single invocation. For example, x = 1; is an idempotent operation because it does not matter whether it is executed once or twice—either way, x ends up with the value 1. On the other hand, x += 1; is not an idempotent operation because executing it twice results in a different value for x than executing it once. Obviously, any read-only operation is idempotent.
The idempotent keyword is useful because it allows the Ice run time to attempt more aggressive error recovery. Specifically, Ice guarantees at-most-once semantics for operation invocations:
• For normal (not idempotent) operations, the Ice run time has to be conservative about how it deals with errors. For example, if a client sends an operation invocation to a server and then loses connectivity, there is no way for the client-side run time to find out whether the request it sent actually made it to the server. This means that the run time cannot attempt to recover from the error by re-establishing a connection and sending the request a second time because that could cause the operation to be invoked a second time and violate at-most-once semantics; the run time has no option but to report the error to the application.
• For idempotent operations, on the other hand, the client-side run time can attempt to re-establish a connection to the server and safely send the failed request a second time. If the server can be reached on the second attempt, everything is fine and the application never notices the (temporary) failure. Only if the second attempt fails need the run time report the error back to the application. (The number of retries can be increased with an Ice configuration parameter.)

大意如下:在实际应用中有些操作调用次数不会改变返回结果这样的操作叫做等幂操作,可以用关键词idempotent来修饰,或者叫做与调用次数无关的操作。这个关键词的实际用处在于,对于等幂操作,因为多次调用不会改变服务的逻辑,因此ice在服务出现异常和错误的时候,可以尝试重新建立与服务器的连接,并且重新发送刚才的请求,如果服务恢复了,客户端就可以返回正确的结果,而不是想一般操作那样:当第一次出现问题的时候只能把问题报告给上层,交给上层处理。(一般的操作都是默认为非等幂操作)。并且等幂操作从新发送求的上限是可以设置,应该在proxy里面,具体要尝试一下就知道了。

备注: 在看ice1.3.0版本里面还有一个类似的关键词叫做:Nonmutating,他们的区别在于Nonmutating的要求更加严格一下,因为Nonmutating要求:多次调用不会改变服务对象的状态,好像比Idempotent稍微高了一下,它里面暗含Idempotent。现在的版本中好像去掉了这个关键词,只保留了Idempotent。

心的:其实有很多服务都是等幂操作,使用这个关键词可以减少超时等异常,当然可能会提高最大时间时间)

11月 19, 2009

AMQP resources(转载)

AMQP resources:
Servers:
RabbitMQ (Rabbit Technologies, Erlang/OTP, MPL) – http://rabbitmq.com
ZeroMQ (iMatix/FastMQ/Intel, C++, GPL3) – http://www.zeromq.org
OpenAMQ (iMatix, C, GPL2) – http://openamq.org
ActiveMQ (Apache Foundation, Java, apache2) – http://activemq.apache.org

Steve Vinoski explains AMQP in his column, Towards Integration

http://steve.vinoski.net/pdf/IEEE-Advanced_Message_Queuing_Protocol.pdf

John O’Hara on the history of AMQP

http://www.acmqueue.org/modules.php?name=Content&pa=showpage&pid=485

Dmitriy’s presentation on RabbitMQ/AMQP

http://somic-org.homelinux.org/blog/2008/07/31/slides-for-my-amqprabbitmq-talk/

ZeroMQ’s analysis of the messaging technology market

http://www.zeromq.org/whitepapers:market-analysis

Pieter Hintjens’s background to AMQP

http://www.openamq.org/doc:amqp-background

Barry Pederson’s py-amqplib

http://barryp.org/software/py-amqplib/

Ben Hood on writing an AMQP client

http://hopper.squarespace.com/blog/2008/6/21/build-your-own-amqp-client.html

Dmitriy Samovskiy introduces Ruby + QPid + RabbitMQ

http://somic-org.homelinux.org/blog/2008/06/24/ruby-amqp-rabbitmq-example/

Ben Hood’s as3-amqp

http://github.com/0×6e6562/as3-amqp

http://hopper.squarespace.com/blog/2008/7/4/server-side-as3.html

http://hopper.squarespace.com/blog/2008/3/24/as3-amqp-client-first-cut.html

RabbitMQ’s protocol code generator

http://hg.rabbitmq.com/rabbitmq-codegen/

Erlang Exchange presentation on the implementation of RabbitMQ

http://skillsmatter.com/podcast/erlang/presenting-rabbitmq-an-erlang-based-implementatio-nof-amqp

http://www.lshift.net/blog/2008/07/01/slides-from-our-erlang-exchange-talk

Jonathan Conway’s series on RabbitMQ and using it with Ruby/Merb

http://jaikoo.com/2008/3/20/daemonize-rabbitmq

http://jaikoo.com/2008/3/14/oh-hai-rabbitmq

http://jaikoo.com/2008/2/29/friday-round-up-2008-02-29

http://jaikoo.com/2007/9/4/didn-t-you-get-the-memo

Open Enterprise’s series on messaging middleware and AMQP

http://www1.interopsystems.com/analysis/can-amqp-break-ibms-mom-monopoly-part-1.html

http://www1.interopsystems.com/analysis/can-amqp-break-ibms-mom-monopoly-part-2.html

http://www1.interopsystems.com/analysis/can-amqp-break-ibms-mom-monopoly-part-3.html

Messaging and distributed systems resources:

A Critique of the Remote Procedure Call Paradigm

http://www.cs.vu.nl/~ast/publications/euteco-1988.pdf

A Note on Distributed Computing

http://research.sun.com/techrep/1994/smli_tr-94-29.pdf

Convenience Over Correctness

http://steve.vinoski.net/pdf/IEEE-Convenience_Over_Correctness.pdf

Metaprotocol Taxonomy and Communications Patterns

http://hessian.caucho.com/doc/metaprotocol-taxonomy.xtp

Joe Armstrong on Erlang messaging vs RPC

http://armstrongonsoftware.blogspot.com/2008/05/road-we-didnt-go-down.html

SEDA: scalable internet services using message queues

http://www.eecs.harvard.edu/~mdw/papers/seda-sosp01.pdf

11月 16, 2009

Ubuntu工作配置

以ubuntu 9.04为例介绍基本配置。 注意:本文档只是一个简单的介绍,在安装的过程中可能遇到这样或者那样的问题,请先使用搜索引擎独立解决。

  • 修改源
  • 首先打开源的配置文件

    $ sudo vim /etc/apt/sources.list

    选择一个网速较快的源写入sources.lst,然后更新一下源

    $ sudo apt-get update

    最新更新系统

    $ sudo apt-get upgrade

  • 开发环境
    命令:$sudo apt-get install xxxx

    1. c/c++: gcc
    2. java: sun-java6-jdk
    3. python
    4. ssh: opensssh
  • 基本工具
    1. 邮箱客户端:thunderbird
    2. 即时通讯:pidgin/Empathy
    3. flash播放器 :Adobe flash player
    4. 浏览器:firefox  以及很好的插件
    5. 中文输入法:scim/ibus/fcitx
    6. 辞典:Star Dict
    7. 压缩工具:unrar p7zip-rar p7zip-full cabextract
    8. pdf阅读器:Adobe Reader
    9. chm阅读器: kchmreader
    10. kerberos认证: krb5
    11. maven: maven2
    12. 数据库连接: mysql-client
  • 推荐工具
    1. Gnome.do 非常好的一个快速启动装置,用了就会喜欢上他
    2. prism (Gmail,facebook,docs,google talk),当然也可以自己制作喜欢网站的快捷方式,比如我就搞了一个renren的
    3. latex写作  texlive 2008 kile
    4. ads 广告拦截 adblock  非常好用
    5. Vimperator firefox vim 化
  • java开发环境
    eclipse 3.5 及以上版本
    插件:

    1. subclipse 版本控制插件
    2. Mylyn
    3. AJDT
    4. WTP
    5. m2eclipse
    6. ….有需要自己找更新网址,然后update

(红色部分是强烈推荐的,不信你可以试一试!)

很多重复的工作多写一些脚本,bash或者python不管什么都好,只要可以完成工作就ok,个人现在比较喜欢bash。

有好的工作环境,工作起来就会事办功备,同时有时间多学以前其他东西!

11月 16, 2009

some useful jdk tools!

some useful jdk tools!

  1. javac/java/javadoc/jar/javah/javap
  2. jps/jstat/jstatd
  3. jinfo/jhat/jmap/jstack
  4. ….

JDK Tools and Utilities

11月 16, 2009

算法感想

算法感想:从大一学期开始学习算法,参加acm竞赛,和算法作了3年的朋友,现在想来

  • acm算法不是algorithm的全部,或者只是很小的一部分。不敢说最重要,但是确实最基础部分,理解好这些基础部分,对于理解那些更贴近工程实际的算法事半功倍!
  • acm算法的核心是什么?是灵活! (个人愚见)大部分的问题很实际但不工程,没有人会告诉你应该使用什么方法,方法是根据题目问题和数据灵活选择的,topcoder的srm尤其重视这一点!
  • 代码能力决定你能否把思路变成现实。算法思路影响你的代码能力,代码能力决定思路有多宽!好的代码风格也是一种能力。
  • 认真学习别人的代码会使你进步的更快,前提是你真正理解这个东西。否则不仅使你限制了你的思路,同时剥夺了你独立思考习惯和成功的喜悦。很多对acm渐渐失去热情的人多如此
  • 性格会灌注在你的代码里面。要严谨,冷静,问题想清楚思路在动手,要全面考虑,不要一时冲动,最好反复求证。同时遇到难点不要无法自拔,多交流,多沟通,敢于放弃。(在观看魔兽高手比赛中更能深刻感受这一点!,胜负就在一瞬间,但是有些时候要敢于放弃,有些时候却要坚持到底,不到最后一刻绝不放弃。至于怎么选择要看感觉,但是感觉是可以培养,是一个不断积攒经验的过程)
  • 数学基础很重要。我初一的数学老师第一节给我们将的数学三种性质:模仿性,变通性,破坏性。至今觉得数学如此,acm竞赛也如此。好的数学基础觉得你可以在竞赛中走多远!

这些是最近特别是看了WCG2009魔兽项目总决赛fly100% VS infi 回想到自己大学比赛之路,反思的!

11月 6, 2009

Unix/linux System tools

一些常用unix/linux系统工具:

  1. top/free/df/ps/sar
  2. vmstat/iostat/nmon
  3. strace/ltrace/dtrace
  4. ping/dig/mtr/ifconfig
  5. tcpdump/iptraf
  6. netstat/lsof