Home

Statistical analysis on the Android platform

Last week a new release of AWork (version 2.0) was submitted to Google Play  (see the AWork link). Finally it supports Android 8+ devices with high resolution screens. AWork is a complete programming environment for Android devices that can execute standard Java syntax and extends it with scripting conveniences of BeanShell. At the same time, it allows to use scientific Java libraries to perform complex mathematical and statistical calculations with scientific graphs. In addition, it can be used to execute Matlab/Octave style- programs.

Project documentation

Here is a simple example: We will create a Gamma distribution, fill a histograms, and calculate (and pint) basic descriptive statistics of the Gamma distribution. We will use the BeanShell syntax to write the code.

import jhplot.*;
import java.util.Random;
import cern.jet.random.engine.*;
import cern.jet.random.*;
import jhplot.math.StatisticSample;

h=new H1D(“test1”,50,0,10);
engine=new MersenneTwister();
Events=5000;
r=new Gamma(1,0.5,engine);
for (i=0; i<Events; i++)  h.fill(r.nextDouble());
print(h.getStat()); // print statistics of this histogram
c=new HChart();
c.add(h);
c.update();

This code will show a zoom-able histogram with data.

Here is another example. We will create 1000 numbers distributed using a Log-normal distribution and look at descriptive statistics of this distribution:

import jhplot.*;
import jhplot.math.StatisticSample;
a=StatisticSample.randomLogNormal(1000,0,10);
p0=new P0D(a); // convert to an array
print (p0.getStatString()); // detailed characteristics

The output is:

Size: 1000 Sum: 2.0795326321690155E11 
SumOfSquares: 1.7220728312882923E22
Min: 4.3681673233597326E-14
Max: 1.187289072883721E11
Mean: 2.0795326321690154E8
RMS: 4.149786538230963E9
Variance: 1.7194678431631997E19
Standard deviation: 4.14664664899627E9
Standard error: 1.3112848062732977E8
Geometric mean: 0.7193930848008395
Product: 9.252494313364321E-144
Harmonic mean: 2.2976022239249115E-11
Sum of inversions: 4.352363475222164E13
Skew: 25.65476598759878
Kurtosis: 694.7699433878664
Moment(0,0): 1.0
Moment(1,0): 2.0795326321690154E8
Moment(2,0): 1.7220728312882924E19
Moment(3,0): 1.839916709064571E30
25%, 50%, 75% Quantiles: 0.0012310644573427145 0.9530465118707188, 535.0653267374155
....

Wow. That’s a lot of characteristics of this distribution  (too many to print!). Look at this project and make use of it for your statistical calculations!

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *