Categories
读书有感

Constitutional Law by Yale 听课笔记(三)

宪法修正过程。

第一次大的修正称之为Bill of Rights, 1791年通过。后面的修正案大都集中在某一段时间。

Bill of Rights 修正案1-12 十八世纪末十九世纪初

Civil War Amendments/Reconstruction Amendments 修正案13-15 十九世纪中期,civil war后

The Progressive Era Amendments 修正案16-18  二十世纪初

详细的列表在这里:http://en.wikipedia.org/wiki/List_of_amendments_to_the_United_States_Constitution

Bill of Rights主要的诉求是:

The Bill of Rights enumerates freedoms not explicitly indicated in the main body of the Constitution, such as freedom of religion, freedom of speech, a free press, and free assembly; the right to keep and bear arms; freedom from unreasonable search and seizure, security in personal effects, and freedom from warrants issued without probable cause; indictment by a grand jury for any capital or "infamous crime"; guarantee of a speedy, public trial with an impartial jury; and prohibition of double jeopardy. In addition, the Bill of Rights reserves for the people any rights not specifically mentioned in the Constitution and reserves all powers not specifically granted to the federal government to the people or the States.

Civil War Amendments主要是告别奴隶制度:

Their proponents saw them as transforming the United States from a country that was (in Abraham Lincoln's words) "half slave and half free" to one in which the constitutionally guaranteed "blessings of liberty" would be extended to the entire populace, including the former slaves and their descendants.

Progressive Era Amendments更多是现代化的标志:

The Sixteenth Amendment gave the federal government the power to lay and collect an income tax regardless of the source of that income.

The Seventeenth Amendment provided for the direct election of Senators by the people rather than by the state legislatures as the original Constitution called for.

The Eighteenth Amendment prohibited the import, export, transport, manufacture or sale of intoxicating beverages.

The Nineteenth Amendment gave women the right to vote.

最有趣的就是妇女投票权了。毕竟是需要男人们投票来决定妇女有权投票。一开始是从稀缺妇女的 Wyoming Territory州开始,然后扩展到全国。

最后的二战后的修正则主要是一些对于民主的更深入理解,比如总统任期的限制。

Categories
网络新发现

最新的一些经济学研究趋势...

今天闲着无聊抓了一下NBER最近一年的working paper数据看看。众所周知,econ现在发表周期越来越长,一两年都算少的,三五年也挺常见的。虽然跟跟AER什么的也是个比较好的指向,但多少还是“旧”了一点。

NBER覆盖的研究范围还是蛮广的,大部分发表的paper都能在这里找到working paper版本,所以一时没想到更好的抓数据的来源:

Aging(AG)
Asset Pricing(AP)
Children(CH)
Corporate Finance(CF)
Development Economics(DEV)
Development of the American Economy(DAE)
Economics of Education(ED)
Economic Fluctuations and Growth(EFG)
Environmental and Energy Economics (EEE)
Health Care(HC)
Health Economics(HE)
Industrial Organization(IO)
International Finance and Macroeconomics(IFM)
International Trade and Investment(ITI)
Labor Studies(LS)
Law and Economics(LE)
Monetary Economics(ME)
Political Economy(POL)
Productivity, Innovation, and Entrepreneurship Program(PR)
Public Economics(PE)

抓了一番之后,基本关键词热度如下。一些太没有意义的我就调透明了。(个人很讨厌word cloud这种东西,所以还是选择了bar chart)

[3/19更新] 和Bing里面的key words match了一下。貌似信息多了一些。

key_word

虽然数目不代表质量,但至少能看出来有多少人在某个领域耕耘。最突出的就是health这里了,很高(钱很多)。然后还有很多研究trade和growth的。然后risk和finance好像也蛮多的,crisis好像也挺多。Labor和IO一直也是热热的。研究方法上,随机试验还是最亮的。

没有进一步分析那些作者在高产,下次搞个“抱大腿”趋势好了。

代码在这里:

grab_url <- c("http://www.nber.org/new_archive/mar14.html",
              "http://www.nber.org/new_archive/dec13.html",
              "http://www.nber.org/new_archive/sep13.html",
              "http://www.nber.org/new_archive/jun13.html",
              "http://www.nber.org/new_archive/mar13.html")

library(RCurl)
require(XML)

grab_paper <- function (grab) {
  webpage <- getURLContent(grab)
  web_content <- htmlParse(webpage,asText = TRUE)
  paper_title <- sapply(getNodeSet(web_content, path="//li/a[1]"),xmlValue)
  author <- sapply(getNodeSet(web_content, path="//li/text()[1]") ,xmlValue)
  paper_author <- data.frame(paper_title = paper_title, author = author)
  return(paper_author)
}

library(plyr)
paper_all <- ldply(grab_url,grab_paper)

titles <- strsplit(as.character(paper_all$paper_title),split="[[:space:]|[:punct:]]")
titles <- unlist(titles)

library(tm)
library(SnowballC)
titles_short <- wordStem(titles)
Freq2 <- data.frame(table(titles_short))
Freq2 <- arrange(Freq2, desc(Freq))
Freq2 <- Freq2[nchar(as.character(Freq2$titles_short))>3,]
Freq2 <- subset(Freq2, !titles_short %in% stopwords("SMART"))
Freq2$word <- reorder(Freq2$titles_short,X = nrow(Freq2) - 1:nrow(Freq2))
Freq2$common <- Freq2$word %in% c("Evidenc","Effect","Econom","Impact","Experiment","Model","Measur","Rate","Economi",
                                  "High","Data","Long","Chang","Great","Estimat","Outcom","Program","Analysi","Busi"
                                  ,"Learn","More","What")
library(ggplot2)
ggplot(Freq2[1:100,])+geom_bar(aes(x=word,y=Freq,fill = common,alpha=!common))+coord_flip()

### get some keywords from Bing academic
start_id_Set = (0:5)*100+1
require(RCurl)
require(XML)
# start_id =1
# 

get_keywords_table <- function (start_id) {
  end_id = start_id+100-1
  keyword_url <- paste0("http://academic.research.microsoft.com/RankList?entitytype=8&topDomainID=7&subDomainID=0&last=0&start=",start_id,"&end=",end_id)
  keyword_page <- getURLContent(keyword_url)
  keyword_page <- htmlParse(keyword_page,asText = TRUE)
  keyword_table <- getNodeSet(keyword_page, path="id('ctl00_MainContent_divRankList')//table")
  table_df <- readHTMLTable(keyword_table[[1]])
  names(table_df) <- c("rowid","Keywords"   ,  "Publications" ,"Citations")
  return (table_df)
}

require(plyr)
keywords_set <- ldply(start_id_Set,get_keywords_table)

save(keywords_set, file="keywords_set.rdata")

最后更新的部分代码。效率偏低,见谅。

### map keywords
load("keywords_set.rdata")
load("NBER.rdata")
keys <- strsplit(as.character(keywords_set$Keywords), split=" ")
require(SnowballC)
keys_Stem <- lapply(keys,wordStem)

#get edges 
edge_Set <- data.frame()
for (word in Freq2$word){
#   print(word)
  for (key_id in 1:length(keys_Stem)){
#     print(keys_Stem[[key_id]])
    if (word %in% keys_Stem[[key_id]]) {
      edge <- data.frame(keywords = keywords_set[key_id,]$Keywords, kid = word)
      edge_Set <- rbind(edge_Set,edge)}
  }
}

#edge_Set
require(ggplot2)
kid_freq <- as.data.frame(table(edge_Set$kid))
require(plyr)
kid_freq <- arrange(kid_freq, desc(Freq))

edge_Set_sub <- subset(edge_Set, kid %in% Freq2[1:100,]$word)
edge_Set_sub$keywords <- as.character(edge_Set_sub$keywords)
# edge_Set_sub$kid <- as.character(edge_Set_sub$kid)

link_keys <- function(x) {paste(x$keywords,collapse = ", ")}

linked <- ddply(edge_Set_sub, .(kid), link_keys)

show_keys <- merge(Freq2[1:100,],linked, by.x="word",by.y="kid", all.x=T)
names(show_keys)[5] <- "linked"

ggplot(show_keys[!is.na(show_keys$linked),],aes(x=word,y=Freq))+
  geom_bar(aes(fill = common,alpha=!common),stat="identity",ymin=10)+coord_flip()+
  geom_text(aes(label=substr(linked,1,200),y = Freq, size = 1),hjust=0)

 

Categories
读书有感

读大学读什么?

最近一直在想这个问题:花费了那么多时间读书,究竟读了一些什么?

知识这东西,但凡肯花时间,大部分都是能学会的。应付考试什么的就更不是特别难的事情了。

可是成绩单上满满的,都是知识、知识。让人看起来都觉得疲倦。

除了知识,上学的时候还学会了什么?更多是培养性情?养成一颗好奇心,养成探索事物的兴趣,广泛的接纳各个领域的思维冲击。说起来工作了之后,太多东西都是可以现用现学的,没有什么那么困难的。

前段时间在看美国LAC(Liberal Arts College)的教育模式,培养精英的气质。因为有幸接触过一些top LAC出来的精英,确实气质上稍胜一筹。

A "liberal arts" institution can be defined as a "college or university curriculum aimed at imparting broad general knowledge and developing general intellectual capacities, in contrast to a professional, vocational, or technical curriculum."

越往后走,这种积淀的力量越能超越知识课程什么的,支撑着前行。而我的大学,确实缺少这样的时间。被无辜的填了太多鸭,被GPA逼得去竞争分数,缺少了太多太多思考的广度和深度。而那些知识,考过了试,又有多少受用至今?了了。

说回语言。学西班牙语的时候,很多人说,拉丁语系学两门以上,其他的就都很容易了。现在深以为然——计算机语言也是如此。R和Matlab用的熟了,加上C和PHP的一些基础,现在去看Python真的没什么难度。估计去学Java也不会花太多功夫。

我曾经试图说服无数周围的人,数学也是一门语言(统计学不是,它是一种思维方式,可以用多种语言表述),学了那么多公式什么的表达的其实是人们对于逻辑推理的极致追求。看似复杂高深的课程,其实大都还是可以,读书百变、其意自现的。

想到这里就说到这里。是的,我是在有些可惜那些匆匆错过的时光。

Categories
读书有感

python小试

今天非常无聊的决定去试一下python。找了一个题,大意如下:

  • 给定一个输入字符串,找出最漂亮的无重复子字符串。
  • 子字符串:从原字符串中减掉某些字符可得到的。
  • 无重复字符串:没有重复的字符
  • 甲比乙漂亮:甲的长度>乙,或者甲的字典排序在乙之后。

因为都是无重复的,所以肯定不需要甲的长度大于乙,故而是所有长度一样的无重复子字符串中,找出字典排序最大的。

这个先用R写的,为的是写出一个有效的算法来。基本的思路就是强行的逐层递归。

x = 'nlhthgrfdnnlprjtecpdrthigjoqdejsfkasoctjijaoebqlrgaiakfsbljmpibkidjsrtkgrdnqsknbarpabgokbsrfhmeklrle'

x_split = strsplit(x,split="")[[1]]
unique_x = unique(x_split) 
unique_x_order = sort(unique_x,decreasing=T) 
x_remain = character() 

# find the largest character than can be remained

#initialize
current_string = x_split
current_unique = unique_x
current_order = unique_x_order
while ( length(x_remain) < 20) 
{ 
  for(i in 1:length(current_order))
  { character = current_order[i]
    index = which(current_string == character)
    sub_string = current_string[min(index):length(current_string)]  
    if (length(setdiff(unique(current_string),unique(sub_string)))==0) #no lose of characters
    {x_remain = c(x_remain,character);
     current_string = current_string[-c(1:min(index),index)];
     current_unique = unique(current_string);
     current_order = sort(current_unique,decreasing=T);
     break;
    }
  }
}

#answer is 'tsocrpkijgdqnbafhmle'

后面用python重写了一遍。基本就是等价函数的替换...我是不是在暴殄天物的利用python?完全不理解program on the fly的感觉...

x = 'nlhthgrfdnnlprjtecpdrthigjoqdejsfkasoctjijaoebqlrgaiakfsbljmpibkidjsrtkgrdnqsknbarpabgokbsrfhmeklrle';
x_split = list(x);
unique_x = list(set(x_split));
unique_x.sort(reverse=True)
x_remain = list();
###initialize
current_string = x_split;current_unique = unique_x;current_order = unique_x;
while len(x_remain) < len(unique_x):
	for character in current_order:
		index = current_string.index(character);
		sub_string = current_string[index:len(current_string)];
		#print(character);
		if (len(set(current_string)-set(sub_string))==0): #no lose of characters
			x_remain.append(character);
			for i in range(sub_string.count(character)):
				sub_string.remove(character);
			current_string= sub_string;
			current_unique = list(set(current_string));
			current_unique.sort(reverse=True);
			current_order = current_unique;
			break;
print(x_remain);

最后好不容易写完python之后,发现网断了...没法在线提交了。等重新连上,时间已经过了,sigh。就当周末无聊历练一下了。

Categories
我的生活状态

美好的时光是忙碌中有闲暇可打发

人生经历过或快或慢的一些节奏。读master的那年还是比较忙碌的,很多deadline赶很多paper要写,但也觉得蛮开心的。一方面是做着自己喜欢做的事情,可以专心的泡在图书馆里一个人傻傻的兴奋或发狂;另一方面,也是巴塞罗那这座城市给了人一些生活的情调。每月一日的免费博物馆日,骑车十分钟可到的音乐厅画廊,随便走走小巷子里面的手工艺品店,还有穿梭在居民区内的甜点和酒窖珍藏。和同学们研究一下分布在校园不同角落的自动咖啡机哪个更好喝,周末顺便去海滩上懒懒的晒太阳。对的,这样的调剂让人不觉得忙碌是可怕的。略有闲暇,无数的方案可以打发。

工作的第一年经常很忙,忙到记忆都有些中断。然而那样的忙碌却单单是忙碌,因为一旦闲下来只想窝在家里睡过去。完全没有精力调节生活的情调。上海的艺术氛围远不如它金碧辉煌的购物广场,走来走去的文艺青年捧本线装书就在地铁上傲然。太不随性,太过于符号化。在纸醉金迷的城市里,看不到年轻人的美好梦想。走进过一家又一家咖啡馆,只觉得小资书吧和星巴克连锁也没有什么气质上的两样。我嗅不到自由的味道。对我这种物质欲尚远不如口腹之欲的人来说,在这个城市活得多少有些麻木和迷茫了。我需要新的目标,来忙碌,来折腾。

死得轰轰烈烈,也比活得行尸走肉强。期待,破茧。
7-31-12-spongilla-fly-cocoon-img_7739图片来自naturallycuriouswithmaryholland