LaTex插入algorthim

LaTex插入algorthimhttp www cnblogs com piags archive 2012 11 06 2757683 html 插入算法 参照 http www ctex org documents packages verbatim index htm 中的 algorithms 章节 下面举例说明需要注意的几点 代码范例 begin algorithm

大家好,我是讯享网,很高兴认识大家。

http://www.cnblogs.com/piags/archive/2012/11/06/2757683.html
插入算法
参照 http://www.ctex.org/documents/packages/verbatim/index.htm 中的algorithms章节,下面举例说明需要注意的几点


讯享网

代码范例

\begin{algorithm}
\caption{PB-KNN Algorithm}
\label{alg_PB-KNN}
\algblock[Name]{Begin}{End}
\begin{algorithmic}[1]
\scriptsize
\Require DataSet $D$, parameters $k$,$n$
\Ensure outliers set $OutSet$
\Begin
\State Classify and pre-pruning, get $D=\{D_1,D_2,\cdots,D_n\}$
\State Sort subsets and clusters,get $C=\{C_1,C_2,C_3,C_4\}$
\ForAll {cluster $C_i\in C$}
\ForAll {data $p\in C_i$}
\State Inti $Neig(p)$
\ForAll {data $q\in  C_i$ \textbf{and} $q\neq p$}
        \If {$Avg_D(q)+\mathrm{distance}(p,q)\leq OutValue$}
        \State data $p$ is not an outlier, \textbf{break}
        \EndIf
        \If {$Avg_D(p)\leq OutValue$ \textbf{and} $|Neig(p)|=q$}
        \State data $p$ is not an outlier, \textbf{break}
        \EndIf
        \If {$\text{distance}(p,q) \leq
             \text{Maxdistance}(p,Neig(p))$}
        \State Update $Neig(p)$ by $q$
        \EndIf
        \If {$Avg_D(p)> OutValue$}
        \State Update $OutSet$ by $p$
        \EndIf
        \If {$|OutSet|=n$}
        \State Update $OutValue$ by $\text{Min}(OutSet)$
        \EndIf   
\EndFor
    \EndFor
\EndFor    
\State \textbf{return} $OutSet$
\End
\end{algorithmic}
\end{algorithm}
小讯
上一篇 2025-03-01 18:26
下一篇 2025-01-28 07:00

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/99406.html