sc_statistic (arr_val, tp_var)

This macro calculates and returns an array with the reported statistical values ​​from an array of numeric values.

Two parameters are required for using the macro.

Parameter Value Description
arr_val

This parameter accepts only variables.

Example of use:
$arr_val = array (5230.01,8374,625.45,8926.34,7000,523.78);
sc_statistic ($ arr_val, $ type);

Variable containing an array with the numeric input values.

Parameter required.

tp_var

This parameter accepts the value or a variable.

Example using value:
sc_statistic ($arr_val, 'P');

Example using a variable:
$type = 'P';
sc_statistic ($arr_val, $type);

List of values ​​accepted in the parameter.

  • P
  • A

This parameter defines the type of calculation of the variance(index 2) and standard deviation(index 3) of the array.

Accepted values ​​are P and A

  • P = Population
  • A = Sampling

Parameter required.

 

This macro returns the calculation in an array with 10 positions, where each position is related to a statistical data.

Check below what each index will return.

Values ​​returned in each index of the array:

Index Value
[0] Arithmetic mean
[1] Median
[2] Variance
[3] Standard deviation
[4] Amplitude
[5] Number of different values
[6] Number of array values
[7] Number of Null values
[8] Lowest value
[9] Highest value

Example of using the macro

$arr_val = array (5230.01.8374,625.45.8926.34,7000,523.78,523.78,6897.21,987.56,987.56,8729,63);

$arr_stat = sc_statistic ($arr_val, 'P');

 

Macro return:

Array
(
    [0] => 4072.3075
    [1] => 3108.785
    [2] => 12817792.489302
    [3] => 3580.1944764638
    [4] => 8863.34
    [5] => 10
    [6] => 12
    [7] => 12
    [8] => 63
    [9] => 8926.34
);