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

From STX Wiki
Jump to navigationJump to search
(initial import)
 
No edit summary
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====wsum=====
Calculate the weighted sum over one or more user-defined extents of a function <var>y = f(x)</var>. Depending on the number of extents, the result of the function is a vector or a scalar.
;Usage:
:<code>wsum(<var>x</var>, <var>y</var>, <var>w</var>, <var>s</var>, <var>us</var>, <var>os</var>, <var>n</var>)</code>
:<code>wsum(<var>x</var>, <var>y</var>, <var>w</var>, <var>s</var>, <var>uv</var>, <var>ov</var>)</code>
:<code>wsum(<var>x</var>, <var>y</var>, <var>w</var>, <var>s</var>, <var>rv</var>)</code>
:<code>wsum(<var>x</var>, <var>y</var>, <var>w</var>, <var>s</var>, <var>rm</var>)</code>
:;<var>x, y</var>: the x- and y-data vector: <code>''y''[i] = f(''x''[i])</code>
:;<var>w</var>: defines the type of the weighting function
::{|class="keinrahmen"
|''w''=0 ||no weight (rectangle)
|-
|''w''=1 ||triangle
|-
|''w''=2 ||hanning window
|-
|''w''=2 ||hamming window
|}
:;<var>s</var>: if this argument is set to '''1''' the sum of each extent is normalized (scaled by <code>1/sum(weights)</code>), otherwise not
:;<var>us, os, n</var>: Every pair <code>{''us''+d*i, ''us''+d*(i+1)} (with: d=(''os''-''us'')/n, i=0..n-1)</code> defines an extent to sum. All three arguments are scalars.
:;<var>uv, ov</var>: Every pair <code>{''uv''[i], ''ov''[i]} (with: i=0..nrow(''uv'')-1)</code> defines an extent to sum. Both arguments must be vectors with same length.
:;<var>rv</var>: Every pair <code>{''rv''[i], ''rv''[i+1]} (with: i=0..nrow(''rv'')-2)</code> defines an extent to sum. The argument must be vector.
:;<var>rm</var>: Every pair <code>{''rm''[i,0], ''rm''[i,1]} (with: i=0..nrow(''rm'')-1)</code> defines an 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 weighted the ''y '' values over the i-th extent {xmin<sub>i</sub>, xmax<sub>i</sub>}.
:Note: an extent is defined by the x-range {xmin, xmax} and not by the indices!
;See also: [[../sum|sum]], [[../hist|hist]]


A weighted summation.
[[../#Functions|<function list>]]
 
=====Usage:=====
 
<code>wsum(<var>x</var>v,<var>y</var>v,<var>w</var>,<var>s</var>,<var>r</var>)</code>
 
=====Parameters:=====
 
;<var>xv</var>
 
:A scalar vector.
 
;<var>yv</var>
 
:A function vector (<code>y</code>i<code>=f(x</code>i<code>)</code>) with the same length as <var>x</var>.
 
;<var>w</var>
 
:The weighting function: a rectangle (<code>0</code>), a triangle (<code>1</code>), a Hanning window (<code>2</code>) or a Hamming window (<code>3</code>).
 
;<var>s</var>
 
:Normalize the results (<code>0</code>|<code>1</code>). If <code>1</code> -> scale with "1 / sum-of-weights".
 
;<var>r</var>
 
:The summation extent. <var>r</var> can be one, two or three arguments (see [[Programmer Guide/Command Reference/EVAL/sum|sum]] for details). Note, however, that the extent is given in values on the x-scale, not in indices.
 
=====Result:=====
 
A scalar or vector depending on the parameters.

Latest revision as of 13:22, 21 April 2011

Calculate the weighted sum over one or more user-defined extents of a function y = f(x). Depending on the number of extents, the result of the function is a vector or a scalar.

Usage
wsum(x, y, w, s, us, os, n)
wsum(x, y, w, s, uv, ov)
wsum(x, y, w, s, rv)
wsum(x, y, w, s, rm)
x, y
the x- and y-data vector: y[i] = f(x[i])
w
defines the type of the weighting function
w=0 no weight (rectangle)
w=1 triangle
w=2 hanning window
w=2 hamming window
s
if this argument is set to 1 the sum of each extent is normalized (scaled by 1/sum(weights)), otherwise not
us, os, n
Every pair {us+d*i, us+d*(i+1)} (with: d=(os-us)/n, i=0..n-1) defines an extent to sum. All three arguments are scalars.
uv, ov
Every pair {uv[i], ov[i]} (with: i=0..nrow(uv)-1) defines an extent to sum. Both arguments must be vectors with same length.
rv
Every pair {rv[i], rv[i+1]} (with: i=0..nrow(rv)-2) defines an extent to sum. The argument must be vector.
rm
Every pair {rm[i,0], rm[i,1]} (with: i=0..nrow(rm)-1) defines an 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 weighted the y values over the i-th extent {xmini, xmaxi}.
Note: an extent is defined by the x-range {xmin, xmax} and not by the indices!
See also
sum, hist

<function list>

Navigation menu

Personal tools