View Raw SPL
/*****************************************************************************
*                                                                            *
*   ROWSTDERR.SPL  Copyright (C) 2009 DSP Development Corporation            *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Calculates the standard error of each row of a series       *
*                                                                            *
*   Revisions:    12 Jul 2009  RRR  Creation                                 *
*                                                                            *
*****************************************************************************/

#if @HELP_ROWSTDERR

    ROWSTDERR

    Purpose: Calculates the standard error of each row of a multi-column series.

    Syntax:  ROWSTDERR(series)

              series - the input series or table

    Returns: A one column series with the same number of rows as the input. 

    Example:
             W1: ravel(1..12, 3)
             W2: rowstderr(w1)

             Returns {1,936492, 1,936492, 1,936492}, the standard error of
             each row of W1.
 
    Remarks:
             The standard error of series s is equal to:

             stdev(s)/sqrt(length(s))

             ROWSTDERR computes the standard error for each row of a multi-column
             series.

             ROWSTDERR does not assume that each column of the series contains the
             same number of rows.

    See Also:
             Colstdev
             Rowstdev
             Stats
             Stderr
             Stdev
#endif


/* standard error of each row */
rowstderr(a)
{
        if (argc < 1) error("rowstderr - input series required");

        return(rowstdev(a) / sqrt(rowlen(a)));
}