Site icon R-bloggers

\STATE [algorithmic package]

[This article was first published on Xi'an's Og » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I fought with my LαTεX compiler this morning as it did not want to deal with my code:

 \begin{algorithmic}[1]
 \STATE N=1000
 \STATE $\hat\pi=0$
 \FOR {I=1,N}
 \STATE X=RDN(1), Y=RDN(1)
 \IF {$\text{X}^2+\text{Y}^2<1$}
 $\hat\pi$ = $\hat\pi +1$
 \ENDIF
 \ENDFOR
 \RETURN 4*$\hat\pi/$N
 \end{algorithmic}
 

looking on forums for incompatibilities between beamer and algorithmic, and adding all kinds of packages, to no avail. Until I realised one \STATE was missing:

 \begin{algorithmic}[1]
 \STATE N=1000
 \STATE $\hat\pi=0$
 \FOR {I=1,N}
 \STATE X=RDN(1), Y=RDN(1)
 \IF {$\text{X}^2+\text{Y}^2<1$}
 \STATE $\hat\pi$ = $\hat\pi +1$
 \ENDIF
 \ENDFOR
 \RETURN 4*$\hat\pi/$N
 \end{algorithmic}
 

(This is connected with my AMSI public lecture on simulation, obviously!)


Filed under: Books, Kids, pictures, R, Statistics, Travel, University life Tagged: algorithmic, AMSI, Australia, Beamer, high school mathematics, LaTeX, Monte Carlo Statistical Methods, pi, R, simulation

To leave a comment for the author, please follow the link and comment on their blog: Xi'an's Og » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.