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

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 6: Line 6:
:;<var>type</var>:selects the smoothing algorithm (default=0)
:;<var>type</var>:selects the smoothing algorithm (default=0)
:;<var>s</var>:output step size; 0 < ''s'' <= <code>nrow(''x'')/2</code> (default=1)
:;<var>s</var>:output step size; 0 < ''s'' <= <code>nrow(''x'')/2</code> (default=1)
;Description:
;Description: The smoothed value ''xs''[i] is computed from the data values ''x''[i-m] to ''x''[i+m]. The general form of the smoothing function is:
The smoothed value ''xs''[i] is computed from the data values ''x''[i-m] to ''x''[i+m]. The general form of the smoothing function is:
:<math>xs[i] = \frac{ \sum_{j=-m}^m{x[i+j].w[j]} }{ \sum_{j=-m}^m{w[j]} }</math>
:<math>xs[i] = \frac{ \sum_{j=-m}^m{x[i+j].w[j]} }{ \sum_{j=-m}^m{w[j]} }</math>
:The weights ''w''[i] are selected by the argument ''type''
:The weights ''w''[i] are selected by the argument ''type''
{|class="einrahmen"  
{|class="einrahmen"  
!''type'' !! ''w''[j]
!''type'' !! ''w''[j] !!
|-
|-
|'''0'''  
|'''0''' ||1 ||average
|1  
|-
|-
|'''1'''  
|'''1''' |||<nowiki>1 / (|j|+1)</nowiki> ||reciprokal weighted average
|<nowiki>1 / (|j|+1)</nowiki>
|}
|}
;Result: A vector r with <code>nrow(''x'')/s</code> elements. The value ''r''[j] is set to the value ''xs''[j*s] of the smoothed data vector.
;Result: A vector r with <code>nrow(''x'')/s</code> elements. The value ''r''[j] is set to the value ''xs''[j*s] of the smoothed data vector.

Revision as of 14:10, 13 April 2011

Apply a smoothing to the vector x.

Usage
smooth(x {, type=0 {, m=1 {, s=1}}})
x
data vector
m
smoothing length; 0 < m <= nrow(x)/2 (default=1)
type
selects the smoothing algorithm (default=0)
s
output step size; 0 < s <= nrow(x)/2 (default=1)
Description
The smoothed value xs[i] is computed from the data values x[i-m] to x[i+m]. The general form of the smoothing function is:
{\displaystyle xs[i]={\frac {\sum _{j=-m}^{m}{x[i+j].w[j]}}{\sum _{j=-m}^{m}{w[j]}}}}
The weights w[i] are selected by the argument type
type w[j]
0 1 average
1 1 / (|j|+1) reciprokal weighted average
Result
A vector r with nrow(x)/s elements. The value r[j] is set to the value xs[j*s] of the smoothed data vector.

Navigation menu

Personal tools