zoukankan      html  css  js  c++  java
  • latex算法排版 Lei

    下给出使用latex进行算法排版的几个例子,以供参考:

    \documentclass{article}

    \usepackage[english]{babel}

    \usepackage{blindtext}

    \usepackage{algorithm} %format of the algorithm

    \usepackage{algorithmic} %format of the algorithm

    <?xml:namespace prefix = o /> 

    \begin{document}

    \blindtext

    \begin{algorithm}[htb] %算法的开始

    \renewcommand{\algorithmicrequire}{\textbf{Input:}}

    \renewcommand\algorithmicensure {\textbf{Output:} }

    \caption{ Framework of ensemble learning for our system.} %算法的标题

    \label{alg:Framwork} %给算法一个标签,这样方便在文中对算法的引用

    \begin{algorithmic}[1] %这个1 表示每一行都显示数字

    \REQUIRE ~~\\ %算法的输入参数:Input

    The set of positive samples for current batch, $P_n$;\\

    The set of unlabelled samples for current batch, $U_n$;\\

    Ensemble of classifiers on former batches, $E_{n-1}$;

    \ENSURE ~~\\ %算法的输出:Output

    Ensemble of classifiers on the current batch, $E_n$;\\

    \STATE Extracting the set of reliable negative and/or positive samples $T_n$ from $U_n$ with help of $P_n$; label{code:fram:extract} %算法的一个陈述,对应算法的一个步骤或公式之类的; label{ code:fram:extract }对此行的标记,方便在文中引用算法的某个步骤

    \STATE Training ensemble of classifiers $E$ on $T_n cup P_n$, with help of data in former batches; label{code:fram:trainbase}

    \STATE $E_n=E_{n-1}cup E$; label{code:fram:add}

    \STATE Classifying samples in $U_n-T_n$ by $E_n$; label{code:fram:classify}

    \STATE Deleting some weak classifiers in $E_n$ so as to keep the capacity of $E_n$; label{code:fram:select}

    \RETURN $E_n$; %算法的返回值

    \end{algorithmic}

    \end{algorithm}

    \blindtext

    \end{document}

    =====

    2.

    \documentclass{article}

    \usepackage[english]{babel}

    \usepackage{blindtext}

    \usepackage{algorithm} %format of the algorithm

    \usepackage{algorithmic} %format of the algorithm

    \begin{document}

    \blindtext

    \begin{algorithm}[h]

    \caption{An example for format For While Loop in Algorithm}

    \begin{algorithmic}[1]

    \FOR{each $iin [1,9]$}

    \STATE initialize a tree $T_{i}$ with only a leaf (the root);\

    \STATE $T_{i};$\

    \ENDFOR

    \FOR{$i=1$; $i<n$; $i++$ }

    \STATE $//$ Your source here;

    \ENDFOR

    \WHILE {$(|E_n| leq L_1 )and(Deq phi)$}

    \STATE Selecting the most recent classifier $c_i$ from $D$;

    \STATE $D=D-c_i$;

    \STATE $E_n=E_n+c_i$;

    \ENDWHILE \label{code:recentEnd}

    \end{algorithmic}

    \end{algorithm}

    \blindtext

    \end{document}

    ===========



     转:http://hi.baidu.com/chong_jing/item/1e6a9832c05bf0352f0f817f

  • 相关阅读:
    iOS9 News 应用
    swift中,Optional、?与!之间的关系
    [翻译] CotEditor
    [book] iOS 8 Swift Programming Cookbook
    便利的操作plist文件
    消除 Xcode7 中 directory not found for option 'xxxx' 警告
    点击单个cell高度变化的动画效果
    [翻译] LiquidFloatingActionButton
    一脸懵逼学习Zookeeper(动物园管理员)---》高度可靠的分布式协调服务
    一脸懵逼学习基于CentOs的Hadoop集群安装与配置(三台机器跑集群)
  • 原文地址:https://www.cnblogs.com/guolei/p/3082066.html
Copyright © 2011-2022 走看看