Programmer Guide/Command Reference/EVAL/avr: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:avr (alias: avg)}}
=====avr=====
The arithmetic mean function is implemented in two versions.
----
;Usage 1: <code>avr(<var>x</var>)</code>
:;<var>x</var>: a scalar, vector or matrix
;Result 1: The result is the arithmetic mean of all elements of <var>x</var>
----
;Usage 2: <code>avr(<var>x</var>, <var>flag</var>)</code>
:;<var>x</var>: a matrix
:;<var>flag</var>: compute mean of the column vectors (''flag''=0) or the row vectors (''flag''&ne;0) is requsted; ''flag'' must be a scalar
;Result 2:
:*if ''flag''=0: the result ''r'' is the vector of the column means
:::<code>''r''[''i''] = eval avr( ''x''[*,''i''], 0) // ''i'' = 0 .. ncol(''x'')-1</code>
:*otherwise: the result ''r'' is the vector of the row means
:::<code>''r''[''i''] = eval avr( ''x''[''i'',*], 1) // ''i'' = 0 .. nrow(''x'')-1</code>
----
;See also: [[../median|median]], [[../var|var]], [[../dev|dev]], [[../corr|corr]], [[../sum|sum]], [[../hist|hist]],


Compute the arithmetic average.
[[../#Functions|<function list>]]
 
=====Usage:=====
 
<code>avr(<var>x</var>)</code>
 
=====Function:=====
 
Compute the arithmetic average of all elements in <var>x</var>.
 
=====Result:=====
 
The arithmetic average of all the elements.
 
=====Return Type:=====
 
scalar
 
=====Usage:=====
 
<code>avr(<var>x</var>, <var>flag</var>)</code>
 
=====Function:=====
 
Compute the arithmetic average of each column or row of the matrix <var>x</var>.
 
=====Parameters:=====
 
;<var>x</var>
 
:A matrix.
 
;<var>flag</var>
 
:A flag determining whether the returned vector contains elements of the averaged column <code>i</code> (<var>type</var><code>=0</code>) or averaged row <code>i</code> (<var>type</var><code>=1</code>).
 
=====Result:=====
 
A vector with <code>ncol(</code><var>x</var><code>)</code> or <code>nrow(</code><var>x</var><code>)</code> elements.
 
=====Return Type:=====
 
vector

Latest revision as of 08:59, 29 January 2020

The arithmetic mean function is implemented in two versions.


Usage 1
avr(x)
x
a scalar, vector or matrix
Result 1
The result is the arithmetic mean of all elements of x

Usage 2
avr(x, flag)
x
a matrix
flag
compute mean of the column vectors (flag=0) or the row vectors (flag≠0) is requsted; flag must be a scalar
Result 2
  • if flag=0: the result r is the vector of the column means
r[i] = eval avr( x[*,i], 0) // i = 0 .. ncol(x)-1
  • otherwise: the result r is the vector of the row means
r[i] = eval avr( x[i,*], 1) // i = 0 .. nrow(x)-1

See also
median, var, dev, corr, sum, hist,

<function list>

Navigation menu

Personal tools