View Raw SPL
/*****************************************************************************
* *
* DEMEAN.SPL Copyright (C) 2002-2015 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Remove the mean from a series *
* *
* Revisions: 28 Aug 2002 RRR Creation *
* 26 Sep 2015 RRR ITERATE for simple column iteration *
* *
*****************************************************************************/
#if @HELP_DEMEAN
DEMEAN
Purpose: Removes the mean (DC value) from a series
Syntax: DEMEAN(series)
series - A series or table.
Returns: A series or table.
Example:
demean(gsin(100, 0.01) + 23)
returns the sinewave minus the mean, or gsin(100, 0.01).
Remarks:
DEMEAN removes the mean (or DC value) from a series.
DEMEAN is often used when computing the SPECTRUM of a
series to prevent a large DC value (the first point of a
spectrum) from visually dominating the plot.
See Also:
Detrend
Mean
Spectrum
#endif
/* remove the mean (DC value) from a series */
ITERATE demean(s, opt)
{
if (argc < 2)
{
if (argc < 1) error("demean - input series required");
opt = 0;
}
return(s - mean(s));
}