Book Review of “The practice of programming” (Ⅲ)

The practice of programming


Chapter 3 Design and Implementation

In this section, we focus on one kind problem: generate random English text that reads well.

The solution is called 'The Markov Chain Algorithm', and its main idea is shown as follows:

  First we scan an article and save it in a special chart. For example, we use two adjacent words as prefix, by searching which we can get all the possible following words. We use 'hashtable', 'list', 'vector' to realize this function. The details are left out.

  Then we are to generate a paragraph based on the data above. The first several words are picked up randomly. And each time, we choose one of its suffix randomly. To ensure the random in just one scanning, we use a stractage, that is, 'use a variable "n" to count the current number of suffixes, use a string to save the previous chosen suffix. each time the present suffix can replace the previous suffix by the possibilition 1/n. When the scan is over, the suffix chosen is determined.'

  Last, to limit to total length of the generated paragraph, we add a symbol of ending to each prefix's map. Also, use a variable to count to total length we have generated.

The book introduce the solving programs in C, JAVA, C++, Awk, Perl. Their different realizations are all anchored in the same main idea. By comparison, we can found that C has the longest code lines and the highest efficience. Awk and Perl are the easiest. The quickest is C, then is Perl. Their adjustence is also different. If the number of prefix is changed, C, C++, Java is easy to modefy, while Perl and Awk are not.

 

转载于:https://www.cnblogs.com/Christen/p/5024777.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
《为什么的书》是由两位计算机科学家、哲学家和统计学家精心创作的一本解释因果关系的经典畅销书。这本书是研究因果关系和机器学习的先驱之一,将深入浅出的解释为什么因果关系是人工智能和机器学习的核心,并且将因果关系对社会科学、生物学、医学和多个其他领域的影响进行了详细的描述。 这本书的主要思想是教人们如何理解因果关系。作者将透过实际的例子,向读者说明研究因果关系的重要性,以及出现因果冲突时该如何解决。因为在许多情况下,人们并不能清楚地判断某些事件之间仅仅是相关关系还是因果关系,这就导致了许多误解和错误的结论,从而影响到了整个社会。 书中的方法论将有助于读者进行正确的思考和正确的决策。还提出了“反因果”的概念,即反向思考事物的原因,从而更好地理解问题。 此外,《为什么的书》还告诫我们,不能因为人工智能的发展而忽略或放弃因果关系研究,因为人类对因果关系的理解将会影响到我们对未来的预测和规划。同时,因果关系的研究不仅会对人工智能领域有所助益,也会对社会、生物学、医学等领域产生极大的影响。 总之,《为什么的书》给我们带来了关于因果关系的深刻洞见,以及如何正确判断因果关系的方法,并且将因果关系的重要性对我们日常生活和未来的发展进行了强调。在人工智能和机器学习的时代,这本书提出了非常重要的因果关系理论。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值