5
\section[Algorithm]{Algorithm}

\begin{frame}[allowframebreaks]
\begin{algorithm}[H]
\begin{algorithmic}[1]

\STATE \emph {Taking a sequence of values $(f_{1} \dotsc
f_{n/2})$, and calculating $pfbm = |fft(fbmn)^2|$ where
\textbf{fbmn} is \begin{equation}(n -
\mu_{n})/\sigma_{n}.\end{equation} next pfbm is ranged in the
scale of 0 to 2$\pi$}.

\STATE \emph {Calculating the spectral
density of FBM using the estimated Hurst Parameter range between
$0<h\_est<1$}.

\STATE \emph {Calculating the intermediate value of $y_f$
as\begin{equation}y_f =
(pfbm/f\_specd)^2.\end{equation}}.\framebreak
 \STATE \emph { Multiply each term of $f_{j}$ with an independent exponential random variable with mean
1 call it $ \hat{f}$}.

\STATE \emph {Calculate the values of A and B as \begin{equation}
A = 2*((2*\pi)/data)*sum(y_f). \end{equation} \begin{equation} B =
2*((2*\pi)/data)*sum(\sqrt(y_f)).
\end{equation}}
\framebreak \STATE \emph {Construct $(z_{1} \dotsc z_{n/2})$, a
sequence of complex numbers such that $ |z_{i}|= \sqrt{ \hat{f}}$
and the phase of $z_{i}$ is uniformly distributed between 0 and
$2\pi$}.

\STATE \emph {Construct $\lbrace z'_{1}
\dotsc z'_{n} \rbrace$ an expanded version of $\lbrace z_{1}
\dotsc z_{n/2} \rbrace$}.

 \STATE \emph {Inverse-Fourier transform
$z'_{i}$ to obtain the approximate FGN sample path $x_{i}$}.

\end{algorithmic}
\caption{Pseudocode for the generation of Trace Using FGN }
\label{alg:seq1}
\end{algorithm}
\end{frame}
2
  • Welcome to TeX.SX! Could you please edit your post a little and add preamble to make it fully compilable example? If you add four spaces at the beginning of each source code line, it would automatically format it for you.
    – Malipivo
    May 17, 2014 at 5:59
  • Please include a few sentences that describe your question/problem (all we have is code).
    – user10274
    May 17, 2014 at 12:53

2 Answers 2

4

You're setting the algorithm within an algorithm (float) environment, and floats cannot be broken midway across a page (or frame) boundary. You can use my suggested nofloatalgorithmic environment (from Algorithm with partial borders/frames) to allow this breaking:

enter image description here

\documentclass{beamer}
\usepackage{algorithm,algcompatible,amsmath,needspace}
\usepackage{lmodern}% https://tex.stackexchange.com/q/58087/5764

\makeatletter
% Taken from https://tex.stackexchange.com/a/178645/5764
\newenvironment{nofloatalgorithmic}[2][0]
  {% \begin{nofloatalgorithmic}
  \par
  %\addvspace{\intextsep}% Vertical gap above in-text float
  \needspace{\dimexpr\baselineskip+6.8pt}%
  \noindent%
  \hrule height.8pt depth0pt \kern2pt% Top horizontal rule
  \refstepcounter{algorithm}% Step algorithm counter
  \addcontentsline{loa}{algorithm}{\numberline{\thealgorithm}#2}% Add entry to LoA
  \noindent\textbf{\fname@algorithm~\thealgorithm} #2\par% Write caption
  \kern2pt\hrule\kern2pt% Middle horizontal rule
  \begin{algorithmic}[#1]
  }
  {% \end{nofloatalgorithmic}
  \end{algorithmic}
  \nobreak\kern2pt\hrule\relax% Bottom horizontal rule
  %\addvspace{\intextsep}% Vertical gap below in-text float
  }
\makeatother

\begin{document}
\section[Algorithm]{Algorithm}

\begin{frame}[allowframebreaks]

  \begin{nofloatalgorithmic}[1]{Pseudocode for the generation of Trace Using FGN\label{alg:seq1}}
    \itshape
    \STATE
    Taking a sequence of values $\bigl( f_{1} \dotsc f_{n/2} \bigr)$, and calculating $\text{pfbm} = 
    |\operatorname{fft}(\textbf{fbmn})^2|$ where \textbf{fbmn} is
    \begin{equation}
      (n - \mu_{n}) / \sigma_{n}
    \end{equation}
    next pfbm is ranged in the scale of~$0$ to~$2\pi$.

    \STATE 
    Calculating the spectral density of FBM using the estimated Hurst Parameter range between $0 < \text{h\_est} < 1$.

    \STATE 
    Calculating the intermediate value of~$y_f$ as
    \begin{equation}
      y_f = \bigl( \text{pfbm}/\text{f\_specd} \bigr)^2.
    \end{equation}

    \framebreak

    \STATE 
    Multiply each term of~$f_{j}$ with an independent exponential random variable with mean $1$ call it~$\hat{f}$.

    \STATE 
    Calculate the values of~$A$ and~$B$ as 
    \begin{align}
      A &= 2 \times \bigl( 2\pi/\text{data} \bigr) \times \sum y_f \\
      B &= 2 \times \bigl( 2\pi/\text{data} \bigr) \times \sum\sqrt{y_f}.
    \end{align}

    \framebreak

    \STATE 
    Construct $\bigl( z_{1} \dotsc z_{n/2} \bigr)$, a sequence of complex numbers such that $\lvert z_{i}\rvert = 
    \sqrt{\hat{f}}$ and the phase of~$z_{i}$ is uniformly distributed between~$0$ and~$2\pi$.

    \STATE 
    Construct $\bigl\{ z'_{1} \dotsc z'_{n} \bigr\}$ an expanded version of $\bigl\{ z_{1} \dotsc z_{n/2} \bigr\}$.

    \STATE 
    Inverse-Fourier transform~$z'_{i}$ to obtain the approximate FGN sample path~$x_{i}$.

  \end{nofloatalgorithmic}
\end{frame}
\end{document}

Here are some suggestions as well:

  • Use lmodern to avoid font-related warnings;
  • Be careful with numbering elements (like equations) in a presentation, since the audience will not be able to keep up with them. The same goes for algorithms. Rather use contextual references that people can relate to as opposed to numbers;
  • For consistency, use the same notation for elements inside and outside math.
3

The easiest solution is not to use the algorithm floating environment provided by the algorithm package (or similar) and define your own environment emulating the beamer definition for figure or table (i.e., using a simple center environment, thus suppressing flotation); this also gives you consistency between the captions for your algorithms and figure or table captions.

The required definition is very simple:

\makeatletter
\newenvironment{algorithm}[1][]{%
  \def\@captype{algorithm}%
  \par\nobreak\begin{center}\nobreak}
  {\par\nobreak\end{center}\nobreak}
\newcounter{algorithm}
\renewcommand\thealgorithm{\@arabic\c@algorithm}
\makeatother

A complete exmaple:

\documentclass{beamer}
\usepackage{algorithmic}

\makeatletter
\newenvironment{algorithm}[1][]{%
  \def\@captype{algorithm}%
  \par\nobreak\begin{center}\nobreak}
  {\par\nobreak\end{center}\nobreak}
\newcounter{algorithm}
\renewcommand\thealgorithm{\@arabic\c@algorithm}
\makeatother

\begin{document}

\begin{frame}[allowframebreaks]

\begin{algorithm}
\begin{algorithmic}[1]
\STATE \emph {Taking a sequence of values $(f_{1} \dotsc
f_{n/2})$, and calculating $pfbm = |fft(fbmn)^2|$ where
\textbf{fbmn} is \begin{equation}(n -
\mu_{n})/\sigma_{n}.\end{equation} next pfbm is ranged in the
scale of 0 to 2$\pi$}.

\STATE \emph {Calculating the spectral
density of FBM using the estimated Hurst Parameter range between
$0<h\_est<1$}.

\STATE \emph {Calculating the intermediate value of $y_f$
as\begin{equation}y_f =
(pfbm/f\_specd)^2.\end{equation}}.\framebreak
 \STATE \emph { Multiply each term of $f_{j}$ with an independent exponential random variable with mean
1 call it $ \hat{f}$}.

\STATE \emph {Calculate the values of A and B as \begin{equation}
A = 2*((2*\pi)/data)*sum(y_f). \end{equation} \begin{equation} B =
2*((2*\pi)/data)*sum(\sqrt(y_f)).
\end{equation}}
\framebreak \STATE \emph {Construct $(z_{1} \dotsc z_{n/2})$, a
sequence of complex numbers such that $ |z_{i}|= \sqrt{ \hat{f}}$
and the phase of $z_{i}$ is uniformly distributed between 0 and
$2\pi$}.

\STATE \emph {Construct $\lbrace z'_{1}
\dotsc z'_{n} \rbrace$ an expanded version of $\lbrace z_{1}
\dotsc z_{n/2} \rbrace$}.

 \STATE \emph {Inverse-Fourier transform
$z'_{i}$ to obtain the approximate FGN sample path $x_{i}$}.

\end{algorithmic}
\caption{Pseudocode for the generation of Trace Using FGN }
\label{alg:seq1}
\end{algorithm}
\end{frame}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .