Contents

# 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:

v=[1,10,20,2,4,7,4,3]
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)

# Correlations

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

v1=[1,10,20,2,4,7,4,3]
v2=[3,11,10,3,5,5,7,3]
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:

a=-0.001:0.0001:0
y=normal_prob(a)
plot2d()
draw2d(a,y) % draw areas under the normal distribution for a vector