Commit 2d3d08df authored by G. Jay Kerns's avatar G. Jay Kerns

initial commit

parent e0155abc
.juliahistory
*~
ols.jl
winston-examples.jl
File added
#+TITLE: julia-beamer.org
#+AUTHOR: G. Jay Kerns
#+EMAIL: jay@gandalfrodo.no-ip.org
#+DATE: 2013-02-25 Mon
#+OPTIONS: H:2 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [presentation, bigger]
#+BEAMER_THEME: default
#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_act(Act) %4BEAMER_col(Col) %8BEAMER_opt(Opt)
#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.0 :ETC
#+PROPERTY: exports both
#+PROPERTY: results output
#+PROPERTY: session *julia*
#+PROPERTY: tangle yes
* Getting started
#+BEGIN_SRC emacs-lisp :results silent :eval no-export
(load "~/gitm/projects/ob-julia.el")
(org-babel-julia-initiate-session "*julia*" nil)
#+END_SRC
Read the following links.
- http://orgmode.org/worg/exporters/beamer/tutorial.html
- http://orgmode.org/worg/exporters/beamer/ox-beamer.html
- http://orgmode.org/manual/Beamer-class-export.html#Beamer-class-export
Add the following to =.emacs=
#+BEGIN_SRC emacs-lisp :eval never
(require 'ox-beamer)
#+END_SRC
You also need to add the LaTeX class.
#+BEGIN_SRC emacs-lisp :eval never
(add-to-list 'org-latex-classes
'("beamer"
"\\documentclass[presentation]{beamer}
\[DEFAULT-PACKAGES]
\[PACKAGES]
\[EXTRA]"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
#+END_SRC
** Exported title
:PROPERTIES:
:EXPORT_LaTeX_CLASS: beamer
:EXPORT_LaTeX_CLASS_OPTIONS: [presentation,smaller]
:EXPORT_BEAMER_THEME: default
:EXPORT_FILE_NAME: presentation.pdf
:END:
- amsdk
- kdsalk
- adkfa
- jlksa
* This is the first structural section
** Frame 1
#+BEAMER: \framesubtitle{with a subtitle}
*** Thanks to Eric Fraga
:PROPERTIES:
:BEAMER_env: block
:BEAMER_envargs: C[t]
:BEAMER_col: 0.5
:END:
for the first viable beamer setup in Org
*** Thanks to everyone else
:PROPERTIES:
:BEAMER_col: 0.5
:BEAMER_env: block
:BEAMER_envargs: <2->
:END:
for contributing to the discussion
**** This will be formatted as a beamer note
:PROPERTIES:
:BEAMER_col: 0.5
:BEAMER_env: note
:BEAMER_envargs: <2->
:END:
** Frame 2
#+BEAMER: \framesubtitle{where we will not use columns}
*** Request
Please test this stuff!
:PROPERTIES:
:BEAMER_env: block
:END:
** Here is a graph
#+BEGIN_SRC julia :exports results :results graphics :file example1.pdf :eval no-export
using Winston
x = linspace(0, 3pi, 100)
c = cos(x)
s = sin(x)
p = FramedPlot();
setattr(p, "title", "title!")
setattr(p, "xlabel", L"\Sigma x^2_i")
setattr(p, "ylabel", L"\Theta_i")
add(p, FillBetween(x, c, x, s) )
add(p, Curve(x, c, "color", "red") )
add(p, Curve(x, s, "color", "blue") )
file(p, "example1.pdf")
#+END_SRC
#+ATTR_LaTeX: :options "width=0.80\\textwidth"
#+RESULTS:
[[file:example1.pdf]]
% Created 2013-02-25 Mon 23:30
\documentclass[presentation, bigger]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\usetheme{default}
\author{G. Jay Kerns}
\date{2013-02-25 Mon}
\title{julia-beamer.org}
\hypersetup{
pdfkeywords={},
pdfsubject={},
pdfcreator={Generated by Org mode 7.9.3f in Emacs 24.3.50.1.}}
\begin{document}
\maketitle
\begin{frame}{Outline}
\tableofcontents
\end{frame}
\section[Getting started]{Getting started}
\label{sec-1}
\begin{verbatim}
(load "~/gitm/projects/ob-julia.el")
(org-babel-julia-initiate-session "*julia*" nil)
\end{verbatim}
Read the following links.
\begin{itemize}
\item \url{http://orgmode.org/worg/exporters/beamer/tutorial.html}
\item \url{http://orgmode.org/worg/exporters/beamer/ox-beamer.html}
\item \url{http://orgmode.org/manual/Beamer-class-export.html#Beamer-class-export}
\end{itemize}
Add the following to \texttt{.emacs}
\begin{verbatim}
(require 'ox-beamer)
\end{verbatim}
You also need to add the \LaTeX{} class.
\begin{verbatim}
(add-to-list 'org-latex-classes
'("beamer"
"\\documentclass[presentation]{beamer}
\[DEFAULT-PACKAGES]
\[PACKAGES]
\[EXTRA]"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
\end{verbatim}
\begin{frame}[label=sec-1-1]{Exported title}
\begin{itemize}
\item amsdk
\item kdsalk
\item adkfa
\item jlksa
\end{itemize}
\end{frame}
\section[This is the first structural section]{This is the first structural section}
\label{sec-2}
\begin{frame}[label=sec-2-1]{Frame 1}
\framesubtitle{with a subtitle}
\begin{columns}
\begin{column}{0.5\textwidth}
\begin{block}{Thanks to Eric Fraga}
for the first viable beamer setup in Org
\end{block}
\end{column}
\begin{column}{0.5\textwidth}
\begin{block}{Thanks to everyone else}
for contributing to the discussion
\note{This will be formatted as a beamer note
}
\end{block}
\end{column}
\end{columns}
\end{frame}
\begin{frame}[label=sec-2-2]{Frame 2}
\framesubtitle{where we will not use columns}
\begin{block}{Request}
Please test this stuff!
\end{block}
\end{frame}
\begin{frame}[label=sec-2-3]{Here is a graph}
\includegraphics[width=0.80\textwidth]{example1.pdf}
\end{frame}
% Generated by Org mode 7.9.3f in Emacs 24.3.50.1.
\end{document}
\ No newline at end of file
This diff is collapsed.
#+TITLE: Org-mode and julia: an introduction
#+AUTHOR: G. Jay Kerns
#+EMAIL: gkerns@ysu.edu
#+PROPERTY: exports both
#+PROPERTY: results output
#+PROPERTY: session *julia*
#+PROPERTY: tangle yes
* What you need to get started
This document assumes you have at least a passing familiarity with Org-mode and Emacs keybindings.
#+BEGIN_SRC emacs-lisp :results silent :eval no-export
(load "~/gitm/projects/ob-julia.el")
(org-babel-julia-initiate-session "*julia*" nil)
#+END_SRC
** Julia
- First install takes the longest, later updates not so bad.
- all the dependencies
** Add on packages
Based on [[http://www.johnmyleswhite.com/notebook/2012/12/02/the-state-of-statistics-in-julia/][The State of Statistics in Julia]] by John Myles White.
#+BEGIN_SRC julia :eval never
Pkg.add("DataFrames", "Distributions", "GLM", "MCMC", "Optim", "NHST", "Clustering")
#+END_SRC
#+BEGIN_SRC julia :eval never
Pkg.add("RDatasets")
#+END_SRC
*** Winston
The =Winston= package at the time of this writing appears to be the most stable and fully featured of the =julia= graphics packages, among alternatives including =Gadfly=.
#+BEGIN_SRC julia :eval never
Pkg.add("Winston")
#+END_SRC
The Winston package has lots of dependencies and many of them must be built from source (on Ubuntu).
*** Gadfly
#+BEGIN_SRC julia :eval never
Pkg.add("Gadfly")
#+END_SRC
- packages take a lot longer to load than R
** Org-mode
We are assuming that you have a passing familiarity with org-mode, so that you likely have something like the following already in your =.emacs=
#+BEGIN_SRC emacs-lisp :eval never
(require 'org)
#+END_SRC
Another handy setting to have is
#+BEGIN_SRC emacs-lisp
(setq org-confirm-babel-evaluate nil)
#+END_SRC
In order to run this org file you will need to load the following code which .
#+BEGIN_SRC emacs-lisp :results silent :eval never
(load "~/gitm/projects/ob-julia.el")
(org-babel-julia-initiate-session "*julia*" nil)
#+END_SRC
Or you can copy =ob-julia.el= to your =/path/to/org-mode/lisp= folder and put the following in your =.emacs=.
#+BEGIN_SRC emacs-lisp :eval never
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(julia . t)))
#+END_SRC
The following lines (either here or in your =.emacs=) allow for inline image display in the Emacs buffer.
#+BEGIN_SRC emacs-lisp :eval never
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
(add-hook 'org-mode-hook 'org-display-inline-images)
#+END_SRC
If you'd like to do LaTeX export then put the following in your emacs.
#+BEGIN_SRC emacs-lisp :eval never
(require 'ox-latex)
(require 'ox-beamer)
#+END_SRC
** ESS
The place to get the latest version of ESS is [[http://stat.ethz.ch/ESS/index.php?Section=download][here]].
#+BEGIN_SRC emacs-lisp :eval never
(add-to-list 'load-path "~/path/to/ESS/lisp")
(require 'ess-site)
#+END_SRC
#+BEGIN_SRC emacs-lisp :eval never
(setq inferior-julia-program-name "~/path/to/julia-release-basic")
#+END_SRC
* Getting started with julia
#+BEGIN_SRC julia :results value
rand(2,3)
#+END_SRC
#+BEGIN_SRC julia :results output
print("hello")
#+END_SRC
#+BEGIN_SRC julia
[3:50]
x = [3:6]
y = [5:11]
z = [4:7]
x + z
ans
sum(x)
mean(x)
exp(x)
log(x)
sort(x)
sqrt(x)
diff(x)
x[3]
y[2:4]
typeof(x)
1.0
1.
Inf
-Inf
NaN
1 + 2im
#+END_SRC
* Plotting with Winston
#+BEGIN_SRC julia :results graphics :file example1.png
using Winston
x = linspace( 0, 3pi, 100 )
c = cos(x)
s = sin(x)
p = FramedPlot();
setattr(p, "title", "title!")
setattr(p, "xlabel", L"\Sigma x^2_i")
setattr(p, "ylabel", L"\Theta_i")
add(p, FillBetween(x, c, x, s) )
add(p, Curve(x, c, "color", "red") )
add(p, Curve(x, s, "color", "blue") )
file(p, "example1.png")
#+END_SRC
#+RESULTS:
[[file:example1.png]]
* Plotting with Gadfly
#+BEGIN_SRC julia :results graphics :file iris_plot.svg :eval never
using RDatasets
using Gadfly
using Compose
iris = data("datasets", "iris")
p = plot(iris, {:x => "Sepal.Length", :y => "Sepal.Width"}, Geom.point);
SVG("iris_plot.svg", 6inch, 4inch)
#+END_SRC
* Fitting (generalized) linear models
#+BEGIN_SRC julia :eval never
using RDatasets, DataFrames, Distributions, GLM
trees = data("datasets", "trees");
treeslm = lm(:(Girth ~ Height + Volume), trees);
coef(treeslm)
confint(treeslm)
#+END_SRC
% Created 2013-02-24 Sun 20:30
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\author{G. Jay Kerns}
\date{\today}
\title{Org-mode and julia: an introduction}
\hypersetup{
pdfkeywords={},
pdfsubject={},
pdfcreator={Generated by Org mode 7.9.3f in Emacs 24.3.50.1.}}
\begin{document}
\maketitle
\tableofcontents
\section[What you need to get started]{What you need to get started}
\label{sec-1}
\begin{verbatim}
(load "~/gitm/projects/ob-julia.el")
(org-babel-julia-initiate-session "*julia*" nil)
\end{verbatim}
\begin{verbatim}
rand(9)
\end{verbatim}
\begin{verbatim}
9-element Float64 Array:
0.627821
0.786056
0.851449
0.447721
0.722442
0.447876
0.578059
0.132425
0.338724
\end{verbatim}
\subsection[Julia]{Julia}
\label{sec-1-1}
\begin{itemize}
\item First install takes the longest, later updates not so bad.
\item all the dependencies
\end{itemize}
\subsection[Add on packages]{Add on packages}
\label{sec-1-2}
Based on \href{http://www.johnmyleswhite.com/notebook/2012/12/02/the-state-of-statistics-in-julia/}{The State of Statistics in Julia} by John Myles White.
\begin{verbatim}
Pkg.add("DataFrames", "Distributions", "MCMC", "Optim", "NHST", "Clustering")
\end{verbatim}
\begin{verbatim}
Pkg.add("RDatasets")
\end{verbatim}
This one is pretty big.
\subsubsection[Winston]{Winston}
\label{sec-1-2-1}
\begin{verbatim}
Pkg.add("Winston")
\end{verbatim}
This one has lots of dependencies.
\subsubsection[Gadfly]{Gadfly}
\label{sec-1-2-2}
\begin{verbatim}
Pkg.add("Gadfly")
\end{verbatim}
\begin{itemize}
\item packages take a lot longer to load than R
\end{itemize}
\subsection[ESS]{ESS}
\label{sec-1-3}
\url{http://stat.ethz.ch/ESS/index.php?Section=download}
\begin{verbatim}
rand(9)
print("hello")
\end{verbatim}
\begin{verbatim}
9-element Float64 Array:
0.294536
0.292205
0.0626337
0.435547
0.830883
0.298874
0.286572
0.539265
0.855514
hello
\end{verbatim}
\begin{verbatim}
(add-to-list 'load-path "~/path/to/ESS/lisp")
(require 'ess-site)
\end{verbatim}
\subsection[Org-mode]{Org-mode}
\label{sec-1-4}
\begin{verbatim}
(setq inferior-julia-program-name "~/path/to/julia-release-basic")
\end{verbatim}
\begin{verbatim}
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(julia . t)))
\end{verbatim}
For inline image display
\begin{verbatim}
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
(add-hook 'org-mode-hook 'org-display-inline-images)
\end{verbatim}
\section[Getting started]{Getting started}
\label{sec-2}
\begin{verbatim}
[3:50]
x = [3:6]
y = [5:11]
z = [4:7]
x + z
ans
sum(x)
mean(x)
exp(x)
log(x)
sort(x)
sqrt(x)
diff(x)
x[3]
y[2:4]
typeof(x)
1.0
1.
Inf
-Inf
NaN
true
false
1 + 2im
\end{verbatim}
\section[Plotting with Winston]{Plotting with Winston}
\label{sec-3}
\begin{verbatim}
using Winston
x = linspace( 0, 3pi, 100 )
c = cos(x)
s = sin(x)
p = FramedPlot();
setattr(p, "title", "title!")
setattr(p, "xlabel", L"\Sigma x^2_i")
setattr(p, "ylabel", L"\Theta_i")
add(p, FillBetween(x, c, x, s) )
add(p, Curve(x, c, "color", "red") )
add(p, Curve(x, s, "color", "blue") )
file(p, "blah2.png")
\end{verbatim}
\includegraphics[width=.9\linewidth]{blah2.png}
\section[Plotting with Gadfly]{Plotting with Gadfly}
\label{sec-4}
\begin{verbatim}
using RDatasets
using Gadfly
using Compose
iris = data("datasets", "iris")
p = plot(iris, {:x => "Sepal.Length", :y => "Sepal.Width"}, Geom.point);
SVG("iris_plot.svg", 6inch, 4inch)
\end{verbatim}
\section[Fitting linear models]{Fitting linear models}
\label{sec-5}
% Generated by Org mode 7.9.3f in Emacs 24.3.50.1.
\end{document}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment