philsupertramp/game-math
|
Go to the source code of this file.
Classes | |
struct | LinearModel |
Enumerations | |
enum | P_NORM { Inf , One , Eukl } |
Functions | |
double | getExponent (double x) |
double | round (double x, int precision) |
double | abs (double x) |
double | pow (double x, int exponent) |
double | norm (const Matrix< double > &vec, P_NORM pNorm) |
double | cov (const Matrix< double > &x, const Matrix< double > &y) |
double | var (const Matrix< double > &x) |
Matrix< double > | sd (const Matrix< double > &x, int axis=0) |
LinearModel | lm (const Matrix< double > &x, const Matrix< double > &y) |
double | coefficientOfDetermination (const Matrix< double > &y, const Matrix< double > &yHat) |
double | likelihood (const Matrix< double > &) |
Matrix< double > | Regression (const Matrix< double > &A) |
Matrix< double > | corr (const Matrix< double > &A, const Matrix< double > &B) |
Matrix< double > | expected_value (const Matrix< double > &A) |
Contains methods of the field of probability calculation.
enum P_NORM |
double abs | ( | double | x | ) |
Absolute value $$|x|$$
x | a value |
The coefficient of determination ($R^2$) is the proportion of the variation in the dependent variable that is predictable from independent variables.
$$R^2 = \frac{\text{var}(y)}{\text{var}(\hat{y})}$$
y | $$y$$ |
yHat | $$\hat{y}$$ |
Computes correlation matrix of two matrices
$$ \text{corr}(X, Y) = \frac{\text{cov}(X, Y)}{\sigma_X\sigma_Y} $$ with $\sigma$ the standard deviations of $X$ and $Y$.
The correlation matrix contains correlation coefficients $\text{corr}_{x_i, y_i} \in [-1, 1]$.
A | the first matrix of values |
B | second matrix of values in same shape as A |
Computes covariance of two given vectors $$\text{cov}(x, y) = E[(x - E[x])(y - E[y])]$$
The covariance is a measure of joint variability of two random variables.
x | a vector |
y | another vector |
Computes the expected value of a given vector.
$$ E[X] = \sum x_i P(x_i) $$
The expected value is a generalization of the weighted average. Given a set of random values, the expected value is the value that is most likely to occur within given distribution of values.
A | the matrix to caclulate the expected value(s) of, each row will receive a corresponding expected value |
double getExponent | ( | double | x | ) |
regular helpers Method to calculate exponent of given value
x | value to calculate exponent of |
double likelihood | ( | const Matrix< double > & | ) |
Computes likelihood
LinearModel lm | ( | const Matrix< double > & | x, |
const Matrix< double > & | y | ||
) |
Computes linear (regression) model for given random sample $$ (Y_i; X_i) $$ $$ Y_i = \beta_0 + \beta_1\phi_1(x_i) + \epsilon_i $$
x | $$X_i$$ |
y | $$Y_i$$ |
Calculates the Norm of a given vector
vec | vector to calculate the norm of |
pNorm | desired norm to compute |
double pow | ( | double | x, |
int | exponent | ||
) |
calculates $$x^{exponent}$$
x | a value |
exponent | desired exponent |
Computes orthogonal-linear regression for given values A, mapped onto points $$P(i, a_i)$$.
$$Y_i = \beta_0 + \beta_1 * a_i$$
A | vector of y-values |
double round | ( | double | x, |
int | precision | ||
) |
Rounds double value to given precision, cuts off other elements
x | value to round |
precision | precision in resulting value |
Computes standard deviation of given vector $$ \text{sd}(x) = \sigma(x) = \sqrt{E[(X-\mu)^2]} = \sqrt{E[X^2] - (E[X])^2} $$
The standard deviation is a measure of variance or dispersion of a set of values.
x | set of values to compute standard deviation from @returnss standard deviation of given x |
double var | ( | const Matrix< double > & | x | ) |
Computes variance of given vector $$\text{var}(x)=E[(X - \mu)^2] = \text{cov}(X,X)$$
The variance is the expectation of the square deviation of a random variable from its population mean or sample mean.
x | a vector |