PHP 클래스 MathPHP\Statistics\Correlation

파일 보기 프로젝트 열기: markrogoyski/math-php

공개 메소드들

메소드 설명
R2 ( array $X, array $Y, boolean $popluation = false ) : number R² - coefficient of determination Convenience wrapper for coefficientOfDetermination
coefficientOfDetermination ( array $X, array $Y, boolean $popluation = false ) : number R² - coefficient of determination
covariance ( array $X, array $Y, boolean $population = false ) : number Covariance Convenience method to access population and sample covariance.
describe ( array $X, array $Y, boolean $population = false ) : array Descriptive correlation report about two random variables
kendallsTau ( array $X, array $Y ) : number τ - Kendall rank correlation coefficient (Kendall's tau)
populationCorrelationCoefficient ( array $X, array $Y ) : number Population correlation coefficient Pearson product-moment correlation coefficient (PPMCC or PCC or Pearson's r)
populationCovariance ( array $X, array $Y ) : number Population Covariance A measure of how much two random variables change together.
r ( array $X, array $Y, boolean $popluation = false ) : number r - correlation coefficient Pearson product-moment correlation coefficient (PPMCC or PCC or Pearson's r)
sampleCorrelationCoefficient ( array $X, array $Y ) : number Sample correlation coefficient Pearson product-moment correlation coefficient (PPMCC or PCC or Pearson's r)
sampleCovariance ( array $X, array $Y ) : number Sample covariance A measure of how much two random variables change together.
spearmansRho ( array $X, array $Y ) : number ρ - Spearman's rank correlation coefficient (Spearman's rho)

메소드 상세

R2() 공개 정적인 메소드

R² - coefficient of determination Convenience wrapper for coefficientOfDetermination
public static R2 ( array $X, array $Y, boolean $popluation = false ) : number
$X array values for random variable X
$Y array values for random variable Y
$popluation boolean
리턴 number

coefficientOfDetermination() 공개 정적인 메소드

Indicates the proportion of the variance in the dependent variable that is predictable from the independent variable. Range of 0 - 1. Close to 1 means the regression line is a good fit https://en.wikipedia.org/wiki/Coefficient_of_determination
public static coefficientOfDetermination ( array $X, array $Y, boolean $popluation = false ) : number
$X array values for random variable X
$Y array values for random variable Y
$popluation boolean
리턴 number

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
public static covariance ( array $X, array $Y, boolean $population = false ) : number
$X array values for random variable X
$Y array values for random variable Y
$population boolean
리턴 number

describe() 공개 정적인 메소드

Descriptive correlation report about two random variables
public static describe ( array $X, array $Y, boolean $population = false ) : array
$X array values for random variable X
$Y array values for random variable Y
$population boolean Optional flag if all samples of a population are present
리턴 array [cov, r, R2, tau, rho]

kendallsTau() 공개 정적인 메소드

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
public static kendallsTau ( array $X, array $Y ) : number
$X array values for random variable X
$Y array values for random variable Y
리턴 number

populationCorrelationCoefficient() 공개 정적인 메소드

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
public static populationCorrelationCoefficient ( array $X, array $Y ) : number
$X array values for random variable X
$Y array values for random variable Y
리턴 number

populationCovariance() 공개 정적인 메소드

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
public static populationCovariance ( array $X, array $Y ) : number
$X array values for random variable X
$Y array values for random variable Y
리턴 number

r() 공개 정적인 메소드

Convenience method for population and sample correlationCoefficient
public static r ( array $X, array $Y, boolean $popluation = false ) : number
$X array values for random variable X
$Y array values for random variable Y
$popluation boolean Optional flag for population or sample covariance
리턴 number

sampleCorrelationCoefficient() 공개 정적인 메소드

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
public static sampleCorrelationCoefficient ( array $X, array $Y ) : number
$X array values for random variable X
$Y array values for random variable Y
리턴 number

sampleCovariance() 공개 정적인 메소드

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
public static sampleCovariance ( array $X, array $Y ) : number
$X array values for random variable X
$Y array values for random variable Y
리턴 number

spearmansRho() 공개 정적인 메소드

https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient 6 ∑ dᵢ² ρ = 1 - --------- n(n² − 1) Where dᵢ: the difference between the two ranks of each observation
public static spearmansRho ( array $X, array $Y ) : number
$X array values for random variable X
$Y array values for random variable Y
리턴 number