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:
<jc lang="math"> 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) </jc>
Similarly, you can do this for matrices:
<jc lang="math"> 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) </jc>
You can also calculate correlations between two vectors or two matrices. For example, calculate covariance and coefficient of correlations as:
<jc lang="math"> 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) </jc>
Analogously, you can do similar calculations for matrices.
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:
<jc lang="math"> a=-0.001:0.0001:0 y=normal_prob(a) plot2d() draw2d(a,y) % draw areas under the normal distribution for a vector </jc>
One can fill histograms with data from vectors and matricies.
<jc lang="math"> y=poisson_rnd(2,100) h=h1d('Poisson',20,1,10,y) plot2d() draw2d(h) </jc>
Here we create a vector with random numbers distributed using the Poisson statistics. Then we create a histogram with the title "Poisson", 20 bins, in the range between 1 and 10. Then we use draw2d() to display the histogram. You can access the descriptive statistics as for any vector or matrix.
You can create vectors and matrices with random numbers using the major distributions. Look at the package [http:/jwork.org//jmathlab/doc/ random_numbers] for the description of various random-number generators.
For example, let us create a vector and a matrix with the random numbers distributed in accordance with a Poisson distribution (assuming the mean 2):
<jc lang="math"> v=poisson_rnd(2,10) % create vector with 10 elements m=poisson_rnd(2,10,3) % create matrix 10x3 printf('%f',m) % print </jc>