1 2The \eslmod{stats} module is the foundation of a set of statistics 3modules. It contains special functions like $\Gamma(x)$ and $\Psi(x)$, 4and elementary statistics routines such as linear regression fitting 5and $\chi^2$ testing. Table~\ref{tbl:stats_api} lists the functions in 6the \eslmod{stats} API. 7 8\begin{table}[hbp] 9\begin{center} 10{\small 11\begin{tabular}{|ll|}\hline 12\hyperlink{func:esl_stats_DMean()}{\ccode{esl\_stats\_\{D,F,I\}Mean()}} & Calculates mean and $\sigma^2$ for samples $x_i$.\\ 13\hyperlink{func:esl_stats_LogGamma()}{\ccode{esl\_stats\_LogGamma()}} & Calculates $\log \Gamma(x)$.\\ 14\hyperlink{func:esl_stats_Psi()}{\ccode{esl\_stats\_Psi()}} & Calculates $\Psi(x)$ (the digamma function).\\ 15\hyperlink{func:esl_stats_IncompleteGamma()}{\ccode{esl\_stats\_IncompleteGamma()}} & Calculates the incomplete Gamma function. 16\\ 17\hyperlink{func:esl_stats_ChiSquaredTest()}{\ccode{esl\_stats\_ChiSquaredTest()}} & Calculates a $\chi^2$ P-value.\\ 18\hyperlink{func:esl_stats_LinearRegression()}{\ccode{esl\_stats\_LinearRegression()}} & Fit data to a straight line.\\ 19\hline 20\end{tabular} 21} 22\end{center} 23\caption{The \eslmod{stats} API.} 24\label{tbl:stats_api} 25\end{table} 26 27\subsection{An example of using the stats API} 28 29 30Figure~\ref{fig:stats_example} shows an example of using one of the 31routines in the \eslmod{stats} module, linear regression fitting. It 32generates a set of $n$ points dispersed around a line, $y_i = a + bx + 33N(\sigma)$ with Gaussian noise $N(\sigma)$, then fits the data to a 34line to obtain estimates $\hat{a}$ and $\hat{b}$. 35 36\begin{figure} 37\input{cexcerpts/stats_example} 38\caption{An example of using the \eslmod{stats} module.} 39\label{fig:stats_example} 40\end{figure} 41 42 43 44