Skip to content
Francois Vancoppenolle edited this page Jul 25, 2014 · 24 revisions

Previous Chapter          Previous Page          Table of content

Statistics

The purpose of a graphics is to display data in a visual way. People who visualize the graph will have a better comprehension of the data. The theory that is behind this method is called "Descriptive statistics". This is a small part of a wider theory. Another part of statistics computes values; the most kown of them is the mean; but values like the standard deviation, the median, the quartiles are other values that helps to "summarize" lot of data. Through the "stats.js" add-ins module, some of well known statistical values are computed.

statistical values

This chapter lists the statistical values computed by the stats.js module.

  • count_all, count_missing, count_not_missing
    Count_missing : count the number of missing values in the data;
    count_not_missing : count the number of not missing values in the data;
    count_all=count_missing+count_not_missing;

  • sum
    sum : sum of the not missing values;

  • mean
    mean = sum / count_not_missing;

  • sum_square_diff_mean
    sum_square_diff_mean=sum of the (values-mean)^2

  • variance
    variance=sum_square_diff_mean/count_not_missing

  • standard_deviation
    standard_deviation=square root (variance)

  • standard_deviation_estimation
    standard_deviation_estimation=square root(sum_square_diff_mean/(count_not_missing-1))

  • standard_error_mean
    standard_error_mean=square root(sum_square_diff_mean) / count_not_missing;

  • minimum
    minimum of the values

  • maximum
    maximum of the values

  • Q0, Q1, Q5, Q10, Q25, Q50, Q75, Q90, Q95, Q99, Q100
    Qx = the value obtained with following algorith :
    -> The data are ordered;
    -> x% of the data are lower than Qx; (100-x)% of the values are greater than Qx.


The Qx values are computed like they are computed in the SAS software which is a software well know in the statistical world.

Special values :
Q0 : minimum value;
Q100 : maximum value;
  • Median
    median=Q50

  • Interquantile_range
    interquantile_range=Q75-Q50

How to compute the statistical values

If you want to compute the statistal value listed in previous chapter, include the "Add-ins\stats.js" module and call the "stats" function with the parameters data and config.

 <SCRIPT src='..\Add-ins\stats.js'></script>
 (...)
 <SCRIPT>
 var mydata1= {
 (...)
 };
 var statOptions = {
 (...)
 };
 stats(mydata1,statOptions);
 </SCRIPT>

When the "stats(<data>,<options>) has been called, the following values are available :

<data>.stats.<statistic> where <statistic> is one of the value listed in previous chapter.

For instance, <data>.stats.mean, <data>.stats.variance, ... are available.

Example :

 <SCRIPT src='..\Add-ins\stats.js'></script>
 <SCRIPT>
 var mydata1= {
labels : ["January","February","March","April","May","June"],
datasets : [
	{
		fillColor : "rgba(220,220,220,0.5)",
		strokeColor : "rgba(220,220,220,1)",
		pointColor : "rgba(220,220,220,1)",
		pointStrokeColor : "#fff",
		data : [7,10,15,15,13,8],
                    title : "Europe"
	},
	{
		fillColor : "rgba(151,187,205,0.5)",
		strokeColor : "rgba(151,187,205,1)",
		pointColor : "rgba(151,187,205,1)",
		pointStrokeColor : "#fff",
		data : [10,13,12,15,8,15],
                    title : "North-America"
	}
 };
 var statOptions = {
       canvasBorders : true
 };
 stats(mydata1,statOptions);
 </SCRIPT>

When executed the following values are available :

 mydata1.stats.count_all;
 mydata1.stats.count_not_missing:
 mydata1.stats.count_missing;
 mydata1.stats.mean;
 mydata1.stats.variance;
 (...)

This gives statistical value for the whole data. If the data are in the form of data for Lines/Bars/Stacked Bars charts other values are also available :

<data>.datasets[i].stats. -> <statistic> for the data in <data>.datasets[i].data[*].

<data>.stats.col_[j] -> <statistic> for the data in <data>.datasets[*].data[j].

Example : From previous example, following statistics are also available : mydata1.datasets[i].stats.mean (for i=0->1) mydata1.datasets[i].stats.count_all (for i=0->1) mydata1.datasets[i].stats.count_missing (for i=0->1) (...) mydata1.stats.col_mean[j] (for j=0->5) mydata1.stats.col_count_all[j] (for j=0->5) mydata1.stats.count_missing[j] (for j=0->5) (...)

replacement in your data/options

Previous Chapter          Previous Page          Top of Page

Clone this wiki locally