您的位置:首页 > 其它

简洁清爽的LaTeX论文模板

2016-03-20 23:42 543 查看
英文版本如下:

\documentclass[a4paper, 11pt]{article} % Font size (can be 10pt, 11pt or 12pt) and paper size (remove a4paper for US letter paper)

\usepackage[protrusion=true,expansion=true]{microtype} % Better typography
\usepackage{graphicx} % Required for including pictures
\usepackage{wrapfig} % Allows in-line images

\usepackage{mathpazo} % Use the Palatino font
\usepackage[T1]{fontenc} % Required for accented characters
\linespread{1.05} % Change line spacing here, Palatino benefits from a slight increase by default

\makeatletter
\renewcommand\@biblabel[1]{\textbf{#1.}} % Change the square brackets for each bibliography item from '[1]' to '1.'
\renewcommand{\@listI}{\itemsep=0pt} % Reduce the space between items in the itemize and enumerate environments and the bibliography

\renewcommand{\maketitle}{ % Customize the title - do not edit title and author name here, see the TITLE block below
\begin{flushright} % Right align
{\LARGE\@title} % Increase the font size of the title

\vspace{50pt} % Some vertical space between the title and author name

{\large\@author} % Author name
\\\@date % Date

\vspace{40pt} % Some vertical space between the author block and abstract
\end{flushright}
}

%----------------------------------------------------------------------------------------
% TITLE
%----------------------------------------------------------------------------------------

\title{\textbf{TTTTTTThe Title}\\ % Title
Subtitle} % Subtitle

\author{\textsc{Your name here} % Author
\\{\textit{University}}} % Institution

\date{\today} % Date

%----------------------------------------------------------------------------------------

\begin{document}

\maketitle % Print the title section

%----------------------------------------------------------------------------------------
% ABSTRACT AND KEYWORDS
%----------------------------------------------------------------------------------------

%\renewcommand{\abstractname}{Summary} % Uncomment to change the name of the abstract to something else

\begin{abstract}
Abstract
\end{abstract}

\hspace*{3,6mm}\textit{Keywords:} lorem , ipsum , dolor , sit amet , lectus % Keywords

\vspace{30pt} % Some vertical space between the abstract and first section

%----------------------------------------------------------------------------------------
% ESSAY BODY
%----------------------------------------------------------------------------------------

\section*{Introduction}

Introduction

%------------------------------------------------

\section*{Section Name}

This is a random string: l8asbnd 09098i3j9ih ln,903 b 02pj lknbsab dkhgfk das8f9 o3 nhb3ro9 80980-t342i icp2sdajl foa8wl347r 89023q4r5 32q2wsfdtv t2t4w53daWEFZEVETEG45q32wsq3aSQD
\begin{wrapfigure}{l}{0.4\textwidth} % Inline image example
\begin{center}
\includegraphics[width=0.38\textwidth]{fish.png}
\end{center}
\caption{Fish}
\end{wrapfigure}
awuelifhlrwiuhf ilahgflkhgbndwedfgbndesaofplikeswdf,gl;easwfvck.b.laws/hih frhnliwaohyryftilohwas.hyfyoitw.lalylotfti.ilwatfih

Morbi tempor congue porta. Proin semper, leo vitae faucibus dictum, metus mauris lacinia lorem, ac congue leo felis eu turpis. Sed nec nunc pellentesque, gravida eros at, porttitor ipsum. Praesent consequat urna a lacus lobortis ultrices eget ac metus. In tempus hendrerit rhoncus. Mauris dignissim turpis id sollicitudin lacinia. Praesent libero tellus, fringilla nec ullamcorper at, ultrices id nulla. Phasellus placerat a tellus a malesuada.

%------------------------------------------------

\section*{Conclusion}

Conclusion

\begin{enumerate}
\item First numbered list item
\item Second numbered list item
\end{enumerate}

aaaaaaaaaaaaaaaaa

%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY
%----------------------------------------------------------------------------------------

\bibliographystyle{unsrt}

\bibliography{sample}

%----------------------------------------------------------------------------------------

\end{document}
效果如下:



可以进行一些额外的设定,使之支持中文(无摘要版本):
\documentclass[a4paper, 11pt]{article}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage{graphicx}
\usepackage{wrapfig}

\usepackage{CJKutf8}
\usepackage{graphicx}
\usepackage[unicode]{hyperref}
\usepackage{xcolor}
\usepackage{cite}
\usepackage{indentfirst}
\usepackage{listings}
\usepackage{amsmath}
\usepackage{ulem}
%\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}

%\usepackage{mathpazo}
\usepackage[T1]{fontenc}
\linespread{1.05}

\makeatletter

\newcommand{\chuhao}{\fontsize{42pt}{\baselineskip}\selectfont}
\newcommand{\xiaochuhao}{\fontsize{36
cced
pt}{\baselineskip}\selectfont}
\newcommand{\yihao}{\fontsize{28pt}{\baselineskip}\selectfont}
\newcommand{\erhao}{\fontsize{21pt}{\baselineskip}\selectfont}
\newcommand{\xiaoerhao}{\fontsize{18pt}{\baselineskip}\selectfont}
\newcommand{\sanhao}{\fontsize{15.75pt}{\baselineskip}\selectfont}
\newcommand{\sihao}{\fontsize{14pt}{\baselineskip}\selectfont}
\newcommand{\xiaosihao}{\fontsize{12pt}{\baselineskip}\selectfont}
\newcommand{\wuhao}{\fontsize{10.5pt}{\baselineskip}\selectfont}
\newcommand{\xiaowuhao}{\fontsize{9pt}{\baselineskip}\selectfont}
\newcommand{\liuhao}{\fontsize{7.875pt}{\baselineskip}\selectfont}
\newcommand{\qihao}{\fontsize{5.25pt}{\baselineskip}\selectfont}

\renewcommand\@biblabel[1]{\textbf{#1.}}
\renewcommand{\@listI}{\itemsep=0pt}
\renewcommand{\maketitle}{
\begin{flushright}
{\LARGE\@title}
\vspace{50pt}
{\large\@author}
\\\@date

\vspace{40pt}
\end{flushright}
}

\title{\centering{\textbf{数学建模第三次作业}}\\[2ex]
\sihao ——元胞自动机仿真与灵敏度分析\\}

\author{名字}

\date{\today} % Date

%----------------------------------------------------------------------------------------

\begin{document}
\begin{CJK}{UTF8}{gbsn}

\lstset{ %
extendedchars=false, % Shutdown no-ASCII compatible
language=Matlab, % choose the language of the code
basicstyle=\normalsize\tt, % the size of the fonts that are used for the code
tabsize=3, % sets default tabsize to 3 spaces
numbers=left, % where to put the line-numbers
numberstyle=\small, % the size of the fonts that are used for the line-numbers
stepnumber=1, % the step between two line-numbers. If it's 1 each line
% will be numbered
numbersep=5pt, % how far the line-numbers are from the code %
keywordstyle=\color[rgb]{0,0,1}, % keywords
commentstyle=\color[rgb]{0.133,0.545,0.133}, % comments
stringstyle=\color[rgb]{0.627,0.126,0.941}, % strings
backgroundcolor=\color{white}, % choose the background color. You must add \usepackage{color}
showspaces=false, % show spaces adding particular underscores
showstringspaces=false, % underline spaces within strings
showtabs=false, % show tabs within strings adding particular underscores
frame=single, % adds a frame around the code
captionpos=b, % sets the caption-position to bottom
breaklines=true, % sets automatic line breaking
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
title=\lstname, % show the filename of files included with \lstinputlisting;
% also try caption instead of title
mathescape=true,escapechar=? % escape to latex with ?..?
escapeinside={\%*}{*)}, % if you want to add a comment within your code
%columns=fixed, % nice spacing
%morestring=[m]', % strings
%morekeywords={%,...},% % if you want to add more keywords to the set
% break,case,catch,continue,elseif,else,end,for,function,global,%
% if,otherwise,persistent,return,switch,try,while,...},%
}

\maketitle

\section{元胞自动机仿真模拟}

\begin{enumerate}
\item \textbf{一间封闭的空房间, 一个人在里面随意移动。}
\\[2ex]
由于人在每一步都会从上下左右四个方向随机选择一个移动一格,故可以建立一格四元向量组来表示四个方向,并用$1\sim 4$的整数做下标来实现随机移动。如此模拟即可模拟人的运动。
\par 用\texttt{Matlab}实现该思路的代码如下:
\lstinputlisting{empty_room.m}

\par 其中\texttt{C}是表示房间状态的矩阵,\texttt{m}表示循环次数。
\par \texttt{C([1 22],:)=1;}~ 表示四周的墙壁。
\par \texttt{dir=[0 1;0 -1;-1 0;1 0];}~ 是代表人行走方向的四个方向向量。
\par \texttt{C(InPos(1),InPos(2))=1;}~ 表示初始状态下人的位置。
\par 人从起点开始,每一步都随机选取四个方向之一(对方向向量的下标取一个$1\sim4$的随机数即可)前进一步并进行一次判定:判定将要到达的格子是否合法。如不合法(走到墙上),则重新选取方向再走。
\par 在\texttt{Matlab}中运行该函数,设定步数为5步(人在走5步后会停止):
\texttt{>~> empty\_room(5)}
\par 输出结果如下:

\begin{figure}[!hbp]
\begin{center}
\includegraphics[scale=0.2]{a.png}
\includegraphics[scale=0.2]{b.png}
\includegraphics[scale=0.2]{c.png}
\includegraphics[scale=0.2]{d.png}
\includegraphics[scale=0.2]{e.png}
\end{center}
\end{figure}

\item \textbf{一间有门的空房间, 一个人沿着最短路径移动到门口。}
\\[2ex]
由于房间内是空的,所以人走到门的最短路径长度即为人的初始位置到门位置的哈密顿距离。所以人只需要先走到门所在的行,在沿该行走到门所在位置即可。
\par 用\texttt{Matlab}实现该模型的代码如下:
\lstinputlisting{empty_room_shortest.m}

\par 在\texttt{Matlab}中运行该函数,设定步数为50步(人在走10步后会停止):
\texttt{>~> empty\_room\-shortest}
\par 输出结果如下:

\begin{figure}[!hbp]
\begin{center}
\includegraphics[scale=0.25]{aa.png}
\includegraphics[scale=0.25]{bb.png}
\includegraphics[scale=0.25]{cc.png}
\includegraphics[scale=0.25]{dd.png}
\\
\includegraphics[scale=0.25]{ee.png}
\includegraphics[scale=0.25]{ff.png}
\includegraphics[scale=0.25]{gg.png}
\includegraphics[scale=0.25]{hh.png}
\\
\includegraphics[scale=0.25]{ii.png}
\includegraphics[scale=0.25]{jj.png}
\includegraphics[scale=0.25]{kk.png}
\includegraphics[scale=0.25]{ll.png}
\end{center}
\end{figure}

\item \textbf{一间有门的教室, 且教室里有桌椅, 一个人沿最短路径移动到门口。}
\\[2ex]
由于教室内的桌椅和讲台都是均匀摆放,故教室内部的路可以视作一个长方形组成的网格,于是人只需要保证走的每一步都使得自己到门的哈密顿距离减小即可。
\par 不妨假设门的位置为$(3,1)$,如下图所示:
\begin{center}
\includegraphics[scale=0.5]{1.png}
\end{center}
\par 则人只需要向左和向上/下移动。即人只需要在能向上/下走时优先向上/下走,不能向上走时优先向左走即可。
\par 利用\texttt{Matlab}实现该思路的代码如下:
\lstinputlisting{shortest_with_obstacle.m}

\par 运行结果如下:

\begin{figure}[!hbp]
\begin{center}
\includegraphics[scale=0.2]{2.png}
\includegraphics[scale=0.2]{3.png}
\includegraphics[scale=0.2]{4.png}
\includegraphics[scale=0.2]{5.png}
\\
\includegraphics[scale=0.2]{6.png}
\includegraphics[scale=0.2]{7.png}
\includegraphics[scale=0.2]{8.png}
\includegraphics[scale=0.2]{9.png}
\\
\includegraphics[scale=0.2]{10.png}
\includegraphics[scale=0.2]{11.png}
\includegraphics[scale=0.2]{12.png}
\includegraphics[scale=0.2]{13.png}
\end{center}
\end{figure}

\item \textbf{如果房间有一个出口,一个人在里面随意移动,仿真计算他移动到出口的可能性和所需要的平均时间 。}
\\[2ex]
要利用仿真讨论人到达门口的概率和平均时间,可以通过多次重复仿真,查看是否都能得到结果并分析所得到的结果来实现。
\par 考虑一个有门的空教室,人从初始位置出发,在教室中随机行走,人走到门所在的位置,程序就停止模拟。则可以运行程序,模拟100次人走到门口,统计每次所用的步数并观察程序是否能得到运行结果。
\par 用\texttt{Matlab}实现该思路的代码如下:
\lstinputlisting{get_out_the_room.m}

\par 在\texttt{Matlab}中运行该程序模拟100次:\\
\texttt{>\ > get\_out\_the\_room(100)}
\par 得到了100组步数的值,从小到大排列如下:
\begin{center}
\begin{table}[!hbp]
\begin{center}

\begin{tabular}{|c c c c c c c c c c|}

\hline
14 & 18 & 26 & 26 & 42 & 42 & 46 & 46 & 50 & 54 \\
\hline
56 & 58 & 60 & 60 & 70 & 72 & 74 & 84 & 88 & 94 \\
\hline
94 & 102 & 104 & 106 & 110 & 116 & 128 & 130 & 132 & 140 \\
\hline
146 & 160 & 162 & 164 & 172 & 196 & 216 & 222 & 232 & 246 \\
\hline
248 & 250 & 256 & 260 & 260 & 264 & 274 & 278 & 288 & 300 \\
\hline
304 & 306 & 310 & 320 & 334 & 338 & 342 & 350 & 354 & 356 \\
\hline
372 & 376 & 382 & 390 & 398 & 408 & 440 & 450 & 466 & 468 \\
\hline
484 & 546 & 558 & 578 & 596 & 596 & 612 & 628 & 642 & 646 \\
\hline
690 & 696 & 704 & 712 & 770 & 788 & 798 & 806 & 810 & 818 \\
\hline
876 & 882 & 890 & 952 & 1140 & 1158 & 1358 & 1488 & 1898 & 2424 \\
\hline

\end{tabular}
\end{center}

\end{table}
\end{center}
\par 处理数据的\texttt{C++}代码如下:
\lstset{language=c++}
\lstinputlisting{data.cpp}
\lstset{language=Matlab}

\par 由于100组数据全部得到了最终结果,即100组数据中,人全部达到了出口,故可以认为人在该房间中有$100\%$的概率,或说有很大概率能够走到出口。
\par 以上数据均是在$12\times 8$的房间中仿真得到的。将房间规模改变为$15\times 10$之后,分别进行10次仿真,仍然全部得到了结果,结果如下:
\begin{center}
\begin{table}[!hbp]
\begin{center}
\begin{tabular}{|c|c c c c c c c c c c|}
\hline
15*10 & 562 & 110 & 1962 & 226 & 818 & 1646 & 540 & 626 & 598 & 2028 \\ \hline
18*12 & 1892 & 810 & 2774 & 989 & 690 & 3701 & 1977 & 1203 & 745 & 3653 \\ \hline
21*14 & 4809 & 1996 & 2046 & 983 & 2359 & 4932 & 3498 & 2789 & 1568 & 3028 \\ \hline
\end{tabular}
\end{center}
\end{table}
\end{center}
\par 由两个表格中的数据可以看出,随着房间规模的增大,步数有着明显的增加。于是可以猜想,到达出口的步数期望为无穷大。
\par 考虑一个无限大的平面,人在平面上移动。若可证明在该平面上人能到达任何一点,即可证明人在封闭房间内可到达任意一点。
\par 仍然考虑一个二维的四元向量组,分别表示上下左右四个方向,人从起点开始随机行走,走到门所在的位置(不妨假设是$(5,5)$),就停止并输出当前步数。同时设定步数上限,如果在规定步数内不能到达将强行停止循环,以完成对步数的讨论。
\par 用\texttt{C++}实现该思路的代码如下:
\lstset{language=C++}
\lstinputlisting{simulate.cpp}
\par 在代码中,用\texttt{num\_of\_cases}表示测试组数,即模拟次数,
\texttt{max\_step}表示最大步数,即步数的上限。通过改变这两个常数的值,即可对概率和步数进行讨论。返回的结果中,\texttt{cnt}表示走到门所在位置的组数,\texttt{aver\_step}表示走到门的平均步数,\texttt{possbility}表示在所有组数中,走到门口的频率。
\par 运行结果统计如下:
\begin{center}
\begin{table}[!hbp]
\begin{center}
\begin{tabular}{cc|ccc}
\hline
num of cases & max step & cnt & average step & possibility \\
\hline
1000000 & 10 & 0 & \sout{NaN} & 0.000\\
100000 & 100 & 8892 & 51.49 & 0.089\\
10000 & 1000 & 3036 & 296.84 & 0.304\\
1000 & 10000 & 435 & 1478.23 & 0.435\\
100 & 100000 & 47 & 8436.64 & 0.470\\
10 & 1000000 & 9 & 35862.44 & 0.900\\
\hline

\end{tabular}
\end{center}
\end{table}
\end{center}

\par 从表中数据可以看出,随着步数上限的提高,概率和步数的增长都很快,故可以认为:在不限制步数的情况下,人一定能够走到门的位置,但是所用步数的期望为无穷大。

\par 以下证明该结论:
\par 不失一般性,假设人的位置为$(0,0)$,门的位置为$(a,b)$,则人到达门所用的步数一定为$a+b+2n$。其中$a,b,n$均为整数。
\par 则问题可以简化为如下等价问题:
\par 人从$(a,b)$出发,经过$2n$步回到$(a,b)$。
\par 于是该问题等价于求解如下问题:
\par 人从$(0,0)$出发,每一步都随机向四个方向之一走一步,求这个人最终能回到起点的概率,并求步数期望。
\par 由于人用不超过$2n$步回到起点,故人可以在$2k,1\leq k\leq n$的任意一个$k$时回到起点。对于$k$,人要在$2k$步时恰好回到起点,等价于人往上走的步数等于往下走的步数,往左走的步数等于往右走的步数。
\par 以下讨论恰好在$2k$步走回起点的概率:由于向上走的步数与向左走的步数之和等于向下走的步数与向右走的步数之和,故其值均为$k$。于是可以枚举向上走的步数$1\leq i\leq k$再对$i$求和,可得在$2k$步恰好走回起点的概率为:

\begin{align*}
q_k~ &= ~ \frac{\sum\limits_{i=1}^{k}\binom{2k}{i}\binom{2k-i}{i}\binom{2k-2i}{k-i}}{4^{2k}}\\
&= ~ \frac{\sum\limits_{i=1}^{k}\frac{(2k)!}{i!(2k-i)!}\times \frac{(2k-i)!}{i!(2k-2i)!}\frac{(2k-2i)!}{((k-i)!)^2}}{16^k}\\
&= ~ \frac{\sum\limits_{i=1}^{k}\frac{(2k)!}{(i!)^2\times ((k-i)!)^2}}{16^k}
\end{align*}

\par 于是用不超过$2n$步走回起点的概率为:

\begin{align*}
P_n~ &= ~ \sum\limits_{k=1}^{n} q_k\\
&= ~ \sum\limits_{k=1}^{n}\frac{\sum\limits_{i=1}^{k}\frac{(2k)!}{(i!)^2\times ((k-i)!)^2}}{16^k}
\end{align*}

\par 故在不限定步数的情况下,人不断行走,最终走回起点的概率为:
\begin{align*}
p~ &= ~ \lim\limits_{n\rightarrow\infty}P_n\\
&= ~ \lim\limits_{n\rightarrow\infty} \sum\limits_{k=1}^{n}\frac{\sum\limits_{i=1}^{k}\frac{(2k)!}{(i!)^2\times ((k-i)!)^2}}{16^k}
\end{align*}
\par 由Stirling公式,有:
\begin{align*}
p~ &= ~ \lim\limits_{n\rightarrow\infty}P_n\\
&= ~ \lim\limits_{n\rightarrow\infty} \sum\limits_{k=1}^{n}\frac{\sum\limits_{i=1}^{k}\frac{\sqrt{2\pi \times 2k}(\frac{2k}{e})^{2k}}{(\sqrt{2\pi i}(\frac{i}{e})^{i})^2\times (\sqrt{2\pi (k-i)}(\frac{k-i}{e})^{k-i})^2}}{16^k}\\
&= ~ \lim\limits_{n\rightarrow\infty} \sum\limits_{k=1}^{n}\frac{\sum\limits_{i=1}^{k}\frac{\sqrt{k\pi }(\frac{2k}{e})^{2k}}{2\pi^2 i(k-i)(\frac{i}{e})^{2i} (\frac{k-i}{e})^{2(k-i)}}}{16^k}\\
&= ~ \lim\limits_{n\rightarrow\infty} \sum\limits_{k=1}^{n}\frac{\sum\limits_{i=1}^{k}\frac{\sqrt{k\pi }k^{2k}\times 4^k}{2\pi^2 i^{2i+1} (k-i)^{2(k-i)+1}}}{4^{2k}}\\
&= ~ \lim\limits_{n\rightarrow\infty} \sum\limits_{k=1}^{n}(\sqrt{k\pi }(\frac{k}{2})^{2k}\times\sum\limits_{i=1}^{k}\frac{1}{2\pi^2 i^{2i+1} (k-i)^{2(k-i)+1}})\\
&= ~ 1
\end{align*}

\par 对于步数期望,由于对于任意确定的$n$,人在$n$步之内回到起点的概率$P_n$都有$P_n<1$,故人回到起点的步数期望为$+\infty$。
\par 综上所述,人在有门的房间内随机走动,到达门的概率是$1$,平均时间为$+\infty$。
\end{enumerate}

\section{灵敏度分析}

\bibliographystyle{unsrt}

\bibliography{sample}

\end{CJK}
\end{document}

效果如图:



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: