Skip to content

Instantly share code, notes, and snippets.

@yanping
Last active December 16, 2015 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanping/5350975 to your computer and use it in GitHub Desktop.
Save yanping/5350975 to your computer and use it in GitHub Desktop.
使用pandoc从md编译成beamer

文件列表

  • cos.beamer.tex 模板文件
  • demo.md 演示文件

编译命令为

pandoc -t beamer --template=cos.beamer.tex --latex-engine=xelatex -Vurl:1 -V theme:CambridgeUS -V colortheme:dolphin  -V shorttitle:COS  demo.md  -o demo.pdf

如果要添加目录

pandoc -t beamer --template=cos.beamer.tex --latex-engine=xelatex --toc -Vurl:1 -V theme:CambridgeUS -V colortheme:dolphin  -V shorttitle:COS  demo.md  -o demo.pdf
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(handout)$handout,$endif$$if(beamer)$ignorenonframetext,$endif$]{$documentclass$}
$if(theme)$
\usetheme{$theme$}
$endif$
$if(colortheme)$
\usecolortheme{$colortheme$}
$endif$
\usepackage{amssymb,amsmath}
\usepackage[boldfont,slantfont,CJKsetspaces,CJKchecksingle]{xeCJK}
\newcommand{\hurl}[1]{\href{#1}{\color{blue}#1}} %自定义的命令
\usepackage{ifxetex,ifluatex}
\ifxetex
\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\setCJKmainfont{文泉驿微米黑}
\setCJKsansfont{Kaiti}
\setCJKmonofont{SimSun}
\punctstyle{quanjiao}
\else
\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\else
\usepackage[utf8]{inputenc}
\fi
\fi
$if(natbib)$
\usepackage{natbib}
\bibliographystyle{plainnat}
$endif$
$if(biblatex)$
\usepackage{biblatex}
$if(biblio-files)$
\bibliography{$biblio-files$}
$endif$
$endif$
$if(listings)$
\usepackage{listings}
$endif$
$if(lhs)$
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
$endif$
$if(highlighting-macros)$
$highlighting-macros$
$endif$
$if(verbatim-in-note)$
\usepackage{fancyvrb}
$endif$
$if(fancy-enums)$
% Redefine labelwidth for lists; otherwise, the enumerate package will cause
% markers to extend beyond the left margin.
% \makeatletter\AtBeginDocument{%
% \renewcommand{\@listi}
% {\setlength{\labelwidth}{4em}}
% }\makeatother
\usepackage{enumerate}
$endif$
$if(tables)$
\usepackage{ctable}
\usepackage{float} % provides the H option for float placement
$endif$
$if(url)$
\usepackage{url}
$endif$
$if(graphics)$
\usepackage{graphicx}
$endif$
% Comment these out if you don't want a slide with just the
% part/section/subsection/subsubsection title:
\AtBeginPart{\frame{\partpage}}
\AtBeginSection{\frame{\sectionpage}}
\AtBeginSubsection{\frame{\subsectionpage}}
\AtBeginSubsubsection{\frame{\subsubsectionpage}}
$if(strikeout)$
\usepackage[normalem]{ulem}
% avoid problems with \sout in headers with hyperref:
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
$endif$
$if(subscript)$
\newcommand{\textsubscr}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}}
$endif$
% \setlength{\parindent}{0pt}
% \setlength{\parskip}{6pt plus 2pt minus 1pt}
% \setlength{\emergencystretch}{3em} % prevent overfull lines
$if(numbersections)$
$else$
\setcounter{secnumdepth}{0}
$endif$
$if(verbatim-in-note)$
\VerbatimFootnotes % allows verbatim text in footnotes
$endif$
$if(lang)$
\usepackage[$lang$]{babel}
$endif$
$for(header-includes)$
$header-includes$
$endfor$
$if(title)$
$if(shorttitle)$
\title[$shorttitle$]{$title$}
$else$
\title{$title$}
$endif$
$endif$
$if(author)$
\author{$for(author)$$author$$sep$ \and $endfor$}
$endif$
$if(date)$
\date{$date$}
$endif$
\institute[统计之都]{
统计之都\\
\hurl{http://cos.name}
}
\setbeamertemplate{navigation symbols}{}
\begin{document}
$if(title)$
\frame{\titlepage}
$endif$
$for(include-before)$
$include-before$
$endfor$
$if(toc)$
\begin{frame}
\tableofcontents[hideallsubsections]
\end{frame}
$endif$
$body$
$if(natbib)$
$if(biblio-files)$
$if(biblio-title)$
$if(book-class)$
\renewcommand\bibname{$biblio-title$}
$else$
\renewcommand\refname{$biblio-title$}
$endif$
$endif$
\bibliography{$biblio-files$}
$endif$
$endif$
$if(biblatex)$
\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
$endif$
$for(include-after)$
$include-after$
$endfor$
\end{document}

% R语言春令营 % \href{mailto:chen@yanping.me}{陈堰平} % April 14, 2013

R的安装

Reproducibility

  • Same script
  • Same results
  • Anywhere
    • Single thread
    • Multi-core
    • Cloud Scale

Everything starts with a seed.

Simulation is based off Pseudo-random number generation (PRNG).

  • PRNG is sequential, next number depends on the last state.
  • Seeds are used to store the state of a random number generator
  • by 'Setting a seed' one can place a PRNG into any exact state.

Parallel Random Number Generation

Simulation is complicated in new parallel environments.

  • PRNG is sequential,
  • parallel execution is not,
  • and order of execution is not guaranteed.
Right Left Default Center
12 12 12 12
123 123 123 123
1 1 1 1

: Demonstration of simple table syntax.

This is where parallel pseudo-random number generators help out.

Parallel PRNG

Parallel pseudo-random number generators start with a singe state that can spawn additional streams as well as streams of random numbers.

  1. SPRNG
  2. L'Ecuyer combined multiple-recursive generator

Centered Default Right Left Header Aligned Aligned Aligned


First row 12.0 Example of a row that spans multiple lines.

Second row 5.0 Here's another one. Note the blank line between rows.

Table: Here's the caption.

R包的使用

R package harvestr

https://github.com/halpo/harvestr

What harvestr does:

  • Reproducibility
  • Caching
  • Under parallelized environments.

How harvestr works

  • Analytical elements are separated into work-flows of dependent elements.
    • Set up environment/seed
    • Generate Data
    • Perform analysis
      • Stochastic
      • Non-Stochastic
    • Summarize
  • Results from one step carry to another by carrying the seed with the results.

Primary work-flow for harvestr

  • gather(n) - generate n random number streams.
  • farm(seeds, expr) - evaluate expr with each seed in seeds.
  • harvest(x, fun) - for each data in x call the function fun

数据管理

Building blocks

Some building blocks that might might be helpful.

  • plant- for setting up copies of an object with given seeds.
  • sprout - for obtaining the sub-streams used with graft.
  • reap - single object version of harvest

In case you are wondering

  • Yes it works with Rcpp code,
  • provided the compiled code uses the RNGScope for RNG in C++.
  • But take care to not carry C++ reference objects across parallel calls.
seeds <- gather(10, seed=20120614)
data <- farm(seeds, {
x1 <- rnorm(400)
x2 <- rnorm(400)
g <- rep(rnorm(4), each=100)
trt <- rep(1:4, each=100)
y <- rnorm(n=400, mean=3*x1 + x2 + g)
data.frame(y, x1, x2, trt)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment