Skip to content

Instantly share code, notes, and snippets.

引子

先讲一个我亲爱的老师Dr. Jiang都说烂了的例子:兹有理工大学毕业生50名与李嘉诚先生一名,计其平均年收入为...很多很多钱,得出结论,理工大学的毕业生普遍收入非常高。

于是这就是经典的统计数字也会骗人的例子......说实话,这个例子我现在觉得他更像是一个尴尬的冷笑话。

统计学本身就是骗人的,那句著名的谚语"Lies,damn lies,statistics"(谎言,该死的谎言,统计学)无疑是最好的佐证。恰好,我最大的爱好就是一本正经地胡说八道,娓娓道来催人泪下却在心里小人得志般暗暗冷笑。

%(1)
s1=price2ret(StockPrice(:,1));
s2=price2ret(StockPrice(:,2));
s3=price2ret(StockPrice(:,3));
s4=price2ret(StockPrice(:,4));
s5=price2ret(StockPrice(:,5));
@LazyLaker
LazyLaker / HW.R
Created September 6, 2018 04:18
How to did simple spelling-check by R with a given dictionary? With only a line of code
library(stringdist)
library(stringr)
#the mistake txt to be modified
#t1=readLines("/path/file", encoding = "utf-8")
#the dictionary
#t2=readLines("/path/file", encoding = "utf-8")
#the correct list of words
#t3=readLines("/path/file", encoding = "utf-8")
# round_1 of replacement
sapply(t1,FUN=function(x){x=which(adist(t2,x)==min(sapply(t2[which(str_sub(t2, start = 1, end = 1)==str_sub(x, start = 1, end = 1))]
@LazyLaker
LazyLaker / zx.R
Created September 6, 2018 04:24
对小说《诛仙》的文本挖掘
#读入诛仙小说
#zx=readLines("/path/file", encoding = "utf-8")
zx[10:16]
length(zx)
# 读入主角变量
role=readLines("/Users/zc/Downloads/role.txt", encoding = "UTF-8")
role[1:5]
# 组合起来
roles1=paste0("(", gsub(" ", ")|(", role), ")")
main_roles=c("张小凡", "陆雪琪", "碧瑶", "田灵儿", "田不易")