Correlation - Maple Help

Student[Statistics]

 Correlation
 compute the correlation

 Calling Sequence Correlation(X, Y, numeric_option, inert_option) Correlation(A, B, numeric_option) Correlation(M, numeric_option)

Parameters

 X - algebraic; random variable Y - algebraic; random variable A - B - M - numeric_option - (optional) equation of the form numeric=value where value is true or false inert_option - (optional) equation of the form inert=value where value is true or false

Description

 • The Correlation function computes the correlation of two data samples or the correlation of multiple data samples in a Matrix.
 • The first parameter can be a data sample (given as e.g. a Vector), a Matrix data sample, a random variable, or an algebraic expression involving random variables (see Student[Statistics][RandomVariable]).
 • If the option inert is not included or is specified to be inert=false, then the function will return the actual value of the result. If inert or inert=true is specified, then the function will return the formula of evaluating the actual value.

Computation

 • By default, all computations involving random variables are performed symbolically (see option numeric below).
 • If there are floating point values or the option numeric is included, then the computation is done in floating point. Otherwise the computation is exact.
 • By default, the correlation is computed according to the rules mentioned above. To always compute the correlation numerically, specify the numeric or numeric = true option.

Examples

 > $\mathrm{with}\left(\mathrm{Student}\left[\mathrm{Statistics}\right]\right):$
 > $U≔\mathrm{seq}\left(57..77\right)$
 ${U}{≔}{57}{,}{58}{,}{59}{,}{60}{,}{61}{,}{62}{,}{63}{,}{64}{,}{65}{,}{66}{,}{67}{,}{68}{,}{69}{,}{70}{,}{71}{,}{72}{,}{73}{,}{74}{,}{75}{,}{76}{,}{77}$ (1)
 > $V≔\mathrm{seq}\left(\mathrm{sin}\left(i\right),i=57..77\right)$
 ${V}{≔}{\mathrm{sin}}{}\left({57}\right){,}{\mathrm{sin}}{}\left({58}\right){,}{\mathrm{sin}}{}\left({59}\right){,}{\mathrm{sin}}{}\left({60}\right){,}{\mathrm{sin}}{}\left({61}\right){,}{\mathrm{sin}}{}\left({62}\right){,}{\mathrm{sin}}{}\left({63}\right){,}{\mathrm{sin}}{}\left({64}\right){,}{\mathrm{sin}}{}\left({65}\right){,}{\mathrm{sin}}{}\left({66}\right){,}{\mathrm{sin}}{}\left({67}\right){,}{\mathrm{sin}}{}\left({68}\right){,}{\mathrm{sin}}{}\left({69}\right){,}{\mathrm{sin}}{}\left({70}\right){,}{\mathrm{sin}}{}\left({71}\right){,}{\mathrm{sin}}{}\left({72}\right){,}{\mathrm{sin}}{}\left({73}\right){,}{\mathrm{sin}}{}\left({74}\right){,}{\mathrm{sin}}{}\left({75}\right){,}{\mathrm{sin}}{}\left({76}\right){,}{\mathrm{sin}}{}\left({77}\right)$ (2)
 > $\mathrm{Correlation}\left(\left[U,\mathrm{undefined}\right],\left[V,2\right]\right)$
 ${\mathrm{undefined}}$ (3)
 > $\mathrm{Correlation}\left(\mathrm{Vector}\left[\mathrm{row}\right]\left(\left[1,2\right]\right),\mathrm{Vector}\left[\mathrm{column}\right]\left(\left[\mathrm{\pi },2\right]\right)\right)$
 $\frac{\left({1}{-}\frac{{\mathrm{\pi }}}{{2}}\right){}\sqrt{{2}}}{\sqrt{{\left(\frac{{\mathrm{\pi }}}{{2}}{-}{1}\right)}^{{2}}{+}{\left({1}{-}\frac{{\mathrm{\pi }}}{{2}}\right)}^{{2}}}}$ (4)

If the computation contains floating point values or the numeric option is included, then a floating point value will be returned.

 > $\mathrm{Correlation}\left(\mathrm{Vector}\left[\mathrm{row}\right]\left(\left[1,2.0\right]\right),\mathrm{Vector}\left[\mathrm{column}\right]\left(\left[\mathrm{\pi },2\right]\right)\right)$
 ${-0.999999999566904}$ (5)
 > $\mathrm{Correlation}\left(\mathrm{Vector}\left[\mathrm{row}\right]\left(\left[1,2\right]\right),\mathrm{Vector}\left[\mathrm{column}\right]\left(\left[\mathrm{\pi },2\right]\right),\mathrm{numeric}\right)$
 ${-1.00000000000000}$ (6)

Compute the correlation between two random variables.

 > $A≔\mathrm{NormalRandomVariable}\left(a,b\right):$
 > $B≔\mathrm{NormalRandomVariable}\left(c,d\right):$
 > $\mathrm{Correlation}\left(A+B,B\right)$
 $\frac{{c}{}{a}{+}{{c}}^{{2}}{+}{{d}}^{{2}}{-}{c}{}\left({a}{+}{c}\right)}{\sqrt{{{b}}^{{2}}{+}{{d}}^{{2}}}{}{d}}$ (7)
 > $P≔\mathrm{NormalRandomVariable}\left(2,3\right):$
 > $Q≔\mathrm{NormalRandomVariable}\left(1,4\right):$
 > $\mathrm{Correlation}\left(P+Q,Q\right)$
 $\frac{{4}}{{5}}$ (8)

Use the inert option.

 > $X≔\mathrm{PoissonRandomVariable}\left(3\right):$
 > $\mathrm{Correlation}\left(X,X,\mathrm{inert}\right)$
 $\frac{\left({\sum }_{{\mathrm{_t}}{=}{0}}^{{\mathrm{\infty }}}{}\frac{{{\mathrm{_t}}}^{{2}}{}{{3}}^{{\mathrm{_t}}}{}{{ⅇ}}^{{-3}}}{{\mathrm{_t}}{!}}\right){-}\left({\sum }_{{\mathrm{_t0}}{=}{0}}^{{\mathrm{\infty }}}{}\frac{{\mathrm{_t0}}{}{{3}}^{{\mathrm{_t0}}}{}{{ⅇ}}^{{-3}}}{{\mathrm{_t0}}{!}}\right){}\left({\sum }_{{\mathrm{_t1}}{=}{0}}^{{\mathrm{\infty }}}{}\frac{{\mathrm{_t1}}{}{{3}}^{{\mathrm{_t1}}}{}{{ⅇ}}^{{-3}}}{{\mathrm{_t1}}{!}}\right)}{\sqrt{{\sum }_{{\mathrm{_t3}}{=}{0}}^{{\mathrm{\infty }}}{}\frac{{\left({\mathrm{_t3}}{-}\left({\sum }_{{\mathrm{_t2}}{=}{0}}^{{\mathrm{\infty }}}{}\frac{{\mathrm{_t2}}{}{{3}}^{{\mathrm{_t2}}}{}{{ⅇ}}^{{-3}}}{{\mathrm{_t2}}{!}}\right)\right)}^{{2}}{}{{3}}^{{\mathrm{_t3}}}{}{{ⅇ}}^{{-3}}}{{\mathrm{_t3}}{!}}}{}\sqrt{{\sum }_{{\mathrm{_t5}}{=}{0}}^{{\mathrm{\infty }}}{}\frac{{\left({\mathrm{_t5}}{-}\left({\sum }_{{\mathrm{_t4}}{=}{0}}^{{\mathrm{\infty }}}{}\frac{{\mathrm{_t4}}{}{{3}}^{{\mathrm{_t4}}}{}{{ⅇ}}^{{-3}}}{{\mathrm{_t4}}{!}}\right)\right)}^{{2}}{}{{3}}^{{\mathrm{_t5}}}{}{{ⅇ}}^{{-3}}}{{\mathrm{_t5}}{!}}}}$ (9)
 > $\mathrm{Correlation}\left(X,X,\mathrm{numeric}\right)$
 ${0.9999999999}$ (10)
 > $M≔\mathrm{Matrix}\left(\left[\left[4,2,1\right],\left[\mathrm{undefined},2.0,4\right],\left[\mathrm{\pi },4,2\right]\right]\right)$
 ${M}{≔}\left[\begin{array}{ccc}{4}& {2}& {1}\\ {\mathrm{undefined}}& {2.0}& {4}\\ {\mathrm{\pi }}& {4}& {2}\end{array}\right]$ (11)
 > $\mathrm{Correlation}\left(M\right)$
 $\left[\begin{array}{ccc}{\mathrm{undefined}}& {Float}{}\left({\mathrm{undefined}}\right)& {\mathrm{undefined}}\\ {Float}{}\left({\mathrm{undefined}}\right)& {1.}& {-0.188982236506435}\\ {\mathrm{undefined}}& {-0.188982236506435}& {1}\end{array}\right]$ (12)

References

 Stuart, Alan, and Ord, Keith. Kendall's Advanced Theory of Statistics. 6th ed. London: Edward Arnold, 1998. Vol. 1: Distribution Theory.

Compatibility

 • The Student[Statistics][Correlation] command was introduced in Maple 18.