\batchmode
\makeatletter
\def\input@path{{/home/pauljohn/SVN/SVN-guides/stat/Distributions/DistributionWriteups/Laplace//}}
\makeatother
\documentclass[12pt,english]{article}
\usepackage{mathptmx}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\usepackage{Sweavel}
<>=
if(exists(".orig.enc")) options(encoding = .orig.enc)
@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{lmodern}
\usepackage{Sweavel}
\usepackage{graphicx}
\usepackage{color}
\usepackage[samesize]{cancel}
\usepackage{ifthen}
\makeatletter
\renewenvironment{figure}[1][]{%
\ifthenelse{\equal{#1}{}}{%
\@float{figure}
}{%
\@float{figure}[#1]%
}%
\centering
}{%
\end@float
}
\renewenvironment{table}[1][]{%
\ifthenelse{\equal{#1}{}}{%
\@float{table}
}{%
\@float{table}[#1]%
}%
\centering
% \setlength{\@tempdima}{\abovecaptionskip}%
% \setlength{\abovecaptionskip}{\belowcaptionskip}%
% \setlength{\belowcaptionskip}{\@tempdima}%
}{%
\end@float
}
%\usepackage{listings}
\lstset{tabsize=2, breaklines=true,style=Rstyle}
% In document Latex options:
\fvset{listparameters={\setlength{\topsep}{0em}}}
\def\Sweavesize{\normalsize}
\def\Rcolor{\color{black}}
\def\Rbackground{\color[gray]{0.95}}
\makeatother
\usepackage{babel}
\begin{document}
<>=
unlink("plots", recursive=T)
dir.create("plots", showWarnings=F)
@
% In document Latex options:
\fvset{listparameters={\setlength{\topsep}{0em}}}
\SweaveOpts{prefix.string=plots/t,split=T,ae=F,height=6,width=6}
<>=
options(width=100, prompt=" ", continue=" ")
options(useFancyQuotes = FALSE)
set.seed(12345)
op <- par()
options(SweaveHooks=list(fig=function() par(ps=12)))
pdf.options(onefile=F,family="Times",pointsize=12)
@
\title{Laplace Distribution}
\author{Raminta Stockute and Paul Johnson}
\date{June 10, 2013}
\maketitle
\section{Introduction}
This is a continuous probability distribution. It is named after a
French mathematician. Wikipedia points out that it is also known as
a double exponential distribution, because it reminds one of an exponential
distribution ``spliced together back-to-back.''
The most outstandanding characteristics of this distribution are that
it is unimodal and symmetric.
\section{Mathematical definition}
This distribution is characterized by location $\theta$ (any real
number) and scale $\lambda$ (has to be greater than a 0) parameters.
The probability density function of $Laplace(\theta,\lambda)$ is:
\[
f(x|\theta,\lambda)=\frac{1}{2\lambda}exp\left(-\frac{|x-\theta|}{\lambda}\right).
\]
The cumulative density function looks even more impressive, yet rather
easy to integrate because of the absolute value in the formula:
\[
F(x|\theta,\lambda)=\frac{1}{2}exp\left(-\frac{|x-\theta|}{\lambda}\right),when\left(x\leq\theta\right).
\]
and
\[
F(x|\theta,\lambda)=1-\frac{1}{2}exp\left(-\frac{|\theta-x|}{\lambda}\right),when\left(x>\theta\right).
\]
The exponential distribution's probability density is defined for
$x>0$
\[
Exponential(\lambda):\,\, f(x|\lambda)=\frac{1}{\lambda}exp(-x/\lambda),\, x>0
\]
\\
Unlike the exponential, the Laplace is defined $-\infty0$ is equal to 1/2 of the probability of the exponential. In
Figure \ref{cap:Laplace-and-Exponential}, we illustrate this fact
by plotting the probability density of the Laplace on $(-15,15)$
side-by-side with an exponential distribution, and then in the figure
below, one can observe that if the exponential is divided by half,
then it is equal to the Laplace. The R code which generates the figure
is:
<>=
par(mfrow=c(2, 2))
x1 <- seq(-15, 15, by = 0.05)
mylaplace1 <- dlaplace(x1, location = 0, scale = 1)
plot(x1, mylaplace1, type = "l", xlab = "x", ylab = "P(x)",
main="Laplace, location=0, scale=1")
x2 <- seq(0, 15, by = 0.05)
myexp1 <- dexp(x2, rate = 1)
plot(x2, myexp1, type = "l", xlab = "x", ylab = "P(x)", main = "Exponential, rate=1")
myexp2 <- 0.5*dexp(x1,rate=1)
plot(x1, myexp2, type = "l", xlab = "x", ylab = "0.5*P(x)", main = "0.5*Exponential PDF")
@
<>=
library(VGAM)
@
\begin{figure}[b]
\caption{Laplace and Exponential \label{cap:Laplace-and-Exponential}}
<>=
<>
@
\end{figure}
\section{Moments}
The expected value of a Laplace distribution is
\[
E(x)=\theta
\]
As in the case of other symmetrical distributions, such as the Normal
and the logistic distributions, Laplace's location is the same as
its mean, median, and mode.
The variance is:
\[
Var(x)=2\lambda^{2}.
\]
\section{Illustrations}
From the Figure \ref{cap:Laplace-Distribution}, we see that the scale
parameter determines the width of the distribution. From Figure \ref{cap:Impact-of-location},
it is apparent that changing the location simply shifts the probability
density curve to the right or to the left.
The Laplace can be compared against the Normal distribution. Recall
that a Normal distribution $N(\mu,\sigma^{2})$ has an expected value
of $\mu$ and a variance equal to $\sigma^{2}.$ Suppose we fix the
mean of a Normal to equal the mean of a Laplace distribution, and
then also match the variances of the two. In Figure \ref{LaplaceNormal},
we compare $N(4,8)$ and $L(4,2)$, both of which have variance equal
to 8. The distributions appear to be quite similar, except that Laplace
has higher spike and slightly thicker tails .
<>=
library(VGAM)
@
\begin{figure}
\caption{Laplace Density Function\label{cap:Laplace-Distribution}}
<>=
x <- seq(-4,12, by=0.05)
mylaplace1 <- dlaplace(x, location=4, scale=2)
mylaplace2 <- dlaplace(x, location=4, scale=4)
mylaplace3 <- dlaplace(x, location=4, scale=8)
matplot(x, cbind(mylaplace1,mylaplace2, mylaplace3), type="l", xlab="x", ylab="P(x)",main="")
legend("topleft", c("Laplace(4,2)","Laplace(4,4)","Laplace(4,8)"),lty=1:3, col=1:3)
@
\end{figure}
\begin{figure}
\caption{I\label{cap:Impact-of-location}mpact of location change on Laplace
Density Function}
<>=
mylaplace1 <- dlaplace(x1, location=-2, scale=1)
mylaplace2 <- dlaplace(x1, location=2, scale=1)
plot(x1, mylaplace2, type = "n", xlab = "x", ylab = "P(x)", main = "Laplace, scale=1")
mylaplace3 <- dlaplace(x1, location = 5, scale = 1)
mylaplace4 <- dlaplace(x1, location = 10, scale = 1)
lines(x1, mylaplace1, lty = 1, col = 1)
lines(x1, mylaplace2, lty = 2, col = 2)
lines(x1, mylaplace3, lty = 3, col = 3)
lines(x1, mylaplace4, lty = 4, col = 4)
legend("topleft",c("location=-2", "location=2", "location=5", "location=10"), lty=1:4, col=1:4)
@
\end{figure}
\begin{figure}
\caption{Laplace and Normal Densities\label{LaplaceNormal}}
<>=
par(mfcol=c(2,1))
x <- seq(-8,16, by = 0.05)
mylaplace1 <- dlaplace(x, location = 4, scale = 2)
mydnorm <- dnorm(x, mean = 4, sd = sqrt(8))
matplot(x, cbind(mylaplace1, mydnorm), type = "l", xlab = "x", ylab = "P(x)", main="")
legend("topleft", c("Laplace(4,2)", "Normal(4,8)"), lty=1:2, col=1:2)
x <- seq(8, 20, by = 0.05)
mylaplace1 <- dlaplace(x, location = 4, scale = 2)
mydnorm <- dnorm(x, mean = 4, sd = sqrt(8))
matplot(x, cbind(mylaplace1, mydnorm), type = "l", xlab = "x", ylab = "P(x)", main = "Expanded view, x>8",)
legend("topleft", c("Laplace(4,2)","Normal(4,8)"), lty = 1:2, col = 1:2)
@
\end{figure}
\section{Conclusion}
If we have real-valued observations, the errors can be distributed
either in normal or in Laplace. Let is take gene expression data as
an example. A distribution of gene expression errors tends to be in
Laplace form. Better yet, if the distribution is a bit asymmetric,
there is an Asymmetric Laplace to allow for this asymmetry.
\end{document}