<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>格物致知</title>
	<atom:link href="http://leeing.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://leeing.org</link>
	<description>keep Thinking</description>
	<lastBuildDate>Thu, 09 Sep 2010 02:24:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Scala: 方法名约定</title>
		<link>http://leeing.org/2010/08/07/scala-method-name-convention/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://leeing.org/2010/08/07/scala-method-name-convention/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 15:03:47 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://leeing.org/?p=651</guid>
		<description><![CDATA[Scala中没有操作符但是支持运算符重载，方法的最后一个字符也对优先级有影响，它决定了方法调用的目标。 Scala的这个约定在熟悉之后你会发现它提高了流畅性，例如，如果想要将一个值添加到一list中，可以写作：value::list，尽管可以读为：“value被附加到list上”，这个方法的目标实际上list而参数是value，也就是说list.::(value)。 如果方法名以冒号结尾，那调用目标是操作符后面的实例，在下一个例子中，^() 是一个定义在类Cow中的方法，而 ^:() 是一个定义在Moon中的方法： class Cow { def ^(moon: Moon) = println("Cow jumped over the moon") } class Moon { def ^:(cow: Cow) = println("This cow jumped over the moon too") } 调用如下： val cow = new Cow val moon = new Moon cow ^ moon cow ^: moon 这两种调用方式看起来基本是相同的，cow在左而moon在右，但前一个调用是在cow上而后一个则是在moon上，这种区别对于新手来说可能很奇怪，但它在列表操作中是很平常的，所以最好熟悉这种写法，前面代码的输出是： Cow jumped over [...]


Related posts:<ol><li><a href='http://leeing.org/2010/04/26/scala-operator-override/' rel='bookmark' title='Permanent Link: Scala : &#8220;运算符&#8221; 重载'>Scala : &#8220;运算符&#8221; 重载</a></li>
<li><a href='http://leeing.org/2010/04/18/scala-option-and-foldleft/' rel='bookmark' title='Permanent Link: Scala : Option 和 foldLeft'>Scala : Option 和 foldLeft</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2010/08/07/scala-method-name-convention/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PeerSim 中文教程：Event-driven 模型</title>
		<link>http://leeing.org/2010/07/04/peersim-tutorial-example-of-event-driven-model/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://leeing.org/2010/07/04/peersim-tutorial-example-of-event-driven-model/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 11:32:44 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[P2P]]></category>
		<category><![CDATA[PeerSim]]></category>

		<guid isPermaLink="false">http://leeing.org/?p=637</guid>
		<description><![CDATA[1. 介绍 本教程使用Event-driven模型来演示一个简单的例子，仍然使用的是gossip-based平均数协议，对消息的发送将进行更细节的建模；通过与cycle-based模型的对比，可以发现本协议存在的问题。 在Event-based模型中，除了时间管理和control传递给protocols的方式以外，其它与cycle-based模型相同。不可执行的Protocols（只用于存储数据，比如只存储邻居节点的linkable协议，或存储数值的vectors）可以以同样的方式应用和初始化，在peersim.cdsim包之外的controls也都可以使用。在默认情况下，在cycle-based模型中，controls会的每个周期中调用 ，但在event-based模型中，它们需要进行明确的调度，因为事件驱动模型并不存在周期的概念。 显然，我们可以编写专用于event-based模型的controls，即可以给协议发送事件（消息）。在很多情况下，这是必要的，因为系统经常完全或部分地由外部事件如用户的查询来驱动 ，这能很好地用由生成这些事件，并且驱动仿真执行的controls进行建模。 有些组件是不可用的。例如依赖于静态类peersim.cdsim.CDState（它提供了读取cycle相关的全局状态的接口）的所有组件。我们的经验是，很多依赖于这个状态的 cycle-based 组件可以经过简单的修改并删除这个依赖。 然而，可能有些令人吃惊的是，实现了cycle-based接口的peersim.cdsim.CDProtocol也可以使用于event-based模型，但是必须指出，在大部份的情况下这样做没有什么意义。然而，这个特性的有用之处在于：它让周期性地调用protocols变得很简单，这是一个几乎对所有与housekeeping，失效检测和sending heartbeat message有关的P2P协议来说典型的特性。 2. Protocol 下面以event-based模型来实现平均数协议： package example.edaggregation; import peersim.vector.SingleValueHolder; import peersim.config.*; import peersim.core.*; import peersim.transport.Transport; import peersim.cdsim.CDProtocol; import peersim.edsim.EDProtocol; /** * Event driven version of epidemic averaging. */ public class AverageED extends SingleValueHolder implements CDProtocol, EDProtocol { 首先，这里同时实现了EDProtocol和CDProtocol接口，前者能让这个类能处理输入的消息，后者则可能令人困惑，因为它属于cycle-based模型的接口。但注意 event-based 的协议不是必须实现CDProtocol接口的，然而想要实现一个可以周期性取得control的协议时，可以通过实现CDProtocol接口，并在配置文件中设置一个CDScheduler 来实现。这样，代码就显得更清晰：以一个单独的组件来管理周期性的执行，而且能单独地进行配置。最后，我们还能简单地将 cycle-based 的协议移植到 event-based 模型上。 [...]


Related posts:<ol><li><a href='http://leeing.org/2010/07/02/peersim-turtorial-how-to-write-a-new-protocol/' rel='bookmark' title='Permanent Link: PeerSim 中文教程：编写一个新协议'>PeerSim 中文教程：编写一个新协议</a></li>
<li><a href='http://leeing.org/2010/07/02/peersim-turtorial-topology-generator/' rel='bookmark' title='Permanent Link: PeerSim 中文教程：拓扑生成器'>PeerSim 中文教程：拓扑生成器</a></li>
<li><a href='http://leeing.org/2010/06/30/peersim-turtorial-analyse-of-cycle-based-model/' rel='bookmark' title='Permanent Link: PeerSim 中文教程：解析 Cycle-based 模式仿真'>PeerSim 中文教程：解析 Cycle-based 模式仿真</a></li>
<li><a href='http://leeing.org/2010/01/20/common-p2p-simulator/' rel='bookmark' title='Permanent Link: 常用的 P2P 仿真平台'>常用的 P2P 仿真平台</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2010/07/04/peersim-tutorial-example-of-event-driven-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PeerSim 中文教程：拓扑生成器</title>
		<link>http://leeing.org/2010/07/02/peersim-turtorial-topology-generator/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://leeing.org/2010/07/02/peersim-turtorial-topology-generator/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 11:35:15 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[P2P]]></category>
		<category><![CDATA[PeerSim]]></category>

		<guid isPermaLink="false">http://leeing.org/?p=612</guid>
		<description><![CDATA[本教程描述了如何构建一个新的 PeerSim 拓扑生成器。 1. 什么是拓扑？为什么它很重要？ 在一个大型的动态P2P系统中，节点没有关于整个网络的信息，而所有的节点都可能拥有一些邻居节点，即节点能”感知”的peers，这种”感知”的关系就定义了一个覆盖网络，这是P2P系统中的一个基本概念。 很多P2P协议都需要在多个不同的网络拓扑上进行实验。PeerSim中的peersim.dynamic.Wire*类已经包含了很多拓扑结构，可以直接用来对linkable协议进行初始化，本教程将展示如何构建一个自定义的拓扑生成器。 2. 一个用来模拟Internet的简单模型 下面我们将编写一个拓扑生成器来构建类似于Internet的树状拓扑，整个构建过程基于一个特定的，与位置相关的preferential attachment方法，编写规则很简单，并且会考虑几何和网络的限制以更好地模拟真实的网络。Preferential attachment由参数a来调整，这个参数能扩大或减少几何位置所带来的影响。 这个规则的策略如下：给定一个单位正方形，将x0置于中心，即x0 = (0.5,0.5)，这个节点被称为root，令W()为与root相隔的跳数(hops)，对于i=1 … n-1，随机在单位正方形中选择一个xi，然后选择使下面的表达式值最小的节点xj来连接它： 在这里dist()是欧几里德距离而a (alpha)是权重参数，显然， 通过这个方案我们得到了一个x0以为根的树。这个拓扑中每个节点(除了root外)的出度都为1,如果想更深入地理解这个模型，可以参考下面的文章： Heuristically Optimized Trade-offs: A New Paradigm for Power Laws in the Internet Degree distributions of the FKP network model On Power-Law Relationships of the Internet Topology 3. 如何编码 我们的目标是编写一个可以根据 a (alpha)参数生成所需拓扑的PeerSim组件，并且能对生成的拓扑进行分析。这个拓扑可以在仿真过程中逐步生成，也可以用一个步骤生成拓扑，在这里我们倾向后者。为了构建需要的拓扑结构，我们需要下面的组件（注意这只是其中一种方案）。 一个protocol 类，可以存储坐标，它不具备行为元素，只是一个普通的容器。 一个initializer 类，可以为每个节点设置坐标值。 [...]


Related posts:<ol><li><a href='http://leeing.org/2010/07/02/peersim-turtorial-how-to-write-a-new-protocol/' rel='bookmark' title='Permanent Link: PeerSim 中文教程：编写一个新协议'>PeerSim 中文教程：编写一个新协议</a></li>
<li><a href='http://leeing.org/2010/07/04/peersim-tutorial-example-of-event-driven-model/' rel='bookmark' title='Permanent Link: PeerSim 中文教程：Event-driven 模型'>PeerSim 中文教程：Event-driven 模型</a></li>
<li><a href='http://leeing.org/2010/06/30/peersim-turtorial-analyse-of-cycle-based-model/' rel='bookmark' title='Permanent Link: PeerSim 中文教程：解析 Cycle-based 模式仿真'>PeerSim 中文教程：解析 Cycle-based 模式仿真</a></li>
<li><a href='http://leeing.org/2010/04/30/swing-redirecting-system-out-and-system-err-to-jtextpane-or-jtextarea/' rel='bookmark' title='Permanent Link: Swing : 将 System.out 重定向到 JTextArea 和 JTextPane'>Swing : 将 System.out 重定向到 JTextArea 和 JTextPane</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2010/07/02/peersim-turtorial-topology-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PeerSim 中文教程：编写一个新协议</title>
		<link>http://leeing.org/2010/07/02/peersim-turtorial-how-to-write-a-new-protocol/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://leeing.org/2010/07/02/peersim-turtorial-how-to-write-a-new-protocol/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 16:52:29 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[P2P]]></category>
		<category><![CDATA[PeerSim]]></category>

		<guid isPermaLink="false">http://leeing.org/?p=592</guid>
		<description><![CDATA[本文的目的是在PeerSim中用Cycle-based模型实现一个简单的负载均衡算法。节点的状态有两种值：本地负载（local load）和配额(quota)，其中配额是指节点在每个周期中允许传输的“负载”的大小。配额是必要的，是一个时间单元中能传输的负载上限。每个节点与和它距离最远的邻居节点交换配额值，这里“距离最远”是指与当前节点的负载差异最大。经过对比距离，协议将在负载均衡时选用push或pull的方式。 在每个周期之后，配额值将会被存储。协议并不关心拓扑管理，它依赖于其它组件来访问邻居节点（例如，Newscast，或者由IdleProtocol实现的静态拓扑）。 一. 必要的组件 一般来说只编写一个协议类是不足够的，还需要一些附加的组件。例如，为了在每个周期结束时为每个节点存储配额值，需要一个特定的Control对象。基本上来说，PeerSim是一个可替换的组件集合，所以在开发时需要注意模块化以让代码尽可能重用，出于这样的目的，我们这样设计下面的类： protocol 它基于peersim.vector.SimpleValueHolder，这是一个简单的基类，用于访问一个浮点变量。Aggreation协议也使用了同样的基类。 ResetQuota 用于在每个周期结束时存储每个节点配额的control。 QuotaObserver 一个control，用于监视quota参数，即覆盖网中交换的流量大小。 initialization 这是在aggregation示例中的初始化器，这里也可以直接使用，因为它们实现了同样的接口SingleValueHolder。注意在example包中提供的初始化器是轻量级的，开发者应当更多地使用peersim.vector.*包中的初始化器。 observers 可以使用aggreagation.AverageObserver，因为这些组件实现了相同接口。 下面将根据源代码来解释这一过程： package example.loadbalance; import peersim.config.Configuration; import peersim.config.FastConfig; import peersim.core.*; import peersim.vector.SingleValueHolder; import peersim.cdsim.CDProtocol; public class BasicBalance extends SingleValueHolder implements CDProtocol { protected static final String PAR_QUOTA = "quota"; /** Quota amount. Obtained from config property {@link #PAR_QUOTA}. */ private [...]


Related posts:<ol><li><a href='http://leeing.org/2010/07/02/peersim-turtorial-topology-generator/' rel='bookmark' title='Permanent Link: PeerSim 中文教程：拓扑生成器'>PeerSim 中文教程：拓扑生成器</a></li>
<li><a href='http://leeing.org/2010/07/04/peersim-tutorial-example-of-event-driven-model/' rel='bookmark' title='Permanent Link: PeerSim 中文教程：Event-driven 模型'>PeerSim 中文教程：Event-driven 模型</a></li>
<li><a href='http://leeing.org/2010/06/30/peersim-turtorial-analyse-of-cycle-based-model/' rel='bookmark' title='Permanent Link: PeerSim 中文教程：解析 Cycle-based 模式仿真'>PeerSim 中文教程：解析 Cycle-based 模式仿真</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2010/07/02/peersim-turtorial-how-to-write-a-new-protocol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PeerSim 中文教程：解析 Cycle-based 模式仿真</title>
		<link>http://leeing.org/2010/06/30/peersim-turtorial-analyse-of-cycle-based-model/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://leeing.org/2010/06/30/peersim-turtorial-analyse-of-cycle-based-model/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 08:33:50 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[PeerSim]]></category>
		<category><![CDATA[P2P]]></category>

		<guid isPermaLink="false">http://leeing.org/?p=574</guid>
		<description><![CDATA[本文介绍了PeerSim的基本概念，并解析了两个示例以更清晰地说明PeeSim的仿真流程。 Peersim支持两种仿真模式，即Cycle-based的模型和传统的event-based的模型，本文专注于前者， Cycle-based模型是一个简化的模型，拥有更好的伸缩性及性能，在拥有4GB内存的情况下，event-driven模式目前最多支持十万节点级别，而cycle-based模式则支持千万个节点级别。 但是Cycle-based模型缺少对传输层的仿真和并行处理，节点之间是直接通信的，仿真核心以一定的顺序周期性地给以节点控制。在运行时，可以进行任意的操作，如调用其它对象的方法并执行一些计算。 Cycle-based模型损失了一些真实性，虽然一些简单的协议可以忽略这些差别，但是在选择使用这个模型时，需要注意这些区别。我们可以相对简单地将Cycle-based的仿真移植到Event-driven引擎上，但在本文中不讨论这个话题。 一．基本介绍 PeerSim鼓励基于接口的模块化编程，每一个组件都能被其它实现了相同接口的组件代替，一般的仿真过程如下： 选择网络大小（即节点数量）。 选择要实验的一个或多个协议并进行初始化。 选择一个或多个Control对象来监视感兴趣的属性，并在仿真时修改一些参数（比如，网络大小，协议的内部状态，等等）。 根据配置文件，调用Simulator类运行仿真。 在仿真时创建的对象都是实现了一个或多个接口的类的实例，主要的接口如下所示： Node P2P网络是由节点组成的，节点是协议的容器。Node接口提供了对节点所包含的协议的访问方法，并为节点提供了固定的ID。 CDProtocol 这是一个特定的协议，被设计用来在Cycle-based模型中运行，它只定义了在每一个周期中要运行的操作。 Linkable 一般都由协议来实现，这个接口为其它协议提供了访问邻居节点集合的服务，节点间相同的linkable协议类的实例定义了一个覆盖网络。 Control 实现了这个接口的类可以在仿真期间的某个时间点调度执行，这些类一般用于观察或修改仿真过程。 Cycle-based仿真的生命周期是这样的： 读取配置文件（通过命令行参数传递进来），然后仿真器初始化网络中的节点和节点中的协议，每个节点都拥有相同的协议栈。节点和协议的实例是通过克隆来创建的，只有一个原型是通过构造方法创建，其它的节点和协议都是从这个原型中克隆而来。基于这个原因，协议类中clone方法的实现是很重要的。 初始化操作，设置每个协议的初始状态。初始化阶段是由Control对象控制运行的，仅在实验开始时运行一次。在配置文件中，初始化的组件可以由init前缀识别，在下面讨论的initializer对象也是controls，但为了标记其功能以区别于一般的Control对象，它被配置用来在初始阶段运行。 在初始化完成后，Cycle-based引擎在每一个周期中调用所有组件（protocols和controls）一次，直到完成了指定的周期数，或者某个组件决定终止仿真为止。在PeerSim中每一个对象（controls和protocols）都被赋以一个Scheduler对象，它定义了什么时候本组件将会被执行。在默认情况下，所有对象都会在每个周期中运行。但我们也可以配置一个protocol或control只在某些特定的周期中运行，也可以在每一个周期中指定组件的执行顺序。 下图展示了对controls和protocols的调度，其中C代表Control而P代表一个协议。图下方的数字代表PeerSim的周期，在最后一个周期后，可以运行一个control来获取最后的快照（snapshot）。 在一个Control收集数据时，数据将会被格式化并发送到标准输出或重定向到一个文件以进行后续的处理。 配置文件只是一个普通的ASCII文本，本质上就是java.util.Properties，以#开头的行代表注释。 用以下的方式在命令行的模式下运行，比如： java -cp peersim.Simulator config-edexample.txt 具体来说，可能是： java -cp D:\library\peersim-1.0.5\jep-2.3.0.jar;D:\library\peersim-1.0.5\djep-1.0.0.jar;D:\library\peersim-1.0.5\peersim-1.0.5.jar;D:\library\peersim-1.0.5\peersim-doclet.jar peersim.Simulator D:\library\peersim-1.0.5\example\config-edexample.txt 当然你的jar包和配置文件的位置可能有所不同，也可以将这个jar包直接加到 classpath上，就不必使用-cp参数来显示指定classpath。 二．配置文件示例一 Gossip-based Aggregation协议，Aggregation是聚集的意思，这里是指对一个分布于网络中的数值集合运行一个特定的函数进行计算（如求平均数，最大值，最小值等等），每个节点周期性地选择一个邻居节点进行通讯（基于覆盖网），并且在每次通讯时，基于前一个取得的近似值，相互更新它们下次计算的近似值。 本例将创建一个由50000个节点组成的固定P2P随机拓扑，选定的协议是使用average函数的Aggregation协议，每个节点中用于求平均的值使用一个区间在(0,100)的线性分布来初始化，最后再定义一个Control监视平均值。 # PEERSIM EXAMPLE 1 random.seed 1234567890 simulation.cycles 30 control.shf Shuffle network.size [...]


Related posts:<ol><li><a href='http://leeing.org/2010/07/04/peersim-tutorial-example-of-event-driven-model/' rel='bookmark' title='Permanent Link: PeerSim 中文教程：Event-driven 模型'>PeerSim 中文教程：Event-driven 模型</a></li>
<li><a href='http://leeing.org/2010/07/02/peersim-turtorial-topology-generator/' rel='bookmark' title='Permanent Link: PeerSim 中文教程：拓扑生成器'>PeerSim 中文教程：拓扑生成器</a></li>
<li><a href='http://leeing.org/2010/07/02/peersim-turtorial-how-to-write-a-new-protocol/' rel='bookmark' title='Permanent Link: PeerSim 中文教程：编写一个新协议'>PeerSim 中文教程：编写一个新协议</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2010/06/30/peersim-turtorial-analyse-of-cycle-based-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>随笔</title>
		<link>http://leeing.org/2010/06/20/be-gentle/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://leeing.org/2010/06/20/be-gentle/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 12:40:20 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[朝花夕拾]]></category>

		<guid isPermaLink="false">http://leeing.org/?p=555</guid>
		<description><![CDATA[每次都是想说很多话，却每次都无从下笔。 刚刚看了一篇日志，一字一句地，看了好多好多遍，也想了好久好久。 在漫漫的人生之中，不免留下许多遗憾，那些错过的，失去的，常常令人难以释怀。一句说错的话，足以改变人生的轨迹。无论再怎么认真地去挽留，都已经找不到来时的路。许多曾在自己心里最珍重的东西，蓦然回首，却发现是如水中月镜中花，显得那么的虚幻与不真实。 人生之中，没有如果，失去就不再来。随着时光的流逝，可能有些等待不能太漫长，最初的触动与感伤，都已经渐渐地枯萎在心里。窗边的晚风吹拂着我的脸颊，也同样扰乱着我的思绪，日复一日，渐渐地习惯了这种平凡而单调的日子，可心中的梦想，未曾忘记。 保持一种从容的心态，不喜欢刻意地去追求什么，一切顺其自然。莫愁前路无知己， 天下谁人不识君。 人生如梦，缘起缘灭。时光若白驹过隙，待黎明初起，浓雾散尽，生活还会继续。 No related posts.


No related posts.]]></description>
		<wfw:commentRss>http://leeing.org/2010/06/20/be-gentle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://www.lmgz.net/admin/uploadfile/5.mp3" length="4721305" type="audio/mpeg" />
<enclosure url="http://xamqd.cn/mp3/1.mp3" length="6248234" type="audio/mpeg" />
		</item>
		<item>
		<title>用户访问行为，齐普夫分布及其 Java 实现</title>
		<link>http://leeing.org/2010/05/18/user-behavior-zipf-distribution-and-java-implementation/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://leeing.org/2010/05/18/user-behavior-zipf-distribution-and-java-implementation/#comments</comments>
		<pubDate>Tue, 18 May 2010 08:47:02 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[CDN]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[Zipf distribution]]></category>

		<guid isPermaLink="false">http://leeing.org/?p=541</guid>
		<description><![CDATA[Zipf定律是文献计量学的重要定律之一，它和罗特卡定律、布拉德福定律一起被并称为文献计量学的三大定律。 对于CDN的内容管理，也近似符合Zipf 定律，就是大家常说对于内容的访问遵循80/20原则，也就是20%的内容，会占有80%的访问量。 这里 r 表示一个单词的出现频率的排名，P(r)表示排名为r的单词的出现频率. (单词频率分布中 C约等于0.1, a约等于1) 后人将这个分布称为zipf distribution，中文名称为齐普夫分布或Zeta 分布。这是一个离散事件分布，广泛应用于语言学，保险学，网络模拟，以及对稀疏事件的建模中。 它表明在英语单词中,只有极少数的词被经常使用,而绝大多数词很少被使用。实际上,包括汉语在内的许多国家的语言都有这种特点。这个定律后来在很多领域得到了同样的验证，包括网站的访问者数量、城镇的大小和每个国家公司的数量。。这个定理也在很多分布里面得到了验证，比如人们的收入，互联网的网站数量和访问比例，互联网内容和访问比例(其他分布两个常数有所不同,a越大，分布越密集,对于VOD来说某些时候符合双zipf分布)。 比起枯燥的公式，图表更具有说服力，下面是用三百个严格符合zipf 分布的数据点描绘成的图，其中横轴表示排名，纵轴表示访问的频率，分别使用线性坐标和对数坐标表示： 可以看到对数坐标下是一条完美的直线。 在很多网页的用户访问行为中，都是近似于zipf 分布的，例如下表是www.sun.com 在1996 年7月的页面访问情况： zipf 定律也可以用于其它领域，例如下面的表格的横轴表示城市的人口排名的对数值，而纵轴则是人口数量的对数值。 编程实现：Mathematica，R，还有Java都有相应的API，在这里，主要讨论Java。 在模拟用户的访问请求时，可以近似地使用zipf 定律， Apache Foundation 的commons-math 项目提供了一个Java实现： 在org.apache.commons.math.distribution 包中的类： ZipfDistributionImpl(int numberOfElements, double exponent) Create a new Zipf distribution with the given number of elements and exponent. 它提供的方法主要有： double cumulativeProbability(int x) 概率密度函数：P(X &#60;= x) 的值。 [...]


Related posts:<ol><li><a href='http://leeing.org/2010/01/17/java-constructor/' rel='bookmark' title='Permanent Link: Java 的构造方法'>Java 的构造方法</a></li>
<li><a href='http://leeing.org/2010/01/17/java-%e7%9a%84%e5%bc%95%e7%94%a8%e4%bc%a0%e9%80%92/' rel='bookmark' title='Permanent Link: Java 的引用传递'>Java 的引用传递</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2010/05/18/user-behavior-zipf-distribution-and-java-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Netbeans 性能调优及加速</title>
		<link>http://leeing.org/2010/05/05/improve-the-performance-of-netbeans/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://leeing.org/2010/05/05/improve-the-performance-of-netbeans/#comments</comments>
		<pubDate>Wed, 05 May 2010 13:31:45 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://leeing.org/?p=536</guid>
		<description><![CDATA[NetBeans  安装目录下的 netbeans.conf  文件中的 netbeans_default_options  能够对 NetBeans 的启动，运行以及编译的速度产生很大的影响，恰当地设值可以让 NetBeans 的性能有大幅提升，当然如果设置的值过高也能导致 NetBeans 无法启动。 我的内存是 2GB 的，netbeans_default-options 设置为以下的参数，运行速度很快，在这里做个备份供以后参考。 netbeans_default_options="-J-Dfile.encoding=UTF-8 -J-XX:PermSize=128m -J-XX:MaxPermSize=256m -J-Xmx1024m -J-Duser.language=en -J-client -J-Xverify:none -J-Xss2m -J-Xms512m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled" Related posts:Netbeans 6.8 字体设置


Related posts:<ol><li><a href='http://leeing.org/2010/03/24/netbeans-6-8-font-configuration/' rel='bookmark' title='Permanent Link: Netbeans 6.8 字体设置'>Netbeans 6.8 字体设置</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2010/05/05/improve-the-performance-of-netbeans/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Swing : 将 System.out 重定向到 JTextArea 和 JTextPane</title>
		<link>http://leeing.org/2010/04/30/swing-redirecting-system-out-and-system-err-to-jtextpane-or-jtextarea/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://leeing.org/2010/04/30/swing-redirecting-system-out-and-system-err-to-jtextpane-or-jtextarea/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 10:47:30 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Swing]]></category>

		<guid isPermaLink="false">http://leeing.org/?p=531</guid>
		<description><![CDATA[最近在用Swing 来编写图形用户界面，其中一个需求就是将System.out.println 的输出重定向到JTextArea组件中，刚开始使用的是《Java 标准输出重定向到GUI 》里的代码，但是在后台需要大量计算的时候，界面出现无响应的情况。后来又经过一番搜索，在 blogspot 找到了一篇文章: 《 Redirecting System.out and System.err to JTextPane or JTextArea》 ( 被墙了)，可以实现实时输出的功能，不会出现缓慢的情况。 在 Swing 中，如果想将System.out和System.err 重定向到 JTextPane或者JTextArea，只需要覆盖OutputStream中的write() 方法来将文件附加到 text pane中。 JTextArea 版本： private void updateTextArea(final String text) { SwingUtilities.invokeLater(new Runnable() { public void run() { textArea.append(text); } }); } private void redirectSystemStreams() { OutputStream out = new OutputStream() { @Override [...]


Related posts:<ol><li><a href='http://leeing.org/2010/01/17/java-constructor/' rel='bookmark' title='Permanent Link: Java 的构造方法'>Java 的构造方法</a></li>
<li><a href='http://leeing.org/2010/01/17/java-%e7%9a%84%e5%bc%95%e7%94%a8%e4%bc%a0%e9%80%92/' rel='bookmark' title='Permanent Link: Java 的引用传递'>Java 的引用传递</a></li>
<li><a href='http://leeing.org/2010/01/31/struct-vs-class-in-cpp/' rel='bookmark' title='Permanent Link: C++ 中 struct 和 class 的联系和区别'>C++ 中 struct 和 class 的联系和区别</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2010/04/30/swing-redirecting-system-out-and-system-err-to-jtextpane-or-jtextarea/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scala : &#8220;运算符&#8221; 重载</title>
		<link>http://leeing.org/2010/04/26/scala-operator-override/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://leeing.org/2010/04/26/scala-operator-override/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 15:45:46 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://leeing.org/?p=529</guid>
		<description><![CDATA[运算符带了双引号，这是因为从技术上来说，Scala 并没有所谓的“运算符”,在这里是指重载符号,如+ ,+- 等等。 在 Scala 中,事实上这些是方法的名字。但是由于 Scala 并不需要点来分隔对象引用和方法名,因而看起来像是运算符。调用 ref1+ref2 其实与 ref1.+(ref2)是等同的,调用的其实是 ref1 的+()方法。 举例如下: class Complex(val real: Int, val imaginary: Int) { def +(operand: Complex) : Complex = { new Complex(real + operand.real, imaginary + operand.imaginary) } override def toString() : String = { real + (if (imaginary &#60; 0) "" else "+") + [...]


Related posts:<ol><li><a href='http://leeing.org/2010/04/20/scala-functions-and-parameters/' rel='bookmark' title='Permanent Link: Scala : Functions and Parameters'>Scala : Functions and Parameters</a></li>
<li><a href='http://leeing.org/2010/04/21/scala-partial-functions-and-type-parameters/' rel='bookmark' title='Permanent Link: Scala : Partial Functions 和 Type Parameters'>Scala : Partial Functions 和 Type Parameters</a></li>
<li><a href='http://leeing.org/2010/04/25/scala-variables-in-scope-containers/' rel='bookmark' title='Permanent Link: Scala : 作用域中的变量，容器'>Scala : 作用域中的变量，容器</a></li>
<li><a href='http://leeing.org/2010/04/18/scala-option-and-foldleft/' rel='bookmark' title='Permanent Link: Scala : Option 和 foldLeft'>Scala : Option 和 foldLeft</a></li>
<li><a href='http://leeing.org/2010/04/26/scala-interactive-application-and-functional-composition/' rel='bookmark' title='Permanent Link: Scala : 交互式应用程序，函数组合'>Scala : 交互式应用程序，函数组合</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2010/04/26/scala-operator-override/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
