JMathLabTutorial:Statistics (Descriptive)

From jWork.ORG
Jump to: navigation, search
Limitted access. Reguest membership or login to this link first if you are already a member

Descriptive Statistics

jMathLab is well suited for statistical calculations. You can calculate the major statistical characteristics for matrices and vectors. Let us calculate mean, variance and standard deviations for a vector:

a=mean(v); printf('%f\n',a)
a=var(v); printf('%f\n',a)
a=std(v); printf('%f\n',a)

Similarly, you can do this for matrices:

v=[1,10,20,2,4,7,4,3; 6,1,2,20,42,7,41,3;]
a=mean(v); printf('%f\n',a)
a=var(v); printf('%f\n',a)
a=std(v); printf('%f\n',a)


You can also calculate correlations between two vectors or two matrices. For example, calculate covariance and coefficient of correlations as:

a=cov(v1,v2);           printf('Covariance=%f\n',a)
a=correlation(v1,v2);   printf('Coeff. correlation=%f\n',a)

Analogously, you can do similar calculations for matrices.

Probability distributions

jMathlab supports custom tailored numerical integration of certain probability distributions. Look at the package statistics_probability in jMathLab reference. As example, normal_prob returns the area under the Normal (Gaussian) probability density function, integrated from minus infinity to x. The argument can be either a number or vector. In the latter case, one can plot such integrals for any sequence of numbers.

Here is an example:

draw2d(a,y) % draw areas under the normal distribution for a vector