2013年1月18日

摘要: V1. 默认字符编码为utf8,打开使用gb2312编码的文件,中文全为乱码,如何恢复正常显示?输入 edit ++enc=cp936V2. 如何在vim系统中执行命令?输入 !cmdV3. 使用vim直接打开并编辑.*gz文件,而无须解压,读取,编辑,再压缩.压缩文件的支持是通过pluginvim ls-lrR.txt.gzV4. 如何Vim支持语法加亮?一劳永逸的方法,在~/.vimrc中增加如下语句syntax on临时性的方法, 输入命令:syntax onV5. Vim如何在结构文档中快速切换,比如 C语言{ }块之间切换.输入在{}之间,输入%即可V6. 如何让Vim记下我的编辑状 阅读全文
posted @ 2013-01-18 00:28 rongyilin 阅读(159) 评论(0) 推荐(0) 编辑

2013年1月4日

摘要: http://code.activestate.com/recipes/413086-gibbs-sampler/The gibbs sampler is an iterative conditional sampler from multidimensional probability density functions (PDFs). The resulting sample is plotted as a scatter plot with the Matplotlib module.## {{{ http://code.activestate.com/recipes/413086/ ( 阅读全文
posted @ 2013-01-04 17:21 rongyilin 阅读(581) 评论(0) 推荐(0) 编辑
摘要: http://code.activestate.com/recipes/414200-metropolis-hastings-sampler/The Metropolis-Hastings Sampler is the most common Markov-Chain-Monte-Carlo (MCMC) algorithm used to sample from arbitrary probability density functions (PDF). Suppose you want to simulate samples from a random variable which can 阅读全文
posted @ 2013-01-04 17:10 rongyilin 阅读(663) 评论(0) 推荐(0) 编辑

2013年1月1日

摘要: 1 # -*- coding: utf-8 -*- 2 import datetime, calendar, time 3 from collections import namedtuple 4 5 def create_logger(filename="file.log"): 6 def logger(info): 7 now = datetime.datetime.today() 8 time_str = now.strftime('%H:%M:%S: ') 9 f = open(filename, "a")10 ... 阅读全文
posted @ 2013-01-01 14:36 rongyilin 阅读(1488) 评论(0) 推荐(0) 编辑
摘要: python中时间日期格式化符号:%y 两位数的年份表示(00-99)%Y 四位数的年份表示(000-9999)%m 月份(01-12)%d 月内中的一天(0-31)%H 24小时制小时数(0-23)%I 12小时制小时数(01-12)%M 分钟数(00=59)%S 秒(00-59)%a 本地简化星期名称%A 本地完整星期名称%b 本地简化的月份名称%B 本地完整的月份名称%c 本地相应的日期表示和时间表示%j 年内的一天(001-366)%p 本地A.M.或P.M.的等价符%U 一年中的星期数(00-53)星期天为星期的开始%w 星期(0-6),星期天为星期的开始%W 一年中的星期数(00- 阅读全文
posted @ 2013-01-01 13:12 rongyilin 阅读(235) 评论(0) 推荐(0) 编辑

2012年12月30日

摘要: 1 ## {{{ http://code.activestate.com/recipes/577361/ (r1) 2 import collections 3 class peekable(object): 4 """ An iterator that supports a peek operation. 5 6 this is a merge of example 19.18 of python cookbook part 2, peek ahead more steps 7 and the simpler example 16.7, w... 阅读全文
posted @ 2012-12-30 16:38 rongyilin 阅读(213) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*-def merge(*sequences): import heapq heap = [(seq[0],seq) for seq in sequences] heapq.heapify(heap) while heap: x, seq = heapq.heappop(heap) yield seq.pop(0) if seq: heapq.heappush(heap, (seq[0], seq))A = [[1,2,3,4], [5,6,8], [1,3,5,... 阅读全文
posted @ 2012-12-30 16:05 rongyilin 阅读(483) 评论(0) 推荐(0) 编辑

2012年12月27日

摘要: http://zhukunguang.blog.163.com/blog/static/214307201201211484523831/KKT条件是非线性规划的重要成果之一,把拉格朗日乘子理论关于等式约束极值问题扩展到了等式约束和不等式约束的情形。考虑以下约束条件下的非线性优化问题:\begin{align}\min & f(x),\: x\in E^{n}\label{eq:prob1}\\s.t. & g_{i}(x)\le0,\: i=1,2,\cdots,m\nonumber \\ & h_{j}(x)=0,\: j=1,2,\cdots,p\nonumber 阅读全文
posted @ 2012-12-27 18:30 rongyilin 阅读(428) 评论(0) 推荐(0) 编辑
摘要: head 及tail 命令介绍当需要查看一个文本文件的头部或尾部时,head 命令及tail 命令可以非常方便的完成该操作。head 命令用于查看一个文本文件的开头部分;而tail 命令则用于显示文本文件的末尾几行。这两个命令举例如下:head example.txt 显示文件 example.txt 的前十行内容;head -n 20 example.txt 显示文件 example.txt 的前二十行内容;tail example.txt 显示文件 example.txt 的后十行内容;tail -n 20 example.txt 显示文件 example.txt 的后二十行内容;tail 阅读全文
posted @ 2012-12-27 10:56 rongyilin 阅读(101) 评论(0) 推荐(0) 编辑

2012年12月26日

摘要: 在线广告的核心计算问题定义:设$\mathcal{A}$为广告集合,有$T$次浏览行为, $c_{i}$为第$i$次浏览的上下文, $u_{i}$为用户特征, $a_{i}\in\mathcal{A}$为给第$i$次浏览投放的广告. 广告中的计算问题是寻求一组广告展示$a_{1},a_{2},\cdots,a_{T}$, 使得ROI之和最大, 即求\[\{a_{1},\cdots, a_{T}\}^{*}=\underset{a_{1},\cdots,a_{T}\in\mathcal{A}}{\arg\max}\sum_{i=1}^{T}ROI(a_{i},u_{i},c_{i})\]上式中, 阅读全文
posted @ 2012-12-26 23:44 rongyilin 阅读(232) 评论(0) 推荐(0) 编辑

导航