|
static | covariance (array $X, array $Y, bool $population=false) |
| Covariance Convenience method to access population and sample covariance. More...
|
|
static | populationCovariance (array $X, array $Y) |
| Population Covariance A measure of how much two random variables change together. More...
|
|
static | sampleCovariance (array $X, array $Y) |
| Sample covariance A measure of how much two random variables change together. More...
|
|
static | weightedCovariance (array $X, array $Y, array $w) |
| Weighted covariance A measure of how much two random variables change together with weights. More...
|
|
static | r (array $X, array $Y, bool $population=false) |
| r - correlation coefficient Pearson product-moment correlation coefficient (PPMCC or PCC or Pearson's r) More...
|
|
static | populationCorrelationCoefficient (array $X, array $Y) |
| Population correlation coefficient Pearson product-moment correlation coefficient (PPMCC or PCC or Pearson's r) More...
|
|
static | sampleCorrelationCoefficient (array $X, array $Y) |
| Sample correlation coefficient Pearson product-moment correlation coefficient (PPMCC or PCC or Pearson's r) More...
|
|
static | r2 (array $X, array $Y, bool $popluation=false) |
| R² - coefficient of determination Convenience wrapper for coefficientOfDetermination. More...
|
|
static | coefficientOfDetermination (array $X, array $Y, bool $popluation=false) |
| R² - coefficient of determination. More...
|
|
static | weightedCorrelationCoefficient (array $X, array $Y, array $w) |
| Weighted correlation coefficient Pearson product-moment correlation coefficient (PPMCC or PCC or Pearson's r) width weighted values. More...
|
|
static | kendallsTau (array $X, array $Y) |
| τ - Kendall rank correlation coefficient (Kendall's tau) More...
|
|
static | spearmansRho (array $X, array $Y) |
| ρ - Spearman's rank correlation coefficient (Spearman's rho) More...
|
|
static | describe (array $X, array $Y, bool $population=false) |
| Descriptive correlation report about two random variables. More...
|
|
static | confidenceEllipse (array $X, array $Y, float $z, int $num_points=11) |
| Confidence ellipse (error ellipse) Given the data in $X and $Y, create an ellipse surrounding the data at $z standard deviations. More...
|
|
static MathPHP\Statistics\Correlation::kendallsTau |
( |
array |
$X, |
|
|
array |
$Y |
|
) |
| |
|
static |
τ - Kendall rank correlation coefficient (Kendall's tau)
A statistic used to measure the ordinal association between two measured quantities. It is a measure of rank correlation: the similarity of the orderings of the data when ranked by each of the quantities. https://en.wikipedia.org/wiki/Kendall_rank_correlation_coefficient https://onlinecourses.science.psu.edu/stat509/node/158
tau-a (no rank ties):
nc - nd
τ = -------— n(n - 1)/2
Where nc: number of concordant pairs nd: number of discordant pairs
tau-b (rank ties exist):
nc - nd
τ = --------------------------— √(nc + nd + X₀)(nc + nd + Y₀)
Where X₀: number of pairs tied only on the X variable Y₀: number of pairs tied only on the Y variable
- Parameters
-
array | $X | values for random variable X |
array | $Y | values for random variable Y |
- Todo:
- Implement with algorithm faster than O(n²)
- Returns
- float
- Exceptions
-
static MathPHP\Statistics\Correlation::populationCorrelationCoefficient |
( |
array |
$X, |
|
|
array |
$Y |
|
) |
| |
|
static |
Population correlation coefficient Pearson product-moment correlation coefficient (PPMCC or PCC or Pearson's r)
A normalized measure of the linear correlation between two variables X and Y, giving a value between +1 and −1 inclusive, where 1 is total positive correlation, 0 is no correlation, and −1 is total negative correlation. It is widely used in the sciences as a measure of the degree of linear dependence between two variables. https://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient
The correlation coefficient of two variables in a data sample is their covariance divided by the product of their individual standard deviations.
cov(X,Y)
ρxy = -------— σx σy
conv(X,Y) is the population covariance σx is the population standard deviation of X σy is the population standard deviation of Y
- Parameters
-
array | $X | values for random variable X |
array | $Y | values for random variable Y |
- Returns
- float
- Exceptions
-
static MathPHP\Statistics\Correlation::populationCovariance |
( |
array |
$X, |
|
|
array |
$Y |
|
) |
| |
|
static |
Population Covariance A measure of how much two random variables change together.
Average product of their deviations from their respective means. The population covariance is defined in terms of the population means μx, μy https://en.wikipedia.org/wiki/Covariance
cov(X, Y) = σxy = E[⟮X - μx⟯⟮Y - μy⟯]
∑⟮xᵢ - μₓ⟯⟮yᵢ - μy⟯
cov(X, Y) = σxy = --------------— N
- Parameters
-
array | $X | values for random variable X |
array | $Y | values for random variable Y |
- Returns
- float
- Exceptions
-
static MathPHP\Statistics\Correlation::sampleCorrelationCoefficient |
( |
array |
$X, |
|
|
array |
$Y |
|
) |
| |
|
static |
Sample correlation coefficient Pearson product-moment correlation coefficient (PPMCC or PCC or Pearson's r)
A normalized measure of the linear correlation between two variables X and Y, giving a value between +1 and −1 inclusive, where 1 is total positive correlation, 0 is no correlation, and −1 is total negative correlation. It is widely used in the sciences as a measure of the degree of linear dependence between two variables. https://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient
The correlation coefficient of two variables in a data sample is their covariance divided by the product of their individual standard deviations.
Sxy
rxy = -------— sx sy
Sxy is the sample covariance σx is the sample standard deviation of X σy is the sample standard deviation of Y
- Parameters
-
array | $X | values for random variable X |
array | $Y | values for random variable Y |
- Returns
- float
- Exceptions
-
static MathPHP\Statistics\Correlation::sampleCovariance |
( |
array |
$X, |
|
|
array |
$Y |
|
) |
| |
|
static |
Sample covariance A measure of how much two random variables change together.
Average product of their deviations from their respective means. The population covariance is defined in terms of the sample means x, y https://en.wikipedia.org/wiki/Covariance
cov(X, Y) = Sxy = E[⟮X - x⟯⟮Y - y⟯]
∑⟮xᵢ - x⟯⟮yᵢ - y⟯
cov(X, Y) = Sxy = ------------— n - 1
- Parameters
-
array | $X | values for random variable X |
array | $Y | values for random variable Y |
- Returns
- float
- Exceptions
-
static MathPHP\Statistics\Correlation::weightedCorrelationCoefficient |
( |
array |
$X, |
|
|
array |
$Y, |
|
|
array |
$w |
|
) |
| |
|
static |
Weighted correlation coefficient Pearson product-moment correlation coefficient (PPMCC or PCC or Pearson's r) width weighted values.
A normalized measure of the linear correlation between two variables X and Y, giving a value between +1 and −1 inclusive, where 1 is total positive correlation, 0 is no correlation, and −1 is total negative correlation. It is widely used in the sciences as a measure of the degree of linear dependence between two variables. https://en.wikipedia.org/wiki/Pearson_correlation_coefficient#Weighted_correlation_coefficient
The weighted correlation coefficient of two variables in a data sample is their covariance divided by the product of their individual standard deviations.
cov(X,Y,w)
ρxyw = ----------— √(sxw syw)
conv(X,Y, w) is the weighted covariance sxw is the weighted variance of X syw is the weighted variance of Y
- Parameters
-
array | $X | values for random variable X |
array | $Y | values for random variable Y |
array | $w | values for weights |
- Returns
- float
- Exceptions
-