\documentclass[twoside]{article}

\usepackage{epsfig}
\usepackage{amssymb}
\usepackage{amsmath}

\setlength{\oddsidemargin}{0.25 in}
\setlength{\evensidemargin}{-0.25 in}
\setlength{\topmargin}{-0.6 in}
\setlength{\textwidth}{6.5 in}
\setlength{\textheight}{8.5 in}
\setlength{\headsep}{0.75 in}
\setlength{\parindent}{0 in}
\setlength{\parskip}{0.1 in}

\newtheorem{thm}{Theorem}[section]
\newtheorem{Defn}{Definition}[section]

\newcommand{\lecture}[3]{
   \pagestyle{myheadings}
   \thispagestyle{plain}
   \newpage
   \setcounter{page}{1}
   \noindent
   \begin{center}
   \framebox{
      \vbox{\vspace{2mm}
    \hbox to 6.28in { {\bf  ~Probabilistic Graphical Models 10-708 Notes with Koller and Friedman Textbook\hfill} }
       \vspace{6mm}
       \hbox to 6.28in { {\Large \hfill #1  \hfill} }
       \vspace{6mm}
       \hbox to 6.28in { {\it Lecturer: #2 \hfill Scribes: #3} }
      \vspace{2mm}}
   }
   \end{center}
   \markboth{#1}{#1}
   \vspace*{4mm}
}

\begin{document}

\lecture{2 : Directed GMs: Bayesian Networks}{Eric P. Xing}{Xing JunJie} % Lecture name, Lecturer, Scribes

\section{Introduction}

The goal of establishing GMs (Graphical Models) is to represent a joint distribution \(P\) over some set of random variables \(\mathbf{\chi} = \{X_1,\ldots,X_n\}\). Consider the simplest case where each variable is binary-valued, a joint distribution requires total \(2^n - 1\) numbers (minus 1 comes from sum-to-one constraint).This explicit representation of the joint distribution is unmanageable from every perspective\footnote{The following mainly quotes from Koller andFriedman Textbook Ch.3}.

\begin{itemize}
\item \textbf{Computationally}, it's very expensive to manipulate and too large to store in memory.
\item \textbf{Cognitively}, it is impossible to acquire so many numbers from a human expert, and the numbers are very small and do not correspond to events that people can reasonably contemplate.
\item \textbf{Statistically}, if we want to learn the distribution from date, we would need ridiculously large amounts of data to estimate this many parameters robustly.
\end{itemize}

However, \textbf{Bayesian Networks} are able to represent compact representations by exploiting \textbf{Independence Properties}.

\section{The \emph{student} Example}

We'll introduce perhaps the simplest example to see how \textbf{independence assumptions} produce a very compact representation of a high-dimensional distribution.

We now assume that a company would like to hire some graduates. The company's goal is to hire intelligent employees, but there is no way to test intelligence directly. However, the company have access to student's SAT scores and course grades. Thus, our probability space is induced by three relevant random variables \(I, S\) and \(G\). Assuming that \(G\) takes on three values \(g^1,g^2,g^3\), representing grades \(A, B\) and \(C\), \(I\) takes on two values \(i^0\)(low intelligence), \(i^1\)(high intelligence), \(S\) takes on two values \(s^0\)(low score) and \(s^1\)(high score).

We can get some intuitive independences in this example. The student's intelligence is clearly correlated both with his SAT score and grade. The SAT score and grade are also not independent.If we on the fact that the student received a high score on his SAT, the chances that he gets a high grade in his class are also likely to increase. Thus, we assume that, for our distribution \(P\),\[P(g^1\ |\ s^1) > P(g^1\ |\ s^0)\]

However, it's quite plausible that our distribution \(P\) satisfies a \textbf{conditional independence property}. If we know that the student has high intelligence, a high grade on the SAT no longer gives us information about the student’s performance in the class. That is:
\[P(g\ |\ i^1,s^1) = P(g\ |\ i^1)\]
Generally, we may assume that \[P\models(S\perp{G\ |\ I)}\]

Note that this independence holds only if we assume that student's intelligence is the only reason why his grade and SAT score might be correlated, which means that it assumes that there is no correlations due to other factors. These assumptions are also not ``True'' in any formal sense of word, and they are often only approximations of our true beliefs.
\begin{figure}
\centering
\includegraphics[width=0.3\textwidth]{assets/student_nb.png}
\caption{\label{fig:student_nb}Simple Bayesian networks for the \emph{student} example}
\end{figure}

As in the case of marginal independence, conditional independences allows us to provide a compact specification of the joint distribution. The compact representation is based on a very natural alternative parameterization. By simple probabilistic reasoning, we have that

\(P(I,S,G) = P(S,G \ |\ I)P(I).\)

But now, the \textbf{conditional independence assumption} implies

\(P(S,G\ |\ I) = P(S\ |\ I)P(G\ |\ I).\)

Hence, we have that

\(P(I,S,G) = P(S\ |\ I)P(G\ |\ I)P(I)\)

Thus, we have factorized the joint distribution \(P(I,G,G)\) as a product of three conditional probability distributions (CPDs). This factorization immediately leads us to the desired alternative parameterization. Together with \(P(I), P(S\ |\ I), P(G\ |\ I)\), we can specify the joint distribution. For example, \(P(i^1,s^1,g^2) = P(i^1)P(s^1\ |\ i^1)P(g^2\ |\ i^1)\).

We note that this probabilistic model would be represented using the Bayesian network shown in Figure \ref{fig:student_nb}.

In this case, the alternative parameterization is more compact than the joint. We now have three binomial distributions --- \(P(I)\), \(P(S\ |\ i^1)\) and \(P(S\ |\ i^0)\), and two three-valued multinomial distributions --- \(P(G\ |\ i^1)\) and \(P(G\ |\ i^0)\). Each of the binomials requires one independent parameter, and each three-valued multinomial requires two independent parameters, for a total of \textbf{seven} (\(3 * (2 - 1) + 2 * (3 - 1)\)).By contract, our joint distribution has twelve entries, so that \textbf{eleven} independent parameters.

\section{Bayesian Networks}

Bayesian networks build on the intuition as the naive Bayes model by exploiting conditional independence properties in order to allow a compact and natural representation.However, they are not restricted to the strong independence assumptions naive Bayes model makes.

The core of the Bayesian network representation is a directed acyclic graph (DAG), whose nodes are the random variables in our domain and whose edges correspond, intuitively, to direct influence of one node on another.

We can view  the graph in two ways:
\begin{itemize}
\item a data structure that provides the skeleton for representing \textbf{a joint distribution} compactly in a \emph{factorized} way.
\item a compact representation for \textbf{a set of conditional independence assumptions} about a distribution.
\end{itemize}

\subsection{Factorization Theorem}

Given a DAG, the most general form of the probability distribution that is \textbf{consistent} with the graph factors according to ``\textbf{node given its parents}'':\[P(X) = \prod_{1=1:d}{P(X_i\ |\ X_{\pi_i})}\] where \(X_{\pi_i}\)is the set of parent node of \(x_i\), and \(d\) is the number of nodes.See Figure \ref{fig:factorize_example} for an example.
This graph can be factorized and represented as follows:
\[
\begin{split}
&P(X_1,X_2,X_3,X_4,X_5,X_6,X_7,X_8) = \\
&P(X_1)P(X_2)P(X_3\ |\ X_1)P(X_4\ |\ X_2)P(X_5\ |\ X_2)P(X_6\ |\ X_3, X_4)P(X_7\ |\ X_6)P(X_8\ |\ X_5, X_6)
\end{split}
\]

\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{assets/factorize_example.png}
\caption{\label{fig:factorize_example}Factorize example graph}
\end{figure}

\subsection{Local Structures and Independences}

Graphical models have three fundamental local structures that composes bigger structures.

\begin{itemize}
\item \textbf{Common parent} Fixing \(B\) decouples \(A\) and \(C\). When two variables \(A\) and \(C\) have a common parent \(B\), conditional independence \(A\perp C\ |\ B\) holds.
\item \textbf{Cascade} Knowing \(B\) decouples \(A\) and \(C\). When a middle node in a cascaded three random variables is known, a conditional independence \(A\perp C\ |\ B\) holds.
\item \textbf{V-structure} If \(C\) is not observed, then \(A\) and \(B\) are independent. However, if it is given, then the independence is lost. (\(A\) and \(B\) are not independent given \(C\)). In this case, \(A\) and \(B\) are \emph{marginally independent}.
\end{itemize}

The unintuitive V-structure can be described by a simple example. Suppose \(A = \) clock on tower, \(B = \) traffic jam on Eric's way to campus, and \(C = \) Eric on time for class. If Eric is not on time and the clock is on time, then our belief that \(B\) occurred is higher.

\section{I-maps}

\begin{Defn}
Let \(P\) be a distribution over \(X\). We define \(I(P)\) to be the set of independence assertions of the form \((X \perp Y\ |\ Z)\) that hold in P.
\end{Defn}
\begin{Defn}
Let \(K\) be an any graph object associated with a set of independences \(I(K)\). Then \(K\) is an \(I-map\) for a set of independences \(I\) if \(I(K) \subseteq I\)
\end{Defn}

For example, if a graph \(K\) is totally connected, then every pair of variables are dependent, more formally, \(I(K) = \emptyset \subset P\). A complete graph is ``useless'', since it does not give any knowledge about the structural.

\subsection{Facts about I-maps}
For \(G\) to be an I-map of \(P\), it is necessary that \(G\) does not mislead us regarding independences in \(P\). In other words, any independence that \(G\) asserts must also hold in \(P\), but conversely, \(P\) may have additional independences that are not reflected in \(G\).

\begin{figure}[!bph]
\centering
\includegraphics[width=0.4\textwidth]{assets/imap_example.png}
\caption{\label{fig:imap_example}} I-map example
\end{figure}

Example:

Consider a joint probability space over two independent random variables \(X\) and \(Y\) . There are three possible graphs (as shown in Figure \ref{fig:imap_example}) over these two nodes: \(G_\emptyset\), which is a disconnected pair \(X\) \(Y\) ; \(G_{X\rightarrow Y}\) , which has the edge \(X\rightarrow Y\) ; and \(G_{X\rightarrow Y}\) , which contains \(Y\rightarrow X\). The graph \(G_\emptyset\) encodes the assumption that \((X \perp Y )\). The latter two encode no independence assumptions.

Consider following two distributions:

\begin{table}[!htbp]
\parbox{.3\linewidth}{
\begin{tabular}{cc|c}
\(X\) & \(Y\) & \(P(X, Y)\)\\ \hline
\(x^0\) & \(y^0\) & \(0.08\)\\
\(x^0\) & \(y^1\) & \(0.32\)\\
\(x^1\) & \(y^0\) & \(0.12\)\\
\(x^1\) & \(y^1\) & \(0.48\)\\
\end{tabular}
\hfill\hfill
\parbox{.3\linewidth}{
\begin{tabular}{cc|c}
\(X\) & \(Y\) & \(P(X, Y)\)\\ \hline
\(x^0\) & \(y^0\) & \(0.4\)\\
\(x^0\) & \(y^1\) & \(0.3\)\\
\(x^1\) & \(y^0\) & \(0.2\)\\
\(x^1\) & \(y^1\) & \(0.1\)\\
\end{tabular}
}
}
\end{table}

In the example on the left, \(X\) and \(Y\) are independent in \(P\); for example, \(P(x^1) = 0.48 + 0.12 = 0.6\), \(P(y^1) = 0.8\), and \(P(x^1, y^1) = 0.48 = 0.6 · 0.8\). Thus, \((X \perp Y ) \in I(P)\), and we have that \(G_\emptyset\) is an I-map of \(P\). In fact, all three graphs are I-maps of \(P\): \(I(G_{X\rightarrow Y})\) is empty, so that trivially \(P\) satisfies all the independences in it (similarly for \(G_{Y\rightarrow X}\) ). In the example on the right, \((X \perp Y) \not\in I(P)\), so that \(G_\emptyset\) is not an I-map of \(P\). Both other graphs are I-maps of \(P\).

\subsection{Local independences}

\begin{Defn}
A Bayesian network structure \(G\) is a directed acyclic graph whose nodes represent random variables \(X_1,\ldots,X_n\) . Let \(Pa_{X_i}\) denote the parents of \(X_i\) in \(G\), and \(NonDescendants_{X_i}\) denote the variables in the graph that are not descendants of \( X_i\) . Then \(G\) encodes the following set of \textbf{local conditional independence assumptions} \(I_l (G)\):
\[For\ each\ variable\ X_i: (X_i \perp NonDescendant_{X_i} | Pa_{x_i}).\]
\end{Defn}

In other words, a node \(X_i\) is independent of any non descendants given its parents.

\section{D-separation}

\textbf{Direct connection}\quad The simple case is that \(X\) and \(Y\) are directly connected via an edge, say \(X \rightarrow Y\). For any network structure \(G\) that contains the edge \(X \rightarrow Y\) , it is possible to construct a distribution where \(X\) and \(Y\) are correlated regardless of any evidence about any of the other variables in the network. In other words, if \(X\) and \(Y\) are directly connected, we can always get examples where they influence each other, regardless of \(Z\).

\begin{figure}[!bth]
\centering
\includegraphics[width=.6\linewidth]{assets/xyz_trail.png}
\caption{\label{fig:xyz_trail} The four possible two-edge trails from \(X\) to \(Y\) via \(Z\)}
\end{figure}

\textbf{Indirect connection}\quad Now consider the more complicated case when X and Y are not directly connected, but there is a trail between them in the graph. We begin by considering the simplest such case: a three-node network, where X and Y are not directly connected, but where there is a trail between them via Z. It is clear that there are four cases where X and Y are connected via Z, as shown in Figure \ref{fig:xyz_trail}.

\begin{itemize}
\item Causal trail \(X \rightarrow Y \rightarrow Z\), and evidential trail \(X \leftarrow Y \leftarrow Z\): active iff \(Z\)is not observed. These two is shown in Figure \ref{fig:xyz_trail} (a),(b)
\item Common cause \(X \leftarrow Z \rightarrow Y\) : active iff \(Z\) is not observed.
\item Common effect \(X \rightarrow Z \leftarrow Y\) : active iff \(Z\) or one of its descendants is observed.
\end{itemize}

\begin{Defn}
Let \(\mathbf{X}\), \(\mathbf{Y}\) , \(\mathbf{Z}\) be three sets of nodes in \(G\). We say that \(\mathbf{X}\) and \(\mathbf{Y}\) are d\textrm{-}separated given \(\mathbf{Z}\), denoted \(d-sep_G(\mathbf{X} ; \mathbf{Y} \ |\ \mathbf{Z})\), if there is no active trail between any node \(X \in \mathbf{X}\) and \(Y \in \mathbf{Y}\) given \(\mathbf{Z}\). We use \(I(G)\) to denote the set of independences that correspond to d-separation:
\[I(G) = \{(\mathbf{X}\perp{\mathbf{Y}}\ |\ \mathbf{Z})\ :\ d\textrm{-}sep_G(\mathbf{X} ; \mathbf{Y} \ |\ \mathbf{Z})\}.\]
This set is also called the set of \textbf{global Markov independences}.
\end{Defn}

\section{Soundness and completeness}

\textbf{Soundness}\quad If a distribution \(P\) factorizes according to a graph \(G\), then \(I(G) \subseteq I(P\)).

\textbf{Completeness}\quad d-separation detects all possible independences.

However, it is important to note that if \(X\) and \(Y\) are not d-separated given \(G\), then it is not the case that \(X\) and \(Y\) are dependent given \(Z\) in all distributions that factorize over \(G\). For example, consider the graph \(A \rightarrow B\). Clearly, \(A\) and \(B\) are dependent. Note that every distribution over \(A\) and \(B\) factorizes according to this graph, since it is always true that \(P(A, B) = P(A)P(B\ |\ A)\). But if we consider the specific distribution give in Table 1, then \(A \perp B\). However, we can assert that if \(X\) and \(Y\) are not d-separated given \(Z\), then there is at least one distribution which factorizes according to the graph, and where \(X\) is not independent of \(Y\) given \(Z\). Combining this with the above theorems gives us an important result.

\begin{table}[!hbt]
\centering
\begin{tabular}{c|cc}
 & \(b^0\) & \(b^1\)\\ \hline
\(a^0\) & 0.4 & 0.6\\
\(a^1\) & 0.4 & 0.6\\
\end{tabular}
\caption{\label{table:completeness} The distribution specified in this table factorizes according to the graph \(A \rightarrow B\) but \(A\) is independent of \(B\).}
\end{table}

\section{Uniqueness of BN}
Very different BN graphs can actually be equivalent, in that they encode precisely the same set of conditional independence assertions.For example, the three networks in figure \ref{fig:xyz_trail}(a),(b),(c) encode precisely the same independence assumption: \(X\perp Y\ |\ Z\). Note that the v-structure network in figure \ref{fig:xyz_trail}(d) induces a very different set of d-separation assertions, and hence it does not fall into the same I-equivalence class as the first three.

\begin{Defn}
Two graph structures \(K^1\) and \(K^2\) over X are I-equivalent if \(I(K^1) = I(K^2)\). The set of all graphs over \(X\) is partitioned into a set of mutually exclusive and exhaustive I-equivalence classes, which are the set of equivalence classes induced by the I-equivalence relation.\(\)
\end{Defn}

\begin{Defn}
The skeleton of a Bayesian network graph \(\mathcal{G}\) over \(X\) is an undirected graph over \(X\) that contains an edge \(\{X, Y\}\) for every edge \((X, Y)\) in \(\mathcal{G}\).
\end{Defn}

\begin{thm}
Let \(\mathcal{G}^1\) and \(\mathcal{G}^2\) be two graphs over \(X\). If \(\mathcal{G}^1\) and \(\mathcal{G}^2\) have the same skeleton and the same set of v-structures then they are I-equivalent.
\end{thm}

\section{Minimum I-Map}

Complete graph is a trivial I-map for any distribution over all variables, since it does not reveal any of the independence structure in the distribution.

\begin{Defn}
A graph \(\mathcal{K}\) is a minimal I-map for a set of independences \(\mathcal{I}\) if it is an I-map for \(\mathcal{I}\), and if the removal of even a single edge from \(\mathcal{K}\) renders it not an I-map.
\end{Defn}

\section{Perfect Maps}

\begin{Defn}
We say that a graph \(\mathcal{K}\) is a perfect map (P-map) for a set of independences \(I\) if we have that \(I(\mathcal{K}) = I\). We say that \(\mathcal{K}\) is a perfect map for \(P\) if \(I(\mathcal{K}) = I(P)\).
\end{Defn}

Note that not every distribution has a perfect map.

\section{Summary}
\begin{itemize}
\item \begin{Defn}
\(A\) Bayesian network is a pair \(B = (G, P)\) where \(P\) factorizes over \(G\), and where \(P\) is specified as a set of CPDs associated with \(G’s\) nodes. The distribution \(P\) is often annotated \(P_B\).
\end{Defn}
\item BN utilizes local and global independences to give a compact representation of the joint distribution.
\item Joint likelihood is computed by multiplying CPDs.
\item Local and global independences are identifiable via d-separation.
\end{itemize}

\end{document}


%------------------------------------------------------------------------------
\section{Computing Tree Edit Distance}
%------------------------------------------------------------------------------

Tree edit distance is formally defined as the minimum total cost of the steps needed to change from a source tree to a destination tree \cite{bille2005survey}. A \textquote{step} can either be inserting a node, deleting a node, or renaming a node. Clearly the trivial solution is to simply delete every node in the source tree and insert a copy of every node from the destination tree. The goal, however, is to find the sequence of steps that minimizes the total cost.

After preprocessing the ASTs, we are now ready to compute the tree edit distance between the student solution's AST and the reference solution's AST. However before we can proceed, we first need to choose a starting point for the root of our trees. In the context of assignment marking, there are two potential candidates for the tree roots.

The first choice is to root our trees at the file level. In this case, we treat the entire solution file as a single tree; functions and global variables are the immediate children of the root. The advantage of this approach is that we only need to compute the tree edit distance once. However, the disadvantage is that it is easy for logically trivial changes, such as different function orderings or function names, to significantly impact the final edit distance value.

The second choice is to root our trees at the function level. In this case, we need to compute a different tree edit distance for each matching function between the student and reference solution. For example, we would have to compute the edit distance between the tree corresponding to \texttt{main()} in the student solution to the tree corresponding to \texttt{main()} in the reference solution. We then repeat this process for each pair of matching functions between the student and reference solution.

Between these two choices, we decided the function-level approach is less prone to miscalculating tree edit distances between logically similar solutions. Since the tree edit distance algorithm library we are using does not have a \textquote{reorder} operation, we want to avoid the case where the students' functions are in a different order than the reference solution.

%------------------------------------------------------------------------------
\subsection{Inlining Unexpected Functions}
%------------------------------------------------------------------------------

Before we pass the ASTs to our tree edit distance algorithm, we need to consider the potential case of unexpected helper functions created by the students. In programming assignments, some students may create helper functions to avoid duplicating code. This is problematic because the edit distance algorithm does not take the context of the nodes to edit into account.

Research in static analysis and automated marking generally focuses on single functions because inter-procedural analysis is exponentially more complex and time consuming. Luckily in our course, students historically do not use helper functions; of those that do, they mainly use \textquote{pure functions}, i.e. functions that do not have any side effects and only have one return statement. In addition, emperical evidence indicate that student helper functions are rarely recursive and do not include complex logic. From this observation, we devised a simple technique (Figure~\ref{fig:cam-inlining}) to inline these helper functions' ASTs into the caller's AST prior to computing edit distances. Should a student solution contain a more complicated helper function, their solution will be designated for manual marking.

\begin{figure}
\begin{minipage}{.45\textwidth}
\lstinputlisting[language=C]{../media/code/inlining-before.c}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
\lstinputlisting[language=C]{../media/code/inlining-after.c}
\end{minipage}
\caption[Inlining Unexpected Student Functions]{Our inliner first deletes the parameter list in the function root. It then replaces every reference to the parameters with the respective argument from the caller. Finally, it replaces the original function call with the child of the return statement.}
\label{fig:cam-inlining}
\end{figure}

%------------------------------------------------------------------------------
\subsection{Cost Model for Comparing ASTs}
\label{sec:cam-cost-model}
%------------------------------------------------------------------------------

The last component to consider before we pass the ASTs to our tree edit distance algorithm is the cost function or model that determines the actual cost of each edit step. A cost model, given an input node, returns the \textquote{cost} to insert a copy of it into the source tree, delete it from the source tree, or rename it to a second input node.

By default, every node has an edit distance of one. Clearly, this is not ideal because some nodes should more important than others. For example, if a student forgot to call \texttt{free()} at the end of their program, they should lose a few marks (small insertion cost) whereas if they forgot to call \texttt{curl\_multi\_perform()}, they should lose a lot of marks (high insertion cost). Furthermore, inconsequential node differences such as parentheses should be penalized less, if at all. Therefore, we have added additional analysis to our cost model to ensure similar nodes and structures have reduced edit costs and key function calls have heavier penalties.

\subsubsection{Variables}
\label{sec:cam-ted-declref}

There are two types of variables to consider in our ASTs: external and internal variables.

External variables are variables defined outside the student or reference solution files. These are usually library constants. For example, students may choose to use \texttt{CURLE\_OK} from the cURL library instead of its hard-coded value of 0 for code readability. To determine if two external variables are \textquote{equivalent}, we check their types and names. We do not check for literal value because we want to encourage good coding practices such as using library defined constants. Furthermore, we do not need to worry about naming conflicts because the Clang frontend will catch them beforehand.

Internal variables are variables defined inside the student or reference solution files. These include global variables as well as scope-level variables such as loop counters and function parameters. Recall from Section~\ref{sec:cam-simplify-var-usage} that variables are defined to be the set of functions that read and write to them. When comparing internal variables, we consider them to be \textquote{equivalent} and thus have zero edit cost if the intersections of their reader or writer sets are not empty.

\subsubsection{Conditions}

There are often many ways to write the same or similar behaving conditions for if-statements and loops. Without relying on SAT solvers, it is difficult to know whether two condition nodes are logically similar. For the purpose of marking, we noticed that simply comparing the set of variables and function calls between two different conditions is sufficient for determining logically similar code.

We define the edit cost between two conditions to be zero if they share at least one \textquote{equivalent} variable (described in Section~\ref{sec:cam-ted-declref}). If one condition has a function call to $f$, then the other condition must either contain a function call to $f$ or a variable that has been written to by $f$.

\subsubsection{Weighting Key Function Usage}

Conceptually, the key aspects to look for when marking should be how students make their function calls to the assignment's corresponding libraries. As a result, we want to penalize improper usage, i.e. increase the cost to insert the missing call statement to the student's AST such that it matches the reference AST.

We assign each \textquote{key function} a weight on a per-assignment basis. Anywhere that requires a call to one of these key functions will use the associated weight---generally magnitudes higher than other edit costs.


\documentclass[apjl]{emulateapj}
%\documentclass[letterpaper,12pt,preprint]{aastex}

% packages
\usepackage{amssymb,amsmath,amsbsy}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{url}

% commands
\newcommand{\given}{\,|\,}
\newcommand{\dd}{\mathrm{d}}
\newcommand{\transpose}[1]{{#1}^{\mathsf{T}}}
\newcommand{\inverse}[1]{{#1}^{-1}}
\newcommand{\Msun}{\ifmmode {{\rm M}_{\odot}}\else M$_{\odot}$\fi}
\newcommand{\bs}[1]{\boldsymbol{#1}}
\newcommand{\degree}{^{\circ}}
\newcommand{\eqn}{Equation~}

% Symbols
\newcommand{\period}{T}
\newcommand{\mf}{m_f}
\newcommand{\wdupper}{1.44}

\begin{document}

\title{The mass distribution of companions to low-mass white dwarfs}
\author{Jeff J.~Andrews\altaffilmark{\colum}, Adrian M.~Price-Whelan\altaffilmark{\colum}, Marcel A.~Ag\"ueros\altaffilmark{\colum}}

% Affiliations
\newcommand{\colum}{1}
\altaffiltext{\colum}{Department of Astronomy,
		              Columbia University,
		              550 W 120th St.,
		              New York, NY 10027, USA}

\begin{abstract}
Measuring the masses of companions to single-line spectroscopic binary stars is (in general) not possible because of the unknown orbital plane inclination.  Even when the mass of the visible star can be measured, only a lower limit can be placed on the mass of the unseen companion. However, since these inclination angles should be isotropically distributed, for a large enough, unbiased sample, the  companion mass distribution can be deconvolved from the distribution of observables. In this work, we construct a hierarchical probabilistic model to infer properties of unseen companion stars given observations of the orbital period and projected radial velocity of the primary star. We apply this model to three mock samples of low-mass white dwarfs (LMWDs, $M\lesssim0.45~\Msun$) and a sample of post-common-envelope binaries. We use a mixture of two Gaussians to model the WD and neutron star (NS) companion mass distributions. Our model successfully recovers the initial parameters of these test data sets. We then apply our model to 55 WDs in the extremely low-mass (ELM) WD Survey. Our maximum a posteriori model for the WD companion population has a mean mass $\mu_{\rm WD} = 0.74~\Msun$, with a standard deviation $\sigma_{\rm WD} = 0.24~\Msun$. Our model constrains the NS companion fraction $f_{\rm NS}$ to be $<$16\% at 68\% confidence. We make samples from the posterior distribution publicly available so that future observational efforts may compute the NS probability for newly discovered LMWDs.
\end{abstract}

\keywords{binaries: general --- binaries: spectroscopic --- methods: statistical --- white dwarfs}

\section{Introduction}
Except in cases of extreme metallicity \citep{kilic07}, the Galaxy is not old enough to produce low-mass white dwarfs (LMWDs) through single-star evolution. Instead, LMWDs are expected to form through interactions with another star \citep{han98,nelemans00,nelemans01,vdSluys06,woods12}. Indeed, with few exceptions, follow-up observations consistently find companions to LMWDs \citep{marsh95,maxted00,nelemans05,rebassa11}. Recently, the ELM WD Survey has identified 61 extremely LMWDs ($M\lesssim0.3~ \Msun$) in the Sloan Digital Sky Survey \citep[SDSS;][]{york00} and elsewhere \citep{ELMI,ELMII, ELMIII, ELMIV, ELMV}. We refer to the 55 WDs found by these authors that have a measured radial velocity (RV) and orbital period ($\period$) as the ELM sample.

These RV and $\period$ measurements indicate that the LMWDs companions are most likely WDs. However, since the inclination angle $i$ is unknown, LMWDs could have neutron star (NS) companions. Indeed, LMWDs are known companions to millisecond pulsars, although these WDs are generally too faint for spectroscopy \citep{vKerkwijk96,callanan98,bassa06,antoniadis12}. Finding even one NS companion to a spectroscopically characterized LMWD would be very valuable, since this system could constrain the NS mass. To date, unfortunately, radio and X-ray searches for NS companions to LMWDs have been unsuccessful \citep{vLeeuwen07,agueros09b,agueros09a,kilic13}.

For each LMWD in the ELM sample, spectroscopy provides $\period$, the primary WD mass $M_1$, and the projected orbital velocity $K=v \sin i$. Assuming circular orbits, we can write:
\begin{equation}
	\frac{(M_2 \sin i)^3}{\left(M_1+M_2\right)^2} = \frac{\period}{2\pi G} K^3, \label{eq:massfunc}
\end{equation}
where the right side is the mass function $\mf$. The companion mass, $M_2$, is minimized for an edge-on orbit ($i = 90\degree$). Because of this dependence on $i$, the nature of the companion cannot usually be determined based on $\mf$ alone. Figure~\ref{fig:Porb-M1} shows that the population of LMWDs with pulsar companions occupies the same region in $M_1 - \period$ space as those with WD companions. Therefore, barring rare circumstances such as eclipsing systems, individual LMWDs with NS companions cannot be identified from optical observations alone.

The ELM sample is now large enough that the $M_2$ distribution and NS companion fraction can be constrained statistically. %These constraints provide important tests for population synthesis models.
We have developed a probabilistic model to infer parameters of an assumed form for the $M_2$ distribution. Our method is similar to that employed by \citet{ozel12} and \citet{kiziltan13} to describe the mass distribution of NSs in binaries using post-Keplerian parameters. We focus on the following questions: Can the companion population be modeled using a simple description of $M_2$? How does the $M_2$ distribution compare to predictions from population synthesis simulations?  What is the rate of LMWD-NS binaries implied by our model? What are the resulting distributions of NS probabilities for individual systems in the ELM sample?

To answer these questions, we build the mathematical framework (Section 2), then test our resulting model (Section 3). We apply our model to the ELM sample (Section 4) before concluding (Section 5).

\begin{figure}[h!]
\begin{center}
\includegraphics[angle=90,width=0.95\columnwidth]{f1.eps}
\caption{The $M_1$ - $\period$ distribution of the ELM sample (circles) and the known WD-NS binaries (triangles). The three eclipsing systems in the ELM sample with known $M_2$ are shown as filled circles, and the masses of the ELM WDs without detected RV variations are shown by the arrows. From $M_1$ and $\period$ alone, the two populations are indistinguishable.}
\label{fig:Porb-M1}
\end{center}
\end{figure}

\section{Building our model}
We construct a statistical model to constrain a parametric model for the distribution of LMWD companion masses, $p(M_2 \given \bs{\theta})$.\footnote{We represent vectors or sets of parameters or quantities by bold symbols.} For each system, we assume we have $K$, $T$, and $M_1$, and therefore know $\mf$. We wish to derive posterior constraints on the model parameters, $\bs{\theta}$, which describe the distribution of companion masses, $p(M_2\given \bs{\theta})$, given the set of observed mass functions, $\bs{m_f}$, by deconvolving the $\mf$ distribution from the unobserved inclinations. Using Bayes' rule,
\begin{equation}
    p(\bs{\theta} \given \bs{\mf}) = \frac{1}{\mathcal{Z}}~p(\bs{\mf} \given \bs{\theta})~p(\bs{\theta}),
\end{equation}
where $p(\bs{\mf} \given \bs{\theta})$ is the likelihood, $p(\bs{\theta})$ is the prior on parameters $\bs{\theta}$, and the evidence integral, $\mathcal{Z}$, is a constant that depends only on the data. The likelihood, $p(\bs{\mf} \given \bs{\theta})$, can be split into a product over the likelihoods of individual systems:
\begin{equation}
p(\bs{\mf} \given \bs{\theta}) = \prod_j p(\mf \given \bs{\theta}),
\end{equation}
where the product is over each of the $j$ systems.  This marginal likelihood involves integrals over the unobserved quantities $i$ and $M_2$,
\begin{align}
    p(\mf \given \bs{\theta}) &= \int_0^\infty dM_2 \int_0^{\pi/2} di  \nonumber \\
      & \qquad {} \times p(\mf \given M_1, M_2, i)~p(M_2 \given \bs{\theta})~p(i).
\end{align}
We neglect observational uncertainties in $\mf$ and $M_1$,\footnote{The fractional uncertainties in these quantities are small, $\sigma_x / x \sim 0.05-0.1$ \citep{gianninas14}.} and assume the inclination angles are isotropically distributed:
\begin{equation}
	p(\mf \given M_1, M_2, i) = \delta \left[\mf - f(M_1, M_2, i) \right],
\end{equation}
where
\begin{equation}
	f(M_1, M_2, i) = \frac{(M_2 \sin i)^3}{(M_1 + M_2)^2}
\end{equation}
and
\begin{equation}
p(i) = \sin i.
\end{equation}
For now, we do not specify a parametric form for the companion mass distribution, $p(M_2 \given \bs{\theta})$. With the above assumptions, the marginal likelihood integral is:
\begin{align}
    p(\mf \given \bs{\theta}) &= \int_{0}^\infty dM_2 ~p(M_2 \given \bs{\theta})  \nonumber \\
    & \qquad {} \times \int_0^{\pi/2} di ~\sin i ~ \delta \left[g(M_1,M_2,i) \right]\label{eq:delta},
\end{align}
where
\begin{equation}
	g(M_1,M_2,i) = \mf - \frac{M_2^3}{(M_1+M_2)^2}\sin^3 i.
\end{equation}
The inner integral (over $i$) has the form:
\begin{equation}
    \int dx~F(x)~\delta \left[ G(x) \right] = \sum_j \frac{F(x^*_j)}{|G'(x^*_j)|},
\end{equation}
where the sum is over the roots, $x^*_j$, of the function $G(x)$. The root, $i^*$, and derivative of the argument of the delta function in \eqn\ref{eq:delta} are:
\begin{align}
	\sin i^* &= \frac{ \left[\mf(M_1+M_2)^2 \right]^{1/3}}{M_2}, \\
	\frac{\partial g}{\partial i}\bigg\rvert_{i^*} &= \frac{3M_2^3}{(M_1+M_2)^2} \sin^2 i^* \sqrt{1 - \sin^2 i^*}.
\end{align}
We may rewrite the marginal likelihood as:
\begin{align}
	p(\mf \given \bs{\theta}) &= \int_{0}^\infty dM_2~p(M_2 \given \bs{\theta})~\sin i^* \left(\frac{\partial g}{\partial i}\bigg\rvert_{i^*}\right)^{-1}\\
	&= \int_{M_{2,{\rm min}}}^\infty dM_2~p(M_2 \given \bs{\theta})~h(M_2, \mf, M_1). \label{eq:fullm2}
\end{align}
The bottom bound in the integral in \eqn\ref{eq:fullm2} is set by the minimum companion mass for which the integrand is real, $M_{2,{\rm min}}$, determined by setting $i=90\degree$ in \eqn\ref{eq:massfunc} and solving for $M_2$, and

\begin{equation}
h(M_2, \mf, M_1) = \frac{(M_1+M_2)^{4/3}}{3\ \mf^{1/3}M_2\sqrt{M_2^2 - \left[ \mf(M_1+M_2)^2 \right]^{2/3}}}.
\end{equation}

\subsection{Our Model} \label{sec:experiments}
We must now choose a functional form for the companion mass distribution, $p(M_2\given \bs{\theta})$. We use a two-component Gaussian mixture model. We truncate the distributions using physically motivated bounds: the WD component is restricted to $M_2\in [0.2,\wdupper]~\Msun$ and the NS component is restricted to $M_2\in [1.3,2.0]~\Msun$. We then have:
\begin{align}
	p(M_2 \given \bs{\theta}) &= \left[ (1-f_{\rm NS})~p_{\rm WD} + f_{\rm NS}~p_{\rm NS} \right],
\end{align}
where $f_{\rm NS}$ is the NS fraction and
\begin{align}
	p_{\rm WD} &= \mathcal{N}(M_2 \given \mu_{\rm WD}, \sigma^2_{\rm WD}); ~0.2 < \frac{M_2}{\Msun} < \wdupper, \\
	p_{\rm NS} &= \mathcal{N}(M_2 \given \mu_{\rm NS}, \sigma^2_{\rm NS}); ~1.3 < \frac{M_2}{\Msun} < 2.
\end{align}
$\mathcal{N}$ is the (truncated, but properly normalized) normal distribution with mean $\mu$, variance $\sigma^2$; the distributions are limited to the ranges specified. To reduce the number of parameters in our model we fix $\mu_{\rm NS}$ and $\sigma_{\rm NS}$
%$\mu_{\rm NS} = 1.4~\Msun$ and $\sigma_{\rm NS} = 0.05~\Msun$,
to:
\begin{align}
	\mu_{\rm NS} &= 1.4~\Msun, \\
	\sigma_{\rm NS} &= 0.05~\Msun,
\end{align}
as some NSs in binaries may be somewhat more massive than the canonical NS mass of 1.35 \Msun~\citep{kiziltan13,smedley14}.

The probability of any particular WD having a NS companion, $P_{\rm NS}$, can be computed for a given set of parameters for the $M_2$ distribution:
\begin{equation}
P_{\rm NS} = \frac{\int_{M_{2,{\rm min}}}^{\infty} dM_2~ f_{\rm NS}~ p_{\rm NS}~ h(M_2, \mf, M_1)}{p(\mf \given \bs{\theta})}. \label{eq:P_NS}
\end{equation}

Our companion mass model parameters are then $\bs{\theta} = (\mu_{\rm WD}, \sigma_{\rm WD}, f_{\rm NS})$. For $\mu_{\rm WD}$, we use a uniform prior from $0.2-1.0~\Msun$; for $\sigma_{\rm WD}$, we use a logarithmic (scale-invariant) prior over the range $0.02-2.0~\Msun$. Finally, we use a uniform prior over the dimensionless $f_{\rm NS}$ from $0-1$. The model parameters are summarized in Table~\ref{tbl:parameters}.

\renewcommand{\arraystretch}{1.405}
\begin{deluxetable}{ccccc}
	\tablecaption{Model Results \label{tbl:parameters}}

	\tablehead{
		\multicolumn{2}{c}{} &
		\colhead{$\mu_{\rm WD}$} &
		\colhead{$\sigma_{\rm WD}$} &
		\colhead{$f_{\rm NS}$} \\
		\colhead{} &
		\colhead{} &
		\colhead{[\Msun]} &
		\colhead{[\Msun]} &
		\colhead{}
	}

	\startdata
		\multicolumn{2}{c}{\multirow{2}{*}{Priors}} & $\mathcal{U}(0.2, 1)$ & $\propto \sigma^{-1}$  & $\mathcal{U}(0, 1)$ \\
		\multicolumn{2}{c}{} & & $(0.02 < \sigma/\Msun < 2.0)$ & \\
		\cutinhead{Test Cases}
		\multirow{2}{*}{Test 1} & True & 0.7 & 0.2 & 0 \\
		 & MAP & 0.72 & 0.20 & 0.0 \\
		 \hline
		\multirow{2}{*}{Test 2} & True & 0.7 & 0.2 & 0.10 \\
		 & MAP & 0.74 & 0.19 & 0.11 \\
		 \hline
		\multirow{2}{*}{Test 3} & True & \nodata & \nodata & 0.10 \\
		 & MAP & 0.63 & 0.52 & 0.14 \\
		 \hline
		\multirow{2}{*}{PCEB} & True & \nodata & \nodata & 0 \\
		 & MAP & 0.58 & 0.16 & 0.0 \\
		 \cutinhead{ELM Sample}
		 & MAP & 0.74 & 0.24 & 0.0
	\enddata

	\tablecomments{Parameter information for the form of the $M_2$ distribution used in the tests described in Section~\ref{sec:tests}. $\mathcal{U}$ is the uniform distribution. We additionally fix the NS mass distribution: $\mu_{\rm NS} = 1.4~\Msun$ and $\sigma_{\rm NS} = 0.05~\Msun.$}\

\end{deluxetable}

We use a Markov Chain Monte Carlo algorithm \citep{goodman10} to draw samples from the posterior distribution, $p(\mu_{\rm WD}, \sigma_{\rm WD}, f_{\rm NS} \given \bs{m}_f, \bs{M}_1)$.\footnote{Our model uses {\tt emcee}, implemented in \texttt{Python} \citep{foremanmackey13}.} The algorithm uses an ensemble of individual ``walkers'' to naturally adapt to the geometry of the parameter-space being explored. We run the walkers for a burn-in period of 500 steps starting from randomly drawn initial conditions (sampled from the priors in Table~\ref{tbl:parameters}). We then re-initialize the walkers from their positions at the end of this run and run again for 1000 steps. We remove the burn-in samples to eliminate any effects due to our choice of initial conditions.

\section{Testing Our Model} \label{sec:tests}
We test the performance of this Gaussian mixture model on four separate data sets: three mock data sets and a sample of SDSS post-common-envelope binaries \citep[PCEBs;][]{nebot11}.
Each of the 100 systems in our three mock data sets is generated by computing a $\mf$ from a random $M_1$ (drawn from a uniform distribution, $\mathcal{U}(0.2,0.4)~\Msun$), $M_2$ (from the distributions described below), and $i$ (from an isotropic distribution).
%the companion mass from the particular distributions described below, then using a randomly drawn $i$ and $M_1$ to compute $\mf$. We draw $M_1$ from a uniform distribution, $\mathcal{U}(0.2,0.4)~\Msun$.
We apply the same Gaussian mixture model to all four tests to infer the parameters of the WD mixture component and $f_{\rm NS}$.

\begin{figure*}[h!]
\begin{center}
\includegraphics[width=0.95\textwidth]{f2.pdf}
\caption{Results from testing the first two mock data sets described in Section~\ref{sec:tests}. The left-most panels show the companion masses (gray histogram) randomly drawn from each of our test distributions and our MAP models (black line). Panels in the second and third columns show samples from the posterior distributions of $\mu_{\rm WD}$ and $\sigma_{\rm WD}$ and $f_{\rm NS}$. Contours designate the 68\% and 95\% confidence levels. Dashed lines in these panels show the true values from which the sample systems were drawn. The fourth panel shows individual mock LMWD systems (ordered by increasing $\mf$) and their corresponding $P_{\rm NS}$ distribution. Tick marks along the bottom indicate inputed LMWD-NS systems.}
\label{fig:tests_1_2}
\end{center}
\end{figure*}

\subsection{Test 1: Single Gaussian (WD)} \label{sec:exp1}
We first generate companion masses by drawing from a single, truncated Gaussian with the parameters given in Table~\ref{tbl:parameters}. This mock sample contains no NSs. In the top row of Figure~\ref{fig:tests_1_2}, the left-most panel shows that our model finds a maximum a posteriori (MAP) $M_2$ distribution (black line) that qualitatively matches the input distribution (gray histogram). The second and third panels show samples from the posterior distributions and contours containing 68\% and 95\% of the samples for our three model parameters. The input values (dashed lines) lie cleanly within the inner contour in both panels, although $f_{\rm NS}$ has a tail up to $\approx$10\%.

%The second panel shows samples from the posterior distribution and contours containing 68\% and 95\% of the samples. The input values lie cleanly within the inner contour in both projections of the posterior.
%the model preference toward higher masses and smaller standard deviations is due to statistical noise from our randomly generated mock sample.
%The third panel shows that, although the posterior $f_{\rm NS}$ distribution is consistent with 0\%, there is a tail up to $\approx$10\%.

Equation~\ref{eq:P_NS} gives the probability of an individual system hosting a NS. Using posterior samples, we can determine the distribution of $P_{\rm NS}$ for each system. The right-most panel in Figure~\ref{fig:tests_1_2} includes all the individual systems, ordered by $\mf$, and shows the distributions of $P_{\rm NS}$ for each. For most systems, there is negligible probability above $P_{\rm NS}\sim 5\%$.

\subsection{Test 2: Two Gaussians (WD + NS)} \label{sec:exp2}
We use the same Gaussian distribution to generate companion masses for the WDs but add a NS component with $f_{\rm NS} = 10\%$. The bottom row of Figure~\ref{fig:tests_1_2} shows that our model again recovers the input values for $\mu_{\rm WD}$ and $\sigma_{\rm WD}$.
%As in Test 1, the model preference for higher $\mu_{\rm WD}$ and lower $\sigma_{\rm WD}$ is due to our randomly generated mass distribution.
Importantly, the third panel shows that our model also recovers $f_{\rm NS}$, although the posterior shows a substantial tail toward higher $f_{\rm NS}$. Tick marks in the right-most panel of Figure~\ref{fig:tests_1_2} indicate ``true" NSs in our mock data. Our model correctly assigns high $P_{\rm NS}$ to roughly half of these. However, many systems with NS companions have inclinations too low to be statistically differentiated from those with WD companions.

\subsection{Test 3: Uniform (WD) + Gaussian (NS)} \label{sec:exp3}
We generate companion masses for the WDs by sampling from a uniform distribution over $[0.2,1.2]~\Msun$, again with $f_{\rm NS}=$10\%. The top row of Figure~\ref{fig:tests_3_4} shows the results. The posterior distribution in the second panel indicates that $\mu_{\rm WD}$ and $\sigma_{\rm WD}$ are not well constrained. The preference for larger $\sigma_{\rm WD}$ is expected, as the model flattens the Gaussian model distribution to match it with the input uniform distribution. Interestingly, the third panel shows that despite having a non-Gaussian input distribution for $M_2$, and a poorly constrained $\sigma_{\rm WD}$, our model still recovers $f_{\rm NS}$ approximately as accurately as in Test 2. Furthermore, the fourth panel of Figure~\ref{fig:tests_3_4} demonstrates that our model effectively identifies which LMWDs host NS companions.

\subsection{Test 4: PCEBs} \label{sec:PCEB}
PCEBs are composed of WDs in close orbits with main-sequence companions. The \citet{nebot11} sample of 54 SDSS PCEBs, which have precisely determined $K$, $\period$, and masses for the main-sequence companions, are an ideal test sample for our model. Our model uses these parameters to try and recover the PCEBs WD mass distribution, which we can then compare to the spectroscopically determined WD masses.
%Our model is ignorant of the spectroscopically measured WD masses and attempts to fit the WD mass distribution based on the measured main sequence mass, $K$, and $\period$. We use a sample of 54 SDSS PCEBs with spectroscopically derived $K$, $\period$, and main sequence masses \citep{nebot11}.
Our MAP distribution (black line) is shown in the left-most panel in the bottom row of Figure~\ref{fig:tests_3_4}. Our model qualitatively recovers the true $M_{\rm WD}$ distribution (gray histogram). The third panel shows that the posterior $f_{\rm NS}$ distribution is very low, as expected since there are no NS companions in the PCEB sample. This is further illustrated in the right-most panel, where every PCEB in the sample has low $P_{\rm NS}$ values.

\begin{figure*}[h!]
\begin{center}
\includegraphics[width=0.95\textwidth]{f3.pdf}
\caption{ The results of our model when applied to our third mock data set and the SDSS PCEB sample. The panels are same as those in Figure~\ref{fig:tests_1_2}.}
\label{fig:tests_3_4}
\end{center}
\end{figure*}

\section{Applying our model}
\subsection{The ELM Sample}
The ELM WD Survey is based on the Hypervelocity Star Survey \citep{brown06}, and includes previously identified SDSS LMWDs \citep{eisenstein06,liebert04}. Objects are chosen for spectroscopic follow-up based on their $ugr$ colors, and this choice is independent of the mass and nature of any putative companions. Therefore, at least with regard to $i$ and $M_2$, the population is unbiased.

The ELM WD sample includes 55 systems with RV variations fit to orbital solutions, which provide precise measurements of $\period$ and $K$. WD masses in these systems are derived from fits to spectroscopic templates, which are generally precise to $\approx$10\% \citep{gianninas14}. The masses of cool LMWDs may suffer somewhat from inaccuracies in the one-dimensional WD atmospheric models \citep{tremblay13}. However, since this should only affect the coolest WDs in the ELM sample, we expect any impact on our results to be minor.

Three systems are eclipsing binaries, with known companion masses: NLTT 11748 \citep[$M_2=0.72~\Msun$;][]{kaplan14}, SDSS J065133.3$+$284423.3 \citep[$M_2=0.50~\Msun$;][]{brown11b}, and SDSS J075141.2$-$014120.9 \citep[$M_2=0.97~\Msun$;][]{kilic14}. For these systems, the likelihood reduces to:
\begin{equation}
p(\mf \given \theta) = (1-f_{\rm NS}) \mathcal{N}(M_2^* \given \mu_{\rm WD}, \sigma^2_{\rm WD}),
\end{equation}
where $M_2^*$ is the mass of the WD companion.

The other six ELM systems show no evidence of orbital motion, with RV upper limits of $\approx$20-50 km s$^{-1}$. Some of these systems may be in low $i$ binaries with RVs below the detection limit, or may have $\period\approx24$ hr, which is difficult to measure \citep{ELMV}. These LMWDs could also have companions at systematically longer $\period$, resulting in orbital velocities below the detection limit. We do not include these systems in our analysis.
% TO ADD?: They could also not have companions at all - reference goes here

\begin{figure*}[h!]
\begin{center}
\includegraphics[width=0.95\textwidth]{f4.pdf}
\caption{Results from applying our model to the ELM WDs.
The panels are the same as in Figures~\ref{fig:tests_1_2} and \ref{fig:tests_3_4}.
%The leftmost panel of the top row shows that the MAP model $M_{\rm WD}$ distribution matches the histogram of true masses in the PCEB sample.
%The second and third panels show the posterior distributions for our model parameters, while the fourth panel shows the $P_{\rm NS}$ values for each of the PCEBs (ordered by increasing $\mf$).
The left-most panel shows both the MAP $M_2$ distribution (solid black) and random samples from the posterior (gray lines).
%The second panel shows that the MAP Gaussian model has $\mu_{\rm WD}= 0.71~\Msun$ and $\sigma_{\rm WD}= 0.26~\Msun$. The third panel shows posterior samples of $\mu$ and $f_{\rm NS}$. The last panel indicates that several LMWDs in the ELM sample have high $P_{\rm NS}$.
The three systems in the right-most panel with all $P_{\rm NS} = 0\%$ are the eclipsing systems with measured $M_2$.
}
\label{fig:ELM_post}
\end{center}
\end{figure*}

\subsection{Results and Discussion}
The results from applying our model to the ELM sample are shown in Figure~\ref{fig:ELM_post}. The MAP model gives $\mu_{\rm WD} = 0.74~\Msun$, $\sigma_{\rm WD} = 0.24~\Msun$, and $f_{\rm NS} = 0\%$. The marginal posterior over $\mu_{\rm WD}$ and $\sigma_{\rm WD}$ has a tail toward larger $\sigma_{\rm WD}$, which could indicate that the true WD distribution may not be exactly Gaussian.

It is interesting that the best-fit Gaussian for the companions to the ELM WDs is similar to that of the population of single hydrogen-atmosphere WDs in SDSS, with a mean of 0.6 $\Msun$ \citep{kleinman13}. Our distribution is significantly wider: $\sigma \approx 0.26~\Msun$, compared to $\sigma \approx 0.1~\Msun$, possibly due to past mass transfer phases increasing the masses of the unseen primary WDs.

The low combined mass in these systems indicates that, although several of them will merge within a Hubble time \citep{ELMV}, the majority of the ELM systems are unlikely to be type Ia SN progenitors. However, we cannot rule out the possibility that some individual LMWD binaries may be massive enough to produce type Ia SNe \citep{justham09}.
%Several of these systems will merge within a Hubble time \citep{ELMV}, but their sub-Chandrasekhar combined mass would suggest that they are more likely to be underluminous type .Ia, rather than Ia, supernova progenitors.
%Our results are independent of astrophysical expectations, as they do not include informative priors on $\mu_{\rm WD}$ and $\sigma_{\rm WD}$, apart from limits for $M_2$ of 0.2 \Msun\,(based on observations of LMWDs) and \wdupper~\Msun\,(based on the Chandrasekhar mass). In principle, priors could be added based on

Our posterior distributions further suggest that the companions to LMWDs have predominantly CO cores. This is in contrast to population synthesis models, which suggest that LMWDs should predominantly have He-core WD companions \citep{toonen12}. With a larger sample, a more sophisticated LMWD companion model could place quantitative constraints on population synthesis predictions.

The third panel in Figure~\ref{fig:ELM_post} shows a $f_{\rm NS}$ strongly peaked toward 0\%. However, there is a significant tail toward higher NS probabilities. Our model indicates $f_{\rm NS} <16\%$ at the 68\% confidence level, in agreement with independent constraints from \citet[][$f_{\rm NS}<18\pm5$\%]{vLeeuwen07} and \citet[][$f_{\rm NS}<10\substack{+4 \\ -2}~\%$]{agueros09b}, both based on radio non-detections of LMWD companions.

The right-most panel in Figure~\ref{fig:ELM_post} indicates there are two LMWDs with substantial $P_{\rm NS}$: SDSS J081133.6$+$022556.8 and J174140.5$+$652638.7. However, the X-ray non-detection of SDSS J174140.5$+$652638.7 suggests its companion is unlikely to be a NS \citep{kilic14}. Searches for radio and X-ray emission from SDSS J081133.6$+$022556.8 are on-going. We note that the $P_{\rm NS}$ distributions in each of our samples show a trend such that systems with higher $\mf$ have higher $P_{\rm NS}$ values. These high $\mf$ systems are therefore ideal targets to search for NS companions to LMWDs.

\section{Conclusions}
We have developed a statistical model to infer the companion mass distribution for a sample of single-line, spectroscopic binaries. This model can be applied to any such sample with measured $M_1$ and $\mf$. When tested on three separate mock data sets with unseen WD and NS companions to LMWDs, our model recovers the input parameters. Even when the companion mass distribution is not drawn from a Gaussian distribution, our model still infers the input NS fraction to within a few percent. We further apply our model to the SDSS PCEBs \citep{nebot11}, and our model qualitatively recovers the independent, spectroscopically measured $M_{\rm WD}$ distribution.

We applied our model to the set of LMWDs from the ELM WD survey. The resulting posterior distribution is qualitatively similar to our two-component Gaussian test case, suggesting that the companion mass distribution to the LMWDs in the ELM sample is well-described by our model. Our model returns a MAP $\mu_{\rm WD} = 0.74\pm0.24\ \Msun$, suggesting that a majority of ELM WDs have CO-core WD companions. This is in contrast to predictions from population synthesis models, which find that the dominant companion population should be He-core WDs \citep[e.g.,][]{toonen12}. Our model further indicates that the fraction of ELM WDs with NS companions is consistent with 0\%, but could be as high as $\approx$16\% (within 1-$\sigma$). Finally, our model identifies the LMWD SDSS J081133.6$+$022556.8 as having the highest median probability of hosting a NS companion.

To determine the probability of any particular LMWD hosting a NS, we make our model posteriors publicly available on fig{\bf share}.\footnote{\url{http://dx.doi.org/10.6084/m9.figshare.1206621}} We further provide a {\tt Python} script that calculates $P_{\rm NS}$ and the mass distribution for a WD companion for any LMWD with a measured $M_1$ and $\mf$. This script can be applied to newly discovered LMWDs as well as those already in the ELM sample.

There are several ways in which our model can be expanded. By modeling photometric variability, \citet{hermes14} recently constrained the inclination of 20 LMWDs in the ELM sample; we could include these constraints. Furthermore, our model can place tighter constraints on $f_{\rm NS}$ by factoring in radio and X-ray non-detections. We plan to develop our method to quantitatively compare our model to the results of population synthesis codes, potentially constraining the formation of LMWDs.

\acknowledgements
The authors thank David Hogg, DJ D'Orazio, and Josh Peek for useful discussions, and the organizers of the \emph{AstroData Hack Week} (2014). We are grateful to the anonymous referees for comments that helped improve this paper. MAA acknowledges support provided by the NSF through grant AST-1255419. APW is supported by a NSF Graduate Research Fellowship under grant No.\ 11-44155. This research made use of Astropy, a community-developed core \texttt{Python} package for Astronomy \citep{astropy13}. \\

\bibliographystyle{apj}

\begin{thebibliography}{43}
\expandafter\ifx\csname natexlab\endcsname\relax\def\natexlab#1{#1}\fi

\bibitem[{{Ag{\"u}eros} {et~al.}(2009{\natexlab{a}}){Ag{\"u}eros}, {Camilo},
  {Silvestri}, {Kleinman}, {Anderson}, \& {Liebert}}]{agueros09b}
{Ag{\"u}eros}, M.~A., {Camilo}, F., {Silvestri}, N.~M., {Kleinman}, S.~J.,
  {Anderson}, S.~F., \& {Liebert}, J.~W. 2009{\natexlab{a}}, \apj, 697, 283

\bibitem[{{Ag{\"u}eros} {et~al.}(2009{\natexlab{b}}){Ag{\"u}eros}, {Heinke},
  {Camilo}, {Kilic}, {Anderson}, {Freire}, {Kleinman}, {Liebert}, \&
  {Silvestri}}]{agueros09a}
{Ag{\"u}eros}, M.~A. {et~al.} 2009{\natexlab{b}}, \apjl, 700, L123

\bibitem[{{Antoniadis} {et~al.}(2012){Antoniadis}, {van Kerkwijk}, {Koester},
  {Freire}, {Wex}, {Tauris}, {Kramer}, \& {Bassa}}]{antoniadis12}
{Antoniadis}, J., {van Kerkwijk}, M.~H., {Koester}, D., {Freire}, P.~C.~C.,
  {Wex}, N., {Tauris}, T.~M., {Kramer}, M., \& {Bassa}, C.~G. 2012, \mnras,
  423, 3316

\bibitem[{{Astropy Collaboration} {et~al.}(2013){Astropy Collaboration},
  {Robitaille}, {Tollerud}, {Greenfield}, {Droettboom}, {Bray}, {Aldcroft},
  {Davis}, {Ginsburg}, {Price-Whelan}, {Kerzendorf}, {Conley}, {Crighton},
  {Barbary}, {Muna}, {Ferguson}, {Grollier}, {Parikh}, {Nair}, {Unther},
  {Deil}, {Woillez}, {Conseil}, {Kramer}, {Turner}, {Singer}, {Fox}, {Weaver},
  {Zabalza}, {Edwards}, {Azalee Bostroem}, {Burke}, {Casey}, {Crawford},
  {Dencheva}, {Ely}, {Jenness}, {Labrie}, {Lim}, {Pierfederici}, {Pontzen},
  {Ptak}, {Refsdal}, {Servillat}, \& {Streicher}}]{astropy13}
{Astropy Collaboration} {et~al.} 2013, \aap, 558, A33

\bibitem[{{Bassa} {et~al.}(2006){Bassa}, {van Kerkwijk}, {Koester}, \&
  {Verbunt}}]{bassa06}
{Bassa}, C.~G., {van Kerkwijk}, M.~H., {Koester}, D., \& {Verbunt}, F. 2006,
  \aap, 456, 295

\bibitem[{{Brown} {et~al.}(2006){Brown}, {Geller}, {Kenyon}, \&
  {Kurtz}}]{brown06}
{Brown}, W.~R., {Geller}, M.~J., {Kenyon}, S.~J., \& {Kurtz}, M.~J. 2006, \apj,
  647, 303

\bibitem[{{Brown} {et~al.}(2013){Brown}, {Kilic}, {Allende Prieto},
  {Gianninas}, \& {Kenyon}}]{ELMV}
{Brown}, W.~R., {Kilic}, M., {Allende Prieto}, C., {Gianninas}, A., \&
  {Kenyon}, S.~J. 2013, \apj, 769, 66

\bibitem[{{Brown} {et~al.}(2010){Brown}, {Kilic}, {Allende Prieto}, \&
  {Kenyon}}]{ELMI}
{Brown}, W.~R., {Kilic}, M., {Allende Prieto}, C., \& {Kenyon}, S.~J. 2010,
  \apj, 723, 1072

\bibitem[{{Brown} {et~al.}(2012){Brown}, {Kilic}, {Allende Prieto}, \&
  {Kenyon}}]{ELMIII}
---. 2012, \apj, 744, 142

\bibitem[{{Brown} {et~al.}(2011){Brown}, {Kilic}, {Hermes}, {Allende Prieto},
  {Kenyon}, \& {Winget}}]{brown11b}
{Brown}, W.~R., {Kilic}, M., {Hermes}, J.~J., {Allende Prieto}, C., {Kenyon},
  S.~J., \& {Winget}, D.~E. 2011, \apjl, 737, L23

\bibitem[{{Callanan} {et~al.}(1998){Callanan}, {Garnavich}, \&
  {Koester}}]{callanan98}
{Callanan}, P.~J., {Garnavich}, P.~M., \& {Koester}, D. 1998, \mnras, 298, 207

\bibitem[{{Eisenstein} {et~al.}(2006){Eisenstein}, {Liebert}, {Harris},
  {Kleinman}, {Nitta}, {Silvestri}, {Anderson}, {Barentine}, {Brewington},
  {Brinkmann}, {Harvanek}, {Krzesi{\'n}ski}, {Neilsen}, {Long}, {Schneider}, \&
  {Snedden}}]{eisenstein06}
{Eisenstein}, D.~J. {et~al.} 2006, \apjs, 167, 40

\bibitem[{{Foreman-Mackey} {et~al.}(2013){Foreman-Mackey}, {Hogg}, {Lang}, \&
  {Goodman}}]{foremanmackey13}
{Foreman-Mackey}, D., {Hogg}, D.~W., {Lang}, D., \& {Goodman}, J. 2013, \pasp,
  125, 306

\bibitem[{{Gianninas} {et~al.}(2014){Gianninas}, {Dufour}, {Kilic}, {Brown},
  {Bergeron}, \& {Hermes}}]{gianninas14}
{Gianninas}, A., {Dufour}, P., {Kilic}, M., {Brown}, W.~R., {Bergeron}, P., \&
  {Hermes}, J.~J. 2014, \apj, 794, 35

\bibitem[Goodman~\&\ Weare(2010)]{goodman10}
Goodman,~J. \& Weare,\ J.
2010, Comm.\ App.\ Math.\ Comp.\ Sci., 5, 65

\bibitem[{{Han}(1998)}]{han98}
{Han}, Z. 1998, \mnras, 296, 1019

\bibitem[{{Hermes} {et~al.}(2014){Hermes}, {Brown}, {Kilic}, {Gianninas},
  {Chote}, {Sullivan}, {Winget}, {Bell}, {Falcon}, {Winget}, {Mason},
  {Harrold}, \& {Montgomery}}]{hermes14}
{Hermes}, J.~J. {et~al.} 2014, \apj, 792, 39

\bibitem[{{Justham} {et~al.}(2009){Justham}, {Wolf}, {Podsiadlowski}, \&
  {Han}}]{justham09}
{Justham}, S., {Wolf}, C., {Podsiadlowski}, P., \& {Han}, Z. 2009, \aap, 493,
  1081

\bibitem[{{Kaplan} {et~al.}(2014){Kaplan}, {Marsh}, {Walker}, {Bildsten},
  {Bours}, {Breedt}, {Copperwheat}, {Dhillon}, {Howell}, {Littlefair},
  {Shporer}, \& {Steinfadt}}]{kaplan14}
{Kaplan}, D.~L. {et~al.} 2014, \apj, 780, 167

\bibitem[{{Kilic} {et~al.}(2011){Kilic}, {Brown}, {Allende Prieto},
  {Ag{\"u}eros}, {Heinke}, \& {Kenyon}}]{ELMII}
{Kilic}, M., {Brown}, W.~R., {Allende Prieto}, C., {Ag{\"u}eros}, M.~A.,
  {Heinke}, C., \& {Kenyon}, S.~J. 2011, \apj, 727, 3

\bibitem[{{Kilic} {et~al.}(2012){Kilic}, {Brown}, {Allende Prieto}, {Kenyon},
  {Heinke}, {Ag{\"u}eros}, \& {Kleinman}}]{ELMIV}
{Kilic}, M., {Brown}, W.~R., {Allende Prieto}, C., {Kenyon}, S.~J., {Heinke},
  C.~O., {Ag{\"u}eros}, M.~A., \& {Kleinman}, S.~J. 2012, \apj, 751, 141

\bibitem[{{Kilic} {et~al.}(2013){Kilic}, {Gianninas}, {Brown}, {Harris},
  {Dahn}, {Ag{\"u}eros}, {Heinke}, {Kenyon}, {Panei}, \& {Camilo}}]{kilic13}
{Kilic}, M. {et~al.} 2013, \mnras, 434, 3582

\bibitem[{{Kilic} {et~al.}(2014){Kilic}, {Hermes}, {Gianninas}, {Brown},
  {Heinke}, {Ag{\"u}eros}, {Chote}, {Sullivan}, {Bell}, \& {Harrold}}]{kilic14}
---. 2014, \mnras, 438, L26

\bibitem[{{Kilic} {et~al.}(2007){Kilic}, {Stanek}, \& {Pinsonneault}}]{kilic07}
{Kilic}, M., {Stanek}, K.~Z., \& {Pinsonneault}, M.~H. 2007, \apj, 671, 761

\bibitem[{{Kiziltan} {et~al.}(2013){Kiziltan}, {Kottas}, {De Yoreo}, \&
  {Thorsett}}]{kiziltan13}
{Kiziltan}, B., {Kottas}, A., {De Yoreo}, M., \& {Thorsett}, S.~E. 2013, \apj,
  778, 66

\bibitem[{{Kleinman} {et~al.}(2013){Kleinman}, {Kepler}, {Koester}, {Pelisoli},
  {Pe{\c c}anha}, {Nitta}, {Costa}, {Krzesinski}, {Dufour}, {Lachapelle},
  {Bergeron}, {Yip}, {Harris}, {Eisenstein}, {Althaus}, \&
  {C{\'o}rsico}}]{kleinman13}
{Kleinman}, S.~J. {et~al.} 2013, \apjs, 204, 5

\bibitem[{{Liebert} {et~al.}(2004){Liebert}, {Bergeron}, {Eisenstein},
  {Harris}, {Kleinman}, {Nitta}, \& {Krzesinski}}]{liebert04}
{Liebert}, J., {Bergeron}, P., {Eisenstein}, D., {Harris}, H.~C., {Kleinman},
  S.~J., {Nitta}, A., \& {Krzesinski}, J. 2004, \apjl, 606, L147

\bibitem[{{Marsh} {et~al.}(1995){Marsh}, {Dhillon}, \& {Duck}}]{marsh95}
{Marsh}, T.~R., {Dhillon}, V.~S., \& {Duck}, S.~R. 1995, \mnras, 275, 828

\bibitem[{{Maxted} {et~al.}(2000){Maxted}, {Marsh}, \& {Moran}}]{maxted00}
{Maxted}, P.~F.~L., {Marsh}, T.~R., \& {Moran}, C.~K.~J. 2000, \mnras, 319, 305

\bibitem[{{Nebot G{\'o}mez-Mor{\'a}n} {et~al.}(2011){Nebot
  G{\'o}mez-Mor{\'a}n}, {G{\"a}nsicke}, {Schreiber}, {Rebassa-Mansergas},
  {Schwope}, {Southworth}, {Aungwerojwit}, {Bothe}, {Davis}, {Kolb},
  {M{\"u}ller}, {Papadaki}, {Pyrzas}, {Rabitz}, {Rodr{\'{\i}}guez-Gil},
  {Schmidtobreick}, {Schwarz}, {Tappert}, {Toloza}, {Vogel}, \&
  {Zorotovic}}]{nebot11}
{Nebot G{\'o}mez-Mor{\'a}n}, A. {et~al.} 2011, \aap, 536, A43

\bibitem[{{Nelemans} {et~al.}(2005){Nelemans}, {Napiwotzki}, {Karl}, {Marsh},
  {Voss}, {Roelofs}, {Izzard}, {Montgomery}, {Reerink}, {Christlieb}, \&
  {Reimers}}]{nelemans05}
{Nelemans}, G. {et~al.} 2005, \aap, 440, 1087

\bibitem[{{Nelemans} {et~al.}(2000){Nelemans}, {Verbunt}, {Yungelson}, \&
  {Portegies Zwart}}]{nelemans00}
{Nelemans}, G., {Verbunt}, F., {Yungelson}, L.~R., \& {Portegies Zwart}, S.~F.
  2000, \aap, 360, 1011

\bibitem[{{Nelemans} {et~al.}(2001){Nelemans}, {Yungelson}, {Portegies Zwart},
  \& {Verbunt}}]{nelemans01}
{Nelemans}, G., {Yungelson}, L.~R., {Portegies Zwart}, S.~F., \& {Verbunt}, F.
  2001, \aap, 365, 491

\bibitem[{{{\"O}zel} {et~al.}(2012){{\"O}zel}, {Psaltis}, {Narayan}, \& {Santos
  Villarreal}}]{ozel12}
{{\"O}zel}, F., {Psaltis}, D., {Narayan}, R., \& {Santos Villarreal}, A. 2012,
  \apj, 757, 55

\bibitem[{{Rebassa-Mansergas} {et~al.}(2011){Rebassa-Mansergas}, {Nebot
  G{\'o}mez-Mor{\'a}n}, {Schreiber}, {Girven}, \& {G{\"a}nsicke}}]{rebassa11}
{Rebassa-Mansergas}, A., {Nebot G{\'o}mez-Mor{\'a}n}, A., {Schreiber}, M.~R.,
  {Girven}, J., \& {G{\"a}nsicke}, B.~T. 2011, \mnras, 413, 1121

\bibitem[{{Smedley} {et~al.}(2014){Smedley}, {Tout}, {Ferrario}, \&
  {Wickramasinghe}}]{smedley14}
{Smedley}, S.~L., {Tout}, C.~A., {Ferrario}, L., \& {Wickramasinghe}, D.~T.
  2014, \mnras, 437, 2217

\bibitem[{{Toonen} {et~al.}(2012){Toonen}, {Nelemans}, \& {Portegies
  Zwart}}]{toonen12}
{Toonen}, S., {Nelemans}, G., \& {Portegies Zwart}, S. 2012, \aap, 546, A70

\bibitem[{{Tremblay} {et~al.}(2013){Tremblay}, {Ludwig}, {Steffen}, \&
  {Freytag}}]{tremblay13}
{Tremblay}, P.-E., {Ludwig}, H.-G., {Steffen}, M., \& {Freytag}, B. 2013, \aap,
  559, A104

\bibitem[{{van der Sluys} {et~al.}(2006){van der Sluys}, {Verbunt}, \&
  {Pols}}]{vdSluys06}
{van der Sluys}, M.~V., {Verbunt}, F., \& {Pols}, O.~R. 2006, \aap, 460, 209

\bibitem[{{van Kerkwijk} {et~al.}(1996){van Kerkwijk}, {Bergeron}, \&
  {Kulkarni}}]{vKerkwijk96}
{van Kerkwijk}, M.~H., {Bergeron}, P., \& {Kulkarni}, S.~R. 1996, \apjl, 467,
  L89

\bibitem[{{van Leeuwen} {et~al.}(2007){van Leeuwen}, {Ferdman}, {Meyer}, \&
  {Stairs}}]{vLeeuwen07}
{van Leeuwen}, J., {Ferdman}, R.~D., {Meyer}, S., \& {Stairs}, I. 2007, \mnras,
  374, 1437

\bibitem[{{Woods} {et~al.}(2012){Woods}, {Ivanova}, {van der Sluys}, \&
  {Chaichenets}}]{woods12}
{Woods}, T.~E., {Ivanova}, N., {van der Sluys}, M.~V., \& {Chaichenets}, S.
  2012, \apj, 744, 12

\bibitem[{{York} {et~al.}(2000){York}, {Adelman}, {Anderson}, {Anderson},
  {Annis}, {Bahcall}, {Bakken}, {Barkhouser}, {Bastian}, {Berman}, {Boroski},
  {Bracker}, {Briegel}, {Briggs}, {Brinkmann}, {Brunner}, {Burles}, {Carey},
  {Carr}, {Castander}, {Chen}, {Colestock}, {Connolly}, {Crocker}, {Csabai},
  {Czarapata}, {Davis}, {Doi}, {Dombeck}, {Eisenstein}, {Ellman}, {Elms},
  {Evans}, {Fan}, {Federwitz}, {Fiscelli}, {Friedman}, {Frieman}, {Fukugita},
  {Gillespie}, {Gunn}, {Gurbani}, {de Haas}, {Haldeman}, {Harris}, {Hayes},
  {Heckman}, {Hennessy}, {Hindsley}, {Holm}, {Holmgren}, {Huang}, {Hull},
  {Husby}, {Ichikawa}, {Ichikawa}, {Ivezi{\'c}}, {Kent}, {Kim}, {Kinney},
  {Klaene}, {Kleinman}, {Kleinman}, {Knapp}, {Korienek}, {Kron}, {Kunszt},
  {Lamb}, {Lee}, {Leger}, {Limmongkol}, {Lindenmeyer}, {Long}, {Loomis},
  {Loveday}, {Lucinio}, {Lupton}, {MacKinnon}, {Mannery}, {Mantsch}, {Margon},
  {McGehee}, {McKay}, {Meiksin}, {Merelli}, {Monet}, {Munn}, {Narayanan},
  {Nash}, {Neilsen}, {Neswold}, {Newberg}, {Nichol}, {Nicinski}, {Nonino},
  {Okada}, {Okamura}, {Ostriker}, {Owen}, {Pauls}, {Peoples}, {Peterson},
  {Petravick}, {Pier}, {Pope}, {Pordes}, {Prosapio}, {Rechenmacher}, {Quinn},
  {Richards}, {Richmond}, {Rivetta}, {Rockosi}, {Ruthmansdorfer}, {Sandford},
  {Schlegel}, {Schneider}, {Sekiguchi}, {Sergey}, {Shimasaku}, {Siegmund},
  {Smee}, {Smith}, {Snedden}, {Stone}, {Stoughton}, {Strauss}, {Stubbs},
  {SubbaRao}, {Szalay}, {Szapudi}, {Szokoly}, {Thakar}, {Tremonti}, {Tucker},
  {Uomoto}, {Vanden Berk}, {Vogeley}, {Waddell}, {Wang}, {Watanabe},
  {Weinberg}, {Yanny}, {Yasuda}, \& {SDSS Collaboration}}]{york00}
{York}, D.~G. {et~al.} 2000, \aj, 120, 1579

\end{thebibliography}

%\bibliography{refs}

%\bibitem[Goodman~\&\ Weare(2010)]{goodman10}
%Goodman,~J. \& Weare,\ J.
%2010, Comm.\ App.\ Math.\ Comp.\ Sci., 5, 65

\end{document}


\section{Particle representation}
\label{sect:amplitudes}
\index{amplitude}
\index{spin}
\index{representation}
\index{scalar particle}
\index{vector particle}
\index{tensor particle}
\index{spin 1/2 particle}
\index{photon}
\index{neutrino}

Particles with spin up to spin 2, with the exception of spin 3/2,
are handled by classes within the framework of EvtGen.\footnote{
Other particles will be added as need arises.
}
This
section will describe how spin degrees of freedom are
represented, and will introduce the classes that represent
particles in EvtGen.  Table~\ref{tab:reps} summarizes the different
types of particles currently implemented.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{ccccl} \hline
Class name     &  Rep. &  J   &  States   & Example \\ \hline
EvtScalarParticle   &  1    &   0  &    1      &  $\pi$, $B^0$ \\
EvtDiracParticle    & $u_{\alpha}$& 1/2 & 2       &  $e$, $\tau$ \\
EvtNeutrinoParticle & $u_{\alpha}$& 1/2 & 1       &  $\nu_e$ \\
EvtVectorParticle   & $\epsilon^{\mu}$ & 1 & 3&  $\rho$, $J/\Psi$ \\
EvtPhotonParticle   & $\epsilon^{\mu}$ & 1 & 2&  $\gamma$ \\
EvtTensorParticle   & $T^{\mu\nu}$ & 2 & 5 &   $D^*_2$, $f_2$ \\ \hline
\end{tabular}
\caption{The different types of particles that supported by EvtGen.
The spin 3/2, Rarita-Schwinger, representation has not yet been
implemented.
\label{tab:reps}}
\end{center}
\end{table}

In Table~\ref{tab:reps}, $u_{\alpha}$
represents a four component Dirac spinor,
defined in the Pauli-Dirac convention for the
gamma matrices, as discussed in Section~\ref{sect:diracspinor}.
The {\tt EvtDiracParticle} class represents
massive spin 1/2 particles that have
two spin degrees of freedom. Neutrinos are also represented
with a 4-component Dirac spinor by the {\tt EvtNeutrinoParticle}
class.  Neutrinos are assumed to
be massless and only left handed neutrinos and
right handed anti-neutrinos
are considered.

The complex 4-vector
$\epsilon^{\mu}$ is used to represent
the spin degrees of freedom for
spin 1 particles.  Massive spin 1 particles, represented
by the {\tt EvtVectorParticle} class,
have three degrees of freedom.  The
{\tt EvtPhotonParticle} class represents massless
spin 1 particles, which have only two (longitudinal)
degrees of freedom.

Massive spin 2 particles are represented
with a complex symmetric rank 2 tensor and are
implemented in the {\tt EvtTensorParticle}
class.

For each particle initialized in EvtGen, a set of
basis states is created, where the number of basis states is
the same as the number of spin degrees of freedom.
These basis states can be accessed
through the {\tt EvtParticle} class
in either the particle's rest frame or in
the parent's rest frame. For massless particles, only states
in the parent's rest frame are available.
As an example, consider the basis
for a massive spin 1 particle in it's own rest frame
\begin{eqnarray}
\epsilon^{\mu}_1&=&(0,1,0,0),\\
\epsilon^{\mu}_2&=&(0,0,1,0),\\
\epsilon^{\mu}_3&=&(0,0,0,1).
\end{eqnarray}
Note that these basis vectors are mutually orthogonal, and
normalized. That is,
\begin{equation}
g_{\mu\nu}\epsilon^{*\mu}_i\epsilon^{\nu}_j=\delta_{ij}.
\end{equation}
Further, they form a complete set
\begin{equation}
\sum_i\epsilon^{*\mu}_i\epsilon^{\nu}_i=g^{\mu\nu}-p^{\mu}p^{\nu}/m^2,
\end{equation}
where $g^{\mu\nu}-p^{\mu}p^{\nu}/m^2$
is the propagator for an on-shell spin 1 particle.

In order to write a new decay model, there
is no reason to need to know the exact choice of
these basis states.  The code needed to describe the amplitude
for a decay process is independent of these states, as
long as they are complete, orthogonal and normalized.