## FCSys.Utilities.Means

Package of mathematical mean functions

### Information

Extends from Modelica.Icons.Package (Icon for standard packages).

### Package Content

Name | Description
--- | ---
arithmetic | Return the arithmetic mean of numbers
harmonic | Return the harmonic mean of numbers

## FCSys.Utilities.Means.arithmetic

Return the arithmetic mean of numbers

### Information

Example:
`arithmetic({1,2,3})` returns 2.

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
Real | u[:] |  | Vector of numbers

### Outputs

Type | Name | Description
--- | --- | ---
Real | mean | Arithmetic mean

### Modelica definition

    function arithmetic "Return the arithmetic mean of numbers"
      extends Modelica.Icons.Function;
      input Real u[:] "Vector of numbers";
      output Real mean "Arithmetic mean";

    algorithm
      mean := sum(u)/size(u, 1);
    end arithmetic;

## FCSys.Utilities.Means.harmonic

Return the harmonic mean of numbers

### Information

Example:
`harmonic({1,1/3})` returns 0.5.

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
Real | u[:] |  | Vector of numbers

### Outputs

Type | Name | Description
--- | --- | ---
Real | mean | Harmonic mean

### Modelica definition

    function harmonic "Return the harmonic mean of numbers"
      extends Modelica.Icons.Function;
      input Real u[:] "Vector of numbers";
      output Real mean "Harmonic mean";

    algorithm
      mean := if size(u, 1) == 1 then u[1] else size(u, 1)/sum(1/u for u in u);
    end harmonic;