# LaTex Formula Cheatsheet

This page includes statistics formulas in raw LaTex code. It is painful sometimes to write a complex formula and thus I hope this page is useful for those need to write them. In case you need to find symbols in LaTex, this linked pdf could be useful.

## Latex Code for Correlation Formula

The following are the sample correlation formula and its raw LaTex code.

$r_{xy}=\frac{\sum_{i=1}^{n}((x_i-\bar{x})(y_i-\bar{y}))}{\sqrt{\sum_{i=1}^{n}(x_i-\bar{x})^2}\sqrt{\sum_{i=1}^{n}(y_i-\bar{y})^2}}$

r_{xy}=\frac{\sum_{i=1}^{n}((x_i-\bar{x})(y_i-\bar{y}))}{\sqrt{\sum_{i=1}^{n}(x_i-\bar{x})^2}\sqrt{\sum_{i=1}^{n}(y_i-\bar{y})^2}}

## Latex Code for One-Way ANOVA Formula

The following are one-way ANOVA formulas and their raw LaTex code.

ANOVA is about partitioning the variance into different parts. Sum of Square Total (SSB) is the total variance of all the observations. SSB can be separated into Sum of Squares Between (SSB) and Sum of squares Error (SSE).

$SST=SSB+SSE$

The formulas of SSB and SSE are as follows.

$SSB=\sum_{i=1}^kn_i(\bar{x_i}-\bar{x})^2$

$SSE=\sum_{i=1}^{k}\sum_{j=1}^{n_i}(x_{ij}-\bar{x_i})^2$

SSB=\sum_{i=1}^kn_i(\bar{x_i}-\bar{x})^2
SSE=\sum_{i=1}^{k}\sum_{j=1}^{n_i}(x_{ij}-\bar{x_i})^2

We also need to consider the degree of freedom, which leads to mean squares, namely Mean Square Between (MSB) and Mean Square Error (MSE).

$MSB=\frac{SSB}{k-1}$

$MSE=\frac{SSE}{n-k}$

MSB=\frac{SSB}{k-1}
MSE=\frac{SSE}{n-k}

Finally, the F value is the ratio of MSB and MSE.

$F(k-1,n-k)=\frac{MSB}{MSE}=\frac{\frac{SSB}{k-1}}{\frac{SSE}{n-k}}=\frac{\frac{\sum_{i=1}^kn_i(\bar{x_i}-\bar{x})^2}{k-1}}{\frac{\sum_{i=1}^{k}\sum_{j=1}^{n_i}(x_{ij}-\bar{x_i})^2}{n-k}}$

F(k-1,n-k)=\frac{MSB}{MSE}=\frac{\frac{SSB}{k-1}}{\frac{SSE}{n-k}}=\frac{\frac{\sum_{i=1}^kn_i(\bar{x_i}-\bar{x})^2}{k-1}}{\frac{\sum_{i=1}^{k}\sum_{j=1}^{n_i}(x_{ij}-\bar{x_i})^2}{n-k}}