Basic Statistics Functions

Prev Next

Function Names

average, average ignore zero, average ignore blanks, variance, variance ignore zero, variance ignore blanks, deviation, deviation ignore zero, deviation ignore blanks, rms, rms ignore zero, rms ignore blanks, geometric mean, geometric mean ignore zero, geometric mean ignore blanks, median, median ignore zero, product, product ignore zero, product ignore blanks, sum, parallel, harmonic mean

Description

These functions identify the minimum or maximum numeric values. Following rules apply

  • The suffix ... ignore zero ignores all 0 (zero) values and blank values (otherwise treated as zero)
  • The suffix ... ignore blanks ignores blanks, but not 0 (zero) values.

Standard approach Ignore zero Ignore blanks Description
average average ignore zoero average ignore blanks Sum of all applicable values divided by the count. Also known as mean
variance variance ignore zero variance ignore blanks Measure of how far numbers spread out from their average
deviation deviation ignore zero deviation ignore blanks Square root of variance
rms rms ignore zero rms ignore blanks Root mean square: Applicable values squared, averaged, and square root applied. Also known as quadratic mean.
geometric mean geometric mean ignore zero geometric mean ignore blanks n-th root of product of all applicable values where n is the number of alues multiplied together.
median median ignore zero (always ignored) Identifes the middle value with half of all values below and half of all values above
product product ignore zero product ignore blanks All applicable values are multiplied together
parallel (always ignored) (always ignored) Resistors-in-parallel formula (sum of inverted value, inverted) = 1/( 1/x1 + 1/x2 + ... + 1/xn )
harmonic mean (always ignored) (always ignored) Also known as Average of rates, calculated = n/( 1/x1 + 1/x2 + ... + 1/xn )

Please note that equivalent conditional combination functions are also available for the function names listed above which allows you to pre-select specific parameters to include in the calculation using one or more comparisons .

Call as: function

Parameter count

Min 1

Parameters

No.TypeDescription
1, etc.
input
valid types All function parameters:

Same parameter passing principle is applied like other series functions such as add(), sub(), etc.
See Two parameter passing methods for series functions for details..

Return value

TypeDescription
numeral Result

Calculated value

Exceptions

Function names containing 'numeral' assert exceptions if values provided are not of type numeral.

Examples

      echo( average(10,12,14,20 ) );         // returns 14
      echo( average({10,12,14,20}, 1) );     // ~15.33 (1st parameter excluded in this case)
      echo( geometric mean( 10,12,14,20 ) ); // ~13.54
      echo( harmonic mean(10,12,14,20 ) );   //  13.125
      echo( rms(10,12,14,20) );              // ~14.49
      echo( parallel(1,3) );                 //   0.75
      echo( product ignore zero( 0,3,4 ) );  //  12
      echo( product ( 3,"",2) );             //   0
      echo( product ignore blanks(3,"",2) ); //   6

Output

14
15.3333333333
13.5389448554
13.125
14.4913767462
0.75
12
0
6
Try it yourself: Open LIB_Function_average.b4p in B4P_Examples.zip. Decompress before use.

See also

add
mul
median