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

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====sum=====
Calculate the summation over one or more user-defined extents of a vector <var>x</var>. Depending on the number of extents, the result of the function is a vector or a scalar.


Calculate the summation over one or more user-defined extents of a vector <var>x</var>. The result of the following functions is a vector or a scalar (depending on the number of extents).


The summation of <var>n</var> extents of <var>x</var>. The first extent begins with the index <var>u</var>s and the last extent ends with the index <var>o</var>s.
;Usage:
:'''<code>sum(<var>x</var>, <var>us</var>, <var>os</var>, <var>n</var>)</code>'''
:'''<code>sum(<var>x</var>, <var>uv</var>, <var>ov</var>)</code>'''
:'''<code>sum(<var>x</var>, <var>rv</var>)</code>'''
:'''<code>sum(<var>x</var>, <var>rm</var>)</code>'''
:;<var>x</var>: the data vector
:;<var>us, os, n</var>: ''us'' is the lowest index, ''os'' the highest and ''n'' the number of extents. All three arguments are scalars. Every pair <code>{'us'+d*k, ''us''+d*(k+1)} (with: d=(''os''-''us'')/n, k=0..n-1)</code> defines an index extent to sum.
:;<var>uv, ov</var>: Every pair <code>{''uv''[k], ''ov''[k]} (with k=0..nrow(''uv'')-1)</code> defines an index extent to sum. Both arguments must be vectors with same length.
:;<var>rv</var>: Every pair <code>{''rv''[k], ''rv''[k+1]} (with k=0..nrow(''rv'')-2)</code> defines an index extent to sum. The argument must be vector.
:;<var>rm</var>: Every pair <code>{''rm''[k,0], ''rm''[k,1]} (with k=0..nrow(''rm'')-1)</code> defines an index extent to sum. The argument must be matrix with 2 columns.
;Result: The result ''r'' is a scalar or a vector. Each element ''r''<sub>i</sub> is the sum of the ''x'' values over the i-th index extent.
;See also: [[Programmer_Guide/Command_Reference/EVAL/wsum|wsum]], [[Programmer_Guide/Command_Reference/EVAL/hist|hist]]


=====Usage:=====
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]
 
<code>sum(<var>x</var>, <var>u</var>s, <var>o</var>s, <var>n</var>)</code>
 
=====Result:=====
 
If <var>n</var> > <code>1</code> the result is a vector, otherwise it is a scalar.
 
The summation over the extent nrow(<var>u</var>v). Every pair (<var>u</var>v[i], <var>o</var>v[i]) defines an index extent to sum.
 
=====Usage:=====
 
<code>sum(<var>x</var>, <var>u</var>v, <var>o</var>v)</code>
 
The summation over the extent nrow(<var>r</var>v)-1. Every pair (<var>r</var>v[i], <var>r</var>v[i+1]) defines an index extent to sum.
 
=====Usage:=====
 
<code>sum(<var>x</var>, <var>r</var>v)</code>
 
The summation over the extent nrow(<var>r</var>m). Every pair (<var>r</var>m[i,0], <var>r</var>v[i,1] defines an index extent for summation.
 
=====Usage:=====
 
<code>sum(<var>x</var>, <var>r</var>m)</code>

Revision as of 10:44, 8 April 2011

Calculate the summation over one or more user-defined extents of a vector x. Depending on the number of extents, the result of the function is a vector or a scalar.


Usage
sum(x, us, os, n)
sum(x, uv, ov)
sum(x, rv)
sum(x, rm)
x
the data vector
us, os, n
us is the lowest index, os the highest and n the number of extents. All three arguments are scalars. Every pair {'us'+d*k, us+d*(k+1)} (with: d=(os-us)/n, k=0..n-1) defines an index extent to sum.
uv, ov
Every pair {uv[k], ov[k]} (with k=0..nrow(uv)-1) defines an index extent to sum. Both arguments must be vectors with same length.
rv
Every pair {rv[k], rv[k+1]} (with k=0..nrow(rv)-2) defines an index extent to sum. The argument must be vector.
rm
Every pair {rm[k,0], rm[k,1]} (with k=0..nrow(rm)-1) defines an index extent to sum. The argument must be matrix with 2 columns.
Result
The result r is a scalar or a vector. Each element ri is the sum of the x values over the i-th index extent.
See also
wsum, hist

<function list>

Navigation menu

Personal tools